@apple-pie/slice-native 0.1.4 → 0.1.7
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/README.md +164 -97
- package/SliceNative.podspec +24 -0
- package/dist/cjs/components.js +19 -0
- package/dist/cjs/hooks.js +9 -0
- package/dist/cjs/index.js +27 -812
- package/dist/cjs/providers.js +9 -0
- package/dist/cjs/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +11 -0
- package/dist/cjs/src/components/SliceButton/SliceButton.js +146 -0
- package/dist/cjs/src/components/SliceIcon/SliceIcon.js +20 -0
- package/dist/cjs/src/components/SliceIcon/iconRegistry.js +668 -0
- package/dist/cjs/src/components/SliceIcon/icons.js +144 -0
- package/dist/cjs/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +12 -0
- package/dist/cjs/src/components/SliceText/SliceText.js +21 -0
- package/dist/cjs/src/components/SliceTextInput/SliceTextInput.js +117 -0
- package/dist/cjs/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +13 -0
- package/dist/cjs/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +19 -0
- package/dist/cjs/src/providers/SliceThemeProvider.js +37 -0
- package/dist/cjs/src/theme/colors/colors.js +253 -0
- package/dist/cjs/src/theme/corners/corners.js +14 -0
- package/dist/cjs/src/theme/elevations/elevations.js +17 -0
- package/dist/cjs/src/theme/motion/motion.js +15 -0
- package/dist/cjs/src/theme/motion.js +47 -0
- package/dist/cjs/src/theme/spacing/spacing.js +14 -0
- package/dist/cjs/src/theme/type/type.js +190 -0
- package/dist/cjs/src/utils/sizes/sizes.js +40 -0
- package/dist/cjs/src/utils/typography/typography.js +17 -0
- package/dist/cjs/theme.js +23 -538
- package/dist/cjs/utils.js +10 -0
- package/dist/esm/components.mjs +7 -0
- package/dist/esm/hooks.mjs +2 -0
- package/dist/esm/index.mjs +12 -813
- package/dist/esm/providers.mjs +1 -0
- package/dist/esm/src/components/SliceBackgroundBlur/SliceBackgroundBlur.mjs +9 -0
- package/dist/esm/src/components/SliceButton/SliceButton.mjs +144 -0
- package/dist/esm/src/components/SliceIcon/SliceIcon.mjs +18 -0
- package/dist/esm/src/components/SliceIcon/iconRegistry.mjs +666 -0
- package/dist/esm/src/components/SliceIcon/icons.mjs +142 -0
- package/dist/esm/src/components/SliceLiquidGlassView/SliceLiquidGlassView.mjs +10 -0
- package/dist/esm/src/components/SliceText/SliceText.mjs +19 -0
- package/dist/esm/src/components/SliceTextInput/SliceTextInput.mjs +115 -0
- package/dist/esm/src/hooks/useCreateThemedStyles/useCreateThemedStyles.mjs +11 -0
- package/dist/esm/src/hooks/useDeviceCapabilities/useDeviceCapabilities.mjs +17 -0
- package/dist/esm/src/providers/SliceThemeProvider.mjs +33 -0
- package/dist/esm/src/theme/colors/colors.mjs +249 -0
- package/dist/esm/src/theme/corners/corners.mjs +12 -0
- package/dist/esm/src/theme/elevations/elevations.mjs +15 -0
- package/dist/esm/src/theme/motion/motion.mjs +13 -0
- package/dist/esm/src/theme/motion.mjs +45 -0
- package/dist/esm/src/theme/spacing/spacing.mjs +12 -0
- package/dist/esm/src/theme/type/type.mjs +184 -0
- package/dist/esm/src/utils/sizes/sizes.mjs +37 -0
- package/dist/esm/src/utils/typography/typography.mjs +15 -0
- package/dist/esm/theme.mjs +7 -522
- package/dist/esm/utils.mjs +2 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +6 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.js +6 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/index.js +1 -0
- package/dist/react-native/native/src/components/SliceButton/SliceButton.js +141 -0
- package/dist/react-native/native/src/components/SliceButton/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceButton/index.js +1 -0
- package/dist/react-native/native/src/components/SliceIcon/SliceIcon.js +15 -0
- package/dist/react-native/native/src/components/SliceIcon/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceIcon/iconRegistry.js +663 -0
- package/dist/react-native/native/src/components/SliceIcon/icons.js +140 -0
- package/dist/react-native/native/src/components/SliceIcon/index.js +2 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.js +6 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +7 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/index.js +1 -0
- package/dist/react-native/native/src/components/SliceText/SliceText.js +16 -0
- package/dist/react-native/native/src/components/SliceText/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceText/index.js +1 -0
- package/dist/react-native/native/src/components/SliceTextInput/SliceTextInput.js +111 -0
- package/dist/react-native/native/src/components/SliceTextInput/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceTextInput/index.js +1 -0
- package/dist/react-native/native/src/components/index.js +6 -0
- package/dist/react-native/native/src/hooks/index.js +2 -0
- package/dist/react-native/native/src/hooks/useCreateThemedStyles/index.js +1 -0
- package/dist/react-native/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +8 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/_types.js +1 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/index.js +1 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +14 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.js +23 -0
- package/dist/react-native/native/src/index.js +6 -0
- package/dist/react-native/native/src/providers/SliceThemeProvider.js +30 -0
- package/dist/react-native/native/src/providers/index.js +1 -0
- package/dist/react-native/native/src/specs/BackgroundBlurNativeComponent.ts +16 -0
- package/dist/react-native/native/src/specs/LiquidGlassNativeComponent.ts +18 -0
- package/dist/react-native/native/src/specs/NativeDeviceCapabilities.ts +13 -0
- package/dist/react-native/native/src/theme/index.js +69 -0
- package/dist/react-native/native/src/theme/motion.js +43 -0
- package/dist/react-native/native/src/types/index.js +1 -0
- package/dist/react-native/native/src/types/sharedTypes.js +1 -0
- package/dist/react-native/native/src/utils/index.js +2 -0
- package/dist/react-native/native/src/utils/sizes/index.js +1 -0
- package/dist/react-native/native/src/utils/sizes/sizes.js +35 -0
- package/dist/react-native/native/src/utils/typography/index.js +1 -0
- package/dist/react-native/native/src/utils/typography/typography.js +13 -0
- package/dist/react-native/src/theme/colors/colors.js +385 -0
- package/dist/react-native/src/theme/colors/types.js +1 -0
- package/dist/react-native/src/theme/corners/corners.js +10 -0
- package/dist/react-native/src/theme/corners/types.js +1 -0
- package/dist/react-native/src/theme/elevations/_types.js +1 -0
- package/dist/react-native/src/theme/elevations/elevations.js +13 -0
- package/dist/react-native/src/theme/motion/_types.js +1 -0
- package/dist/react-native/src/theme/motion/motion.js +11 -0
- package/dist/react-native/src/theme/spacing/_types.js +1 -0
- package/dist/react-native/src/theme/spacing/spacing.js +10 -0
- package/dist/react-native/src/theme/type/type.js +371 -0
- package/dist/react-native/src/theme/type/types.js +1 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.d.ts +3 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.d.ts +2 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/_types.d.ts +24 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceButton/SliceButton.d.ts +5 -0
- package/dist/types/native/src/components/SliceButton/_types.d.ts +78 -0
- package/dist/types/native/src/components/SliceButton/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceIcon/SliceIcon.d.ts +2 -0
- package/dist/types/native/{components/Icon → src/components/SliceIcon}/icons.d.ts +1 -0
- package/dist/types/native/src/components/SliceIcon/index.d.ts +3 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.d.ts +3 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.d.ts +2 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/_types.d.ts +17 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceText/SliceText.d.ts +5 -0
- package/dist/types/native/src/components/SliceText/_types.d.ts +17 -0
- package/dist/types/native/src/components/SliceText/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceTextInput/SliceTextInput.d.ts +2 -0
- package/dist/types/native/src/components/SliceTextInput/_types.d.ts +58 -0
- package/dist/types/native/src/components/SliceTextInput/index.d.ts +2 -0
- package/dist/types/native/src/components/index.d.ts +12 -0
- package/dist/types/native/src/hooks/index.d.ts +3 -0
- package/dist/types/native/src/hooks/useCreateThemedStyles/index.d.ts +1 -0
- package/dist/types/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.d.ts +7 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/_types.d.ts +17 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/index.d.ts +2 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.d.ts +3 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.d.ts +7 -0
- package/dist/types/native/src/index.d.ts +12 -0
- package/dist/types/native/src/providers/SliceThemeProvider.d.ts +16 -0
- package/dist/types/native/src/providers/index.d.ts +2 -0
- package/dist/types/native/src/specs/BackgroundBlurNativeComponent.d.ts +9 -0
- package/dist/types/native/src/specs/LiquidGlassNativeComponent.d.ts +9 -0
- package/dist/types/native/src/specs/NativeDeviceCapabilities.d.ts +11 -0
- package/dist/types/native/{theme → src/theme}/index.d.ts +5 -5
- package/dist/types/native/src/types/index.d.ts +1 -0
- package/dist/types/native/src/types/sharedTypes.d.ts +14 -0
- package/dist/types/native/src/utils/index.d.ts +2 -0
- package/dist/types/native/src/utils/sizes/index.d.ts +1 -0
- package/dist/types/native/src/utils/sizes/sizes.d.ts +7 -0
- package/dist/types/native/src/utils/typography/index.d.ts +1 -0
- package/dist/types/native/src/utils/typography/typography.d.ts +7 -0
- package/package.json +57 -11
- package/platform/android/build.gradle +22 -0
- package/platform/android/src/main/AndroidManifest.xml +1 -0
- package/platform/android/src/main/java/com/slice/SliceBackgroundBlurManager.java +28 -0
- package/platform/android/src/main/java/com/slice/SliceBackgroundBlurView.java +98 -0
- package/platform/android/src/main/java/com/slice/SliceDeviceCapabilitiesModule.java +25 -0
- package/platform/android/src/main/java/com/slice/SlicePackage.java +25 -0
- package/platform/ios/BackgroundBlurSurface.swift +89 -0
- package/platform/ios/LiquidGlassSurface.swift +82 -0
- package/platform/ios/RCTBackgroundBlurView.h +3 -0
- package/platform/ios/RCTBackgroundBlurView.mm +42 -0
- package/platform/ios/RCTLiquidGlassView.h +8 -0
- package/platform/ios/RCTLiquidGlassView.mm +73 -0
- package/platform/ios/SliceDeviceCapabilities.h +4 -0
- package/platform/ios/SliceDeviceCapabilities.mm +35 -0
- package/react-native.config.js +1 -0
- package/src/specs/BackgroundBlurNativeComponent.ts +16 -0
- package/src/specs/LiquidGlassNativeComponent.ts +18 -0
- package/src/specs/NativeDeviceCapabilities.ts +13 -0
- package/dist/types/native/components/Icon/NativeIcon.d.ts +0 -2
- package/dist/types/native/components/Icon/index.d.ts +0 -3
- package/dist/types/native/index.d.ts +0 -4
- /package/dist/types/native/{components/Icon → src/components/SliceIcon}/_types.d.ts +0 -0
- /package/dist/types/native/{components/Icon → src/components/SliceIcon}/iconRegistry.d.ts +0 -0
- /package/dist/types/native/{theme → src/theme}/motion.d.ts +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Convert Slice's explicit CSS curves without importing the React Native runtime. */
|
|
2
|
+
function easing(css) {
|
|
3
|
+
if (css.startsWith('cubic-bezier(')) {
|
|
4
|
+
const [x1, y1, x2, y2] = css.slice(13, -1).split(',').map(Number);
|
|
5
|
+
const sample = (t, a, b) => 3 * (1 - t) ** 2 * t * a + 3 * (1 - t) * t ** 2 * b + t ** 3;
|
|
6
|
+
return (progress) => {
|
|
7
|
+
if (progress <= 0)
|
|
8
|
+
return 0;
|
|
9
|
+
if (progress >= 1)
|
|
10
|
+
return 1;
|
|
11
|
+
let low = 0;
|
|
12
|
+
let high = 1;
|
|
13
|
+
for (let i = 0; i < 30; i++) {
|
|
14
|
+
const middle = (low + high) / 2;
|
|
15
|
+
if (sample(middle, x1, x2) < progress)
|
|
16
|
+
low = middle;
|
|
17
|
+
else
|
|
18
|
+
high = middle;
|
|
19
|
+
}
|
|
20
|
+
return sample((low + high) / 2, y1, y2);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (!css.startsWith('linear('))
|
|
24
|
+
throw new Error(`Unsupported Slice easing: ${css}`);
|
|
25
|
+
const points = css
|
|
26
|
+
.slice(7, -1)
|
|
27
|
+
.split(',')
|
|
28
|
+
.map((entry, index, entries) => {
|
|
29
|
+
const [value, percent] = entry.trim().split(/\s+/).map(Number.parseFloat);
|
|
30
|
+
return { value, position: percent === undefined ? index / (entries.length - 1) : percent / 100 };
|
|
31
|
+
});
|
|
32
|
+
return (progress) => {
|
|
33
|
+
if (progress <= 0)
|
|
34
|
+
return points[0].value;
|
|
35
|
+
for (let i = 1; i < points.length; i++) {
|
|
36
|
+
const left = points[i - 1];
|
|
37
|
+
const right = points[i];
|
|
38
|
+
if (progress <= right.position)
|
|
39
|
+
return (left.value + ((right.value - left.value) * (progress - left.position)) / (right.position - left.position));
|
|
40
|
+
}
|
|
41
|
+
return points[points.length - 1].value;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { easing };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// base family
|
|
2
|
+
const fontFamily = `var(--slice-font-family, "Funnel Sans")`;
|
|
3
|
+
// base weights
|
|
4
|
+
const fontWeights = {
|
|
5
|
+
regular: 360,
|
|
6
|
+
medium: 420,
|
|
7
|
+
bold: 500,
|
|
8
|
+
extra: 560,
|
|
9
|
+
};
|
|
10
|
+
// base sizes
|
|
11
|
+
const fontSizes = {
|
|
12
|
+
xs: '0.75rem',
|
|
13
|
+
s: '0.875rem',
|
|
14
|
+
m: '0.9375rem',
|
|
15
|
+
l: '1rem',
|
|
16
|
+
xl: '1.0625rem',
|
|
17
|
+
h1: '4.25rem',
|
|
18
|
+
h2: '3.5rem',
|
|
19
|
+
h3: '2.75rem',
|
|
20
|
+
h4: '2rem',
|
|
21
|
+
h5: '1.5rem',
|
|
22
|
+
h6: '1.0625rem',
|
|
23
|
+
};
|
|
24
|
+
// base line heights
|
|
25
|
+
const lineHeights = {
|
|
26
|
+
xs: '116.67%',
|
|
27
|
+
m: '133.33%',
|
|
28
|
+
l: '140%',
|
|
29
|
+
xl: '142.86%',
|
|
30
|
+
xxl: '162.5%',
|
|
31
|
+
};
|
|
32
|
+
// base letter spacing
|
|
33
|
+
const letterSpacings = {
|
|
34
|
+
xs: '0.00625em',
|
|
35
|
+
s: '0.009375em',
|
|
36
|
+
m: '0.0125em',
|
|
37
|
+
l: '0.015625em',
|
|
38
|
+
};
|
|
39
|
+
// ** new styles aligned to lyra */
|
|
40
|
+
const type = {
|
|
41
|
+
'body-xs-regular': `
|
|
42
|
+
font-family: ${fontFamily};
|
|
43
|
+
font-weight: ${fontWeights.regular};
|
|
44
|
+
font-size: ${fontSizes.xs};
|
|
45
|
+
line-height: ${lineHeights.m};
|
|
46
|
+
text-decoration: none;
|
|
47
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
48
|
+
'body-xs-medium': `
|
|
49
|
+
font-family: ${fontFamily};
|
|
50
|
+
font-weight: ${fontWeights.medium};
|
|
51
|
+
font-size: ${fontSizes.xs};
|
|
52
|
+
line-height: ${lineHeights.m};
|
|
53
|
+
text-decoration: none;
|
|
54
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
55
|
+
'body-xs-bold': `
|
|
56
|
+
font-family: ${fontFamily};
|
|
57
|
+
font-weight: ${fontWeights.bold};
|
|
58
|
+
font-size: ${fontSizes.xs};
|
|
59
|
+
line-height: ${lineHeights.m};
|
|
60
|
+
text-decoration: none;
|
|
61
|
+
letter-spacing: ${letterSpacings.l}`,
|
|
62
|
+
'body-s-regular': `
|
|
63
|
+
font-family: ${fontFamily};
|
|
64
|
+
font-weight: ${fontWeights.regular};
|
|
65
|
+
font-size: ${fontSizes.s};
|
|
66
|
+
line-height: ${lineHeights.xl};
|
|
67
|
+
text-decoration: none;
|
|
68
|
+
letter-spacing: ${letterSpacings.s}`,
|
|
69
|
+
'body-s-medium': `
|
|
70
|
+
font-family: ${fontFamily};
|
|
71
|
+
font-weight: ${fontWeights.medium};
|
|
72
|
+
font-size: ${fontSizes.s};
|
|
73
|
+
line-height: ${lineHeights.xl};
|
|
74
|
+
text-decoration: none;
|
|
75
|
+
letter-spacing: ${letterSpacings.s}`,
|
|
76
|
+
'body-s-bold': `
|
|
77
|
+
font-family: ${fontFamily};
|
|
78
|
+
font-weight: ${fontWeights.bold};
|
|
79
|
+
font-size: ${fontSizes.s};
|
|
80
|
+
line-height: ${lineHeights.xl};
|
|
81
|
+
text-decoration: none;
|
|
82
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
83
|
+
'body-m-regular': `
|
|
84
|
+
font-family: ${fontFamily};
|
|
85
|
+
font-weight: ${fontWeights.regular};
|
|
86
|
+
font-size: ${fontSizes.m};
|
|
87
|
+
line-height: ${lineHeights.l};
|
|
88
|
+
text-decoration: none;
|
|
89
|
+
letter-spacing: ${letterSpacings.s}`,
|
|
90
|
+
'body-m-medium': `
|
|
91
|
+
font-family: ${fontFamily};
|
|
92
|
+
font-weight: ${fontWeights.medium};
|
|
93
|
+
font-size: ${fontSizes.m};
|
|
94
|
+
line-height: ${lineHeights.l};
|
|
95
|
+
text-decoration: none;
|
|
96
|
+
letter-spacing: ${letterSpacings.s}`,
|
|
97
|
+
'body-m-bold': `
|
|
98
|
+
font-family: ${fontFamily};
|
|
99
|
+
font-weight: ${fontWeights.bold};
|
|
100
|
+
font-size: ${fontSizes.m};
|
|
101
|
+
line-height: ${lineHeights.l};
|
|
102
|
+
text-decoration: none;
|
|
103
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
104
|
+
'body-l-regular': `
|
|
105
|
+
font-family: ${fontFamily};
|
|
106
|
+
font-weight: ${fontWeights.regular};
|
|
107
|
+
font-size: ${fontSizes.l};
|
|
108
|
+
line-height: ${lineHeights.xxl};
|
|
109
|
+
text-decoration: none;
|
|
110
|
+
letter-spacing: ${letterSpacings.xs}`,
|
|
111
|
+
'body-l-medium': `
|
|
112
|
+
font-family: ${fontFamily};
|
|
113
|
+
font-weight: ${fontWeights.medium};
|
|
114
|
+
font-size: ${fontSizes.l};
|
|
115
|
+
line-height: ${lineHeights.xxl};
|
|
116
|
+
text-decoration: none;
|
|
117
|
+
letter-spacing: ${letterSpacings.xs}`,
|
|
118
|
+
'body-l-bold': `
|
|
119
|
+
font-family: ${fontFamily};
|
|
120
|
+
font-weight: ${fontWeights.bold};
|
|
121
|
+
font-size: ${fontSizes.l};
|
|
122
|
+
line-height: ${lineHeights.xxl};
|
|
123
|
+
text-decoration: none;
|
|
124
|
+
letter-spacing: ${letterSpacings.s}`,
|
|
125
|
+
'body-xl-regular': `
|
|
126
|
+
font-family: ${fontFamily};
|
|
127
|
+
font-weight: ${fontWeights.regular};
|
|
128
|
+
font-size: ${fontSizes.xl};
|
|
129
|
+
line-height: ${lineHeights.xxl};
|
|
130
|
+
text-decoration: none;
|
|
131
|
+
letter-spacing: ${letterSpacings.xs}`,
|
|
132
|
+
'body-xl-medium': `
|
|
133
|
+
font-family: ${fontFamily};
|
|
134
|
+
font-weight: ${fontWeights.medium};
|
|
135
|
+
font-size: ${fontSizes.xl};
|
|
136
|
+
line-height: ${lineHeights.xxl};
|
|
137
|
+
text-decoration: none;
|
|
138
|
+
letter-spacing: ${letterSpacings.xs}`,
|
|
139
|
+
'body-xl-bold': `
|
|
140
|
+
font-family: ${fontFamily};
|
|
141
|
+
font-weight: ${fontWeights.bold};
|
|
142
|
+
font-size: ${fontSizes.xl};
|
|
143
|
+
line-height: ${lineHeights.xxl};
|
|
144
|
+
text-decoration: none;
|
|
145
|
+
letter-spacing: ${letterSpacings.s}`,
|
|
146
|
+
h1: `
|
|
147
|
+
font-family: ${fontFamily};
|
|
148
|
+
font-weight: ${fontWeights.extra};
|
|
149
|
+
font-size: ${fontSizes.h1};
|
|
150
|
+
line-height: ${lineHeights.xs};
|
|
151
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
152
|
+
h2: `
|
|
153
|
+
font-family: ${fontFamily};
|
|
154
|
+
font-weight: ${fontWeights.extra};
|
|
155
|
+
font-size: ${fontSizes.h2};
|
|
156
|
+
line-height: ${lineHeights.xs};
|
|
157
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
158
|
+
h3: `
|
|
159
|
+
font-family: ${fontFamily};
|
|
160
|
+
font-weight: ${fontWeights.extra};
|
|
161
|
+
font-size: ${fontSizes.h3};
|
|
162
|
+
line-height: ${lineHeights.xs};
|
|
163
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
164
|
+
h4: `
|
|
165
|
+
font-family: ${fontFamily};
|
|
166
|
+
font-weight: ${fontWeights.extra};
|
|
167
|
+
font-size: ${fontSizes.h4};
|
|
168
|
+
line-height: ${lineHeights.xs};
|
|
169
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
170
|
+
h5: `
|
|
171
|
+
font-family: ${fontFamily};
|
|
172
|
+
font-weight: ${fontWeights.extra};
|
|
173
|
+
font-size: ${fontSizes.h5};
|
|
174
|
+
line-height: ${lineHeights.xs};
|
|
175
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
176
|
+
h6: `
|
|
177
|
+
font-family: ${fontFamily};
|
|
178
|
+
font-weight: ${fontWeights.extra};
|
|
179
|
+
font-size: ${fontSizes.h6};
|
|
180
|
+
line-height: ${lineHeights.xs};
|
|
181
|
+
letter-spacing: ${letterSpacings.m}`,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export { fontSizes, fontWeights, letterSpacings, lineHeights, type };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal utility converting size props to an absolute number
|
|
3
|
+
*/
|
|
4
|
+
function sizeToNumber(size) {
|
|
5
|
+
if (!size)
|
|
6
|
+
return 48;
|
|
7
|
+
if (typeof size === 'number')
|
|
8
|
+
return size;
|
|
9
|
+
switch (size) {
|
|
10
|
+
case 's': {
|
|
11
|
+
return 40;
|
|
12
|
+
}
|
|
13
|
+
case 'm': {
|
|
14
|
+
return 48;
|
|
15
|
+
}
|
|
16
|
+
case 'l': {
|
|
17
|
+
return 56;
|
|
18
|
+
}
|
|
19
|
+
default:
|
|
20
|
+
return 48;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Resolve radius presets; invalid or negative values produce square corners. */
|
|
24
|
+
function borderRadiusToNumber(borderRadius) {
|
|
25
|
+
if (typeof borderRadius === 'number')
|
|
26
|
+
return Number.isFinite(borderRadius) ? Math.max(0, borderRadius) : 0;
|
|
27
|
+
switch (borderRadius) {
|
|
28
|
+
case 'pill':
|
|
29
|
+
return 1000;
|
|
30
|
+
case 'rectangular':
|
|
31
|
+
return 4;
|
|
32
|
+
default:
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { borderRadiusToNumber, sizeToNumber };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple utility to take text style and returns a defined line height factor
|
|
3
|
+
* Since there is no relative/percent in native, looks for the fontsize and
|
|
4
|
+
* derives an absolute line height from the font size
|
|
5
|
+
*/
|
|
6
|
+
function lineHeightTextStyle(styles, lineHeightFactor = 1.2) {
|
|
7
|
+
if (!Number.isFinite(lineHeightFactor) || lineHeightFactor < 0 || lineHeightFactor > 2) {
|
|
8
|
+
throw new Error('lineHeightFactor must be a number between 0 and 2');
|
|
9
|
+
}
|
|
10
|
+
const fontSize = styles.fontSize ?? 16;
|
|
11
|
+
const lineHeight = lineHeightFactor * fontSize;
|
|
12
|
+
return { ...styles, lineHeight };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { lineHeightTextStyle };
|