@tamagui/core 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/config.js +12 -0
- package/dist/cjs/config.js.map +3 -3
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +11 -16
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/expandStyles.js +10 -3
- package/dist/cjs/helpers/expandStyles.js.map +3 -3
- package/dist/cjs/helpers/getSplitStyles.js +28 -0
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/normalizeColor.js +16 -37
- package/dist/cjs/helpers/normalizeColor.js.map +3 -3
- package/dist/cjs/helpers/normalizeValueWithProperty.js +1 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +2 -2
- package/dist/esm/config.js +11 -0
- package/dist/esm/config.js.map +3 -3
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +11 -16
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/expandStyles.js +5 -4
- package/dist/esm/helpers/expandStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +29 -1
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/normalizeColor.js +14 -35
- package/dist/esm/helpers/normalizeColor.js.map +3 -3
- package/dist/esm/helpers/normalizeValueWithProperty.js +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +2 -2
- package/package.json +11 -11
- package/reset.css +1 -1
- package/src/config.ts +11 -0
- package/src/createComponent.tsx +1 -0
- package/src/helpers/createPropMapper.ts +12 -16
- package/src/helpers/expandStyles.ts +5 -4
- package/src/helpers/getSplitStyles.tsx +35 -3
- package/src/helpers/normalizeColor.ts +14 -38
- package/src/helpers/normalizeValueWithProperty.ts +1 -1
- package/types/config.d.ts +1 -0
- package/types/helpers/normalizeColor.d.ts +2 -2
|
@@ -1,54 +1,30 @@
|
|
|
1
1
|
import { isWeb } from '@tamagui/constants'
|
|
2
|
-
import normalizeCSSColor from 'normalize-css-color'
|
|
2
|
+
import normalizeCSSColor, { rgba } from '@tamagui/normalize-css-color'
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export { rgba } from '@tamagui/normalize-css-color'
|
|
5
|
+
|
|
6
|
+
export const normalizeColor = (color?: string | null, opacity?: number) => {
|
|
7
|
+
if (color === null || color === undefined) {
|
|
6
8
|
return
|
|
7
9
|
}
|
|
10
|
+
if (color === 'transparent') {
|
|
11
|
+
return `rgba(0,0,0,0)`
|
|
12
|
+
}
|
|
8
13
|
if (
|
|
9
14
|
color[0] === '$' ||
|
|
10
|
-
(isWeb &&
|
|
11
|
-
typeof color === 'string' &&
|
|
12
|
-
(webColors[color] || color[0] === '_' || color.startsWith('var(')))
|
|
15
|
+
(isWeb && (webColors[color] || color[0] === '_' || color.startsWith('var(')))
|
|
13
16
|
) {
|
|
14
17
|
return color
|
|
15
|
-
} else {
|
|
16
|
-
const rgba = colorToRGBA(color)
|
|
17
|
-
if (rgba != null) {
|
|
18
|
-
const [r, g, b, a] = rgba
|
|
19
|
-
const alpha = (opacity ?? a).toFixed(2)
|
|
20
|
-
return `rgba(${r},${g},${b},${alpha})`
|
|
21
|
-
}
|
|
22
18
|
}
|
|
23
|
-
|
|
19
|
+
const colorProcessed = normalizeCSSColor(color)
|
|
20
|
+
if (colorProcessed !== null) {
|
|
21
|
+
const { r, g, b, a } = rgba(colorProcessed)
|
|
22
|
+
return `rgba(${r},${g},${b},${a.toFixed(2)})`
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const webColors = {
|
|
27
27
|
currentColor: true,
|
|
28
28
|
currentcolor: true,
|
|
29
|
-
transparent: true,
|
|
30
29
|
inherit: true,
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
export function colorToRGBA(color: string | number) {
|
|
34
|
-
const ci = processColor(color)
|
|
35
|
-
if (ci != null) {
|
|
36
|
-
const r = (ci >> 16) & 255
|
|
37
|
-
const g = (ci >> 8) & 255
|
|
38
|
-
const b = ci & 255
|
|
39
|
-
const a = ((ci >> 24) & 255) / 255
|
|
40
|
-
return [r, g, b, a] as const
|
|
41
|
-
}
|
|
42
|
-
return null
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const processColor = (color?: number | string) => {
|
|
46
|
-
if (color === undefined || color === null) {
|
|
47
|
-
return null
|
|
48
|
-
}
|
|
49
|
-
const intColor = normalizeCSSColor(color)
|
|
50
|
-
if (intColor === undefined || intColor === null) {
|
|
51
|
-
return null
|
|
52
|
-
}
|
|
53
|
-
return ((+intColor << 24) | (+intColor >>> 8)) >>> 0
|
|
54
|
-
}
|
|
@@ -27,7 +27,7 @@ export function normalizeValueWithProperty(value: any, property?: string): any {
|
|
|
27
27
|
res = `${value}px`
|
|
28
28
|
} else if (isWeb && property !== undefined && stringNumbers[property]) {
|
|
29
29
|
res = `${res}`
|
|
30
|
-
} else if (property && colorProps
|
|
30
|
+
} else if (property && property in colorProps) {
|
|
31
31
|
res = normalizeColor(value)
|
|
32
32
|
cache[value] = res
|
|
33
33
|
}
|
package/types/config.d.ts
CHANGED
|
@@ -43,4 +43,5 @@ export declare const getThemes: () => {
|
|
|
43
43
|
export declare const configListeners: Set<ConfigListener>;
|
|
44
44
|
export declare const onConfiguredOnce: (cb: ConfigListener) => void;
|
|
45
45
|
export declare const updateConfig: (key: string, value: any) => void;
|
|
46
|
+
export declare const getFont: (name: string) => import("./types").GenericFont<string | number>;
|
|
46
47
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare
|
|
1
|
+
export { rgba } from '@tamagui/normalize-css-color';
|
|
2
|
+
export declare const normalizeColor: (color?: string | null, opacity?: number) => string | undefined;
|
|
3
3
|
//# sourceMappingURL=normalizeColor.d.ts.map
|