@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.
Files changed (178) hide show
  1. package/README.md +164 -97
  2. package/SliceNative.podspec +24 -0
  3. package/dist/cjs/components.js +19 -0
  4. package/dist/cjs/hooks.js +9 -0
  5. package/dist/cjs/index.js +27 -812
  6. package/dist/cjs/providers.js +9 -0
  7. package/dist/cjs/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +11 -0
  8. package/dist/cjs/src/components/SliceButton/SliceButton.js +146 -0
  9. package/dist/cjs/src/components/SliceIcon/SliceIcon.js +20 -0
  10. package/dist/cjs/src/components/SliceIcon/iconRegistry.js +668 -0
  11. package/dist/cjs/src/components/SliceIcon/icons.js +144 -0
  12. package/dist/cjs/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +12 -0
  13. package/dist/cjs/src/components/SliceText/SliceText.js +21 -0
  14. package/dist/cjs/src/components/SliceTextInput/SliceTextInput.js +117 -0
  15. package/dist/cjs/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +13 -0
  16. package/dist/cjs/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +19 -0
  17. package/dist/cjs/src/providers/SliceThemeProvider.js +37 -0
  18. package/dist/cjs/src/theme/colors/colors.js +253 -0
  19. package/dist/cjs/src/theme/corners/corners.js +14 -0
  20. package/dist/cjs/src/theme/elevations/elevations.js +17 -0
  21. package/dist/cjs/src/theme/motion/motion.js +15 -0
  22. package/dist/cjs/src/theme/motion.js +47 -0
  23. package/dist/cjs/src/theme/spacing/spacing.js +14 -0
  24. package/dist/cjs/src/theme/type/type.js +190 -0
  25. package/dist/cjs/src/utils/sizes/sizes.js +40 -0
  26. package/dist/cjs/src/utils/typography/typography.js +17 -0
  27. package/dist/cjs/theme.js +23 -538
  28. package/dist/cjs/utils.js +10 -0
  29. package/dist/esm/components.mjs +7 -0
  30. package/dist/esm/hooks.mjs +2 -0
  31. package/dist/esm/index.mjs +12 -813
  32. package/dist/esm/providers.mjs +1 -0
  33. package/dist/esm/src/components/SliceBackgroundBlur/SliceBackgroundBlur.mjs +9 -0
  34. package/dist/esm/src/components/SliceButton/SliceButton.mjs +144 -0
  35. package/dist/esm/src/components/SliceIcon/SliceIcon.mjs +18 -0
  36. package/dist/esm/src/components/SliceIcon/iconRegistry.mjs +666 -0
  37. package/dist/esm/src/components/SliceIcon/icons.mjs +142 -0
  38. package/dist/esm/src/components/SliceLiquidGlassView/SliceLiquidGlassView.mjs +10 -0
  39. package/dist/esm/src/components/SliceText/SliceText.mjs +19 -0
  40. package/dist/esm/src/components/SliceTextInput/SliceTextInput.mjs +115 -0
  41. package/dist/esm/src/hooks/useCreateThemedStyles/useCreateThemedStyles.mjs +11 -0
  42. package/dist/esm/src/hooks/useDeviceCapabilities/useDeviceCapabilities.mjs +17 -0
  43. package/dist/esm/src/providers/SliceThemeProvider.mjs +33 -0
  44. package/dist/esm/src/theme/colors/colors.mjs +249 -0
  45. package/dist/esm/src/theme/corners/corners.mjs +12 -0
  46. package/dist/esm/src/theme/elevations/elevations.mjs +15 -0
  47. package/dist/esm/src/theme/motion/motion.mjs +13 -0
  48. package/dist/esm/src/theme/motion.mjs +45 -0
  49. package/dist/esm/src/theme/spacing/spacing.mjs +12 -0
  50. package/dist/esm/src/theme/type/type.mjs +184 -0
  51. package/dist/esm/src/utils/sizes/sizes.mjs +37 -0
  52. package/dist/esm/src/utils/typography/typography.mjs +15 -0
  53. package/dist/esm/theme.mjs +7 -522
  54. package/dist/esm/utils.mjs +2 -0
  55. package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +6 -0
  56. package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.js +6 -0
  57. package/dist/react-native/native/src/components/SliceBackgroundBlur/_types.js +1 -0
  58. package/dist/react-native/native/src/components/SliceBackgroundBlur/index.js +1 -0
  59. package/dist/react-native/native/src/components/SliceButton/SliceButton.js +141 -0
  60. package/dist/react-native/native/src/components/SliceButton/_types.js +1 -0
  61. package/dist/react-native/native/src/components/SliceButton/index.js +1 -0
  62. package/dist/react-native/native/src/components/SliceIcon/SliceIcon.js +15 -0
  63. package/dist/react-native/native/src/components/SliceIcon/_types.js +1 -0
  64. package/dist/react-native/native/src/components/SliceIcon/iconRegistry.js +663 -0
  65. package/dist/react-native/native/src/components/SliceIcon/icons.js +140 -0
  66. package/dist/react-native/native/src/components/SliceIcon/index.js +2 -0
  67. package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.js +6 -0
  68. package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +7 -0
  69. package/dist/react-native/native/src/components/SliceLiquidGlassView/_types.js +1 -0
  70. package/dist/react-native/native/src/components/SliceLiquidGlassView/index.js +1 -0
  71. package/dist/react-native/native/src/components/SliceText/SliceText.js +16 -0
  72. package/dist/react-native/native/src/components/SliceText/_types.js +1 -0
  73. package/dist/react-native/native/src/components/SliceText/index.js +1 -0
  74. package/dist/react-native/native/src/components/SliceTextInput/SliceTextInput.js +111 -0
  75. package/dist/react-native/native/src/components/SliceTextInput/_types.js +1 -0
  76. package/dist/react-native/native/src/components/SliceTextInput/index.js +1 -0
  77. package/dist/react-native/native/src/components/index.js +6 -0
  78. package/dist/react-native/native/src/hooks/index.js +2 -0
  79. package/dist/react-native/native/src/hooks/useCreateThemedStyles/index.js +1 -0
  80. package/dist/react-native/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +8 -0
  81. package/dist/react-native/native/src/hooks/useDeviceCapabilities/_types.js +1 -0
  82. package/dist/react-native/native/src/hooks/useDeviceCapabilities/index.js +1 -0
  83. package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +14 -0
  84. package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.js +23 -0
  85. package/dist/react-native/native/src/index.js +6 -0
  86. package/dist/react-native/native/src/providers/SliceThemeProvider.js +30 -0
  87. package/dist/react-native/native/src/providers/index.js +1 -0
  88. package/dist/react-native/native/src/specs/BackgroundBlurNativeComponent.ts +16 -0
  89. package/dist/react-native/native/src/specs/LiquidGlassNativeComponent.ts +18 -0
  90. package/dist/react-native/native/src/specs/NativeDeviceCapabilities.ts +13 -0
  91. package/dist/react-native/native/src/theme/index.js +69 -0
  92. package/dist/react-native/native/src/theme/motion.js +43 -0
  93. package/dist/react-native/native/src/types/index.js +1 -0
  94. package/dist/react-native/native/src/types/sharedTypes.js +1 -0
  95. package/dist/react-native/native/src/utils/index.js +2 -0
  96. package/dist/react-native/native/src/utils/sizes/index.js +1 -0
  97. package/dist/react-native/native/src/utils/sizes/sizes.js +35 -0
  98. package/dist/react-native/native/src/utils/typography/index.js +1 -0
  99. package/dist/react-native/native/src/utils/typography/typography.js +13 -0
  100. package/dist/react-native/src/theme/colors/colors.js +385 -0
  101. package/dist/react-native/src/theme/colors/types.js +1 -0
  102. package/dist/react-native/src/theme/corners/corners.js +10 -0
  103. package/dist/react-native/src/theme/corners/types.js +1 -0
  104. package/dist/react-native/src/theme/elevations/_types.js +1 -0
  105. package/dist/react-native/src/theme/elevations/elevations.js +13 -0
  106. package/dist/react-native/src/theme/motion/_types.js +1 -0
  107. package/dist/react-native/src/theme/motion/motion.js +11 -0
  108. package/dist/react-native/src/theme/spacing/_types.js +1 -0
  109. package/dist/react-native/src/theme/spacing/spacing.js +10 -0
  110. package/dist/react-native/src/theme/type/type.js +371 -0
  111. package/dist/react-native/src/theme/type/types.js +1 -0
  112. package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.d.ts +3 -0
  113. package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.d.ts +2 -0
  114. package/dist/types/native/src/components/SliceBackgroundBlur/_types.d.ts +24 -0
  115. package/dist/types/native/src/components/SliceBackgroundBlur/index.d.ts +2 -0
  116. package/dist/types/native/src/components/SliceButton/SliceButton.d.ts +5 -0
  117. package/dist/types/native/src/components/SliceButton/_types.d.ts +78 -0
  118. package/dist/types/native/src/components/SliceButton/index.d.ts +2 -0
  119. package/dist/types/native/src/components/SliceIcon/SliceIcon.d.ts +2 -0
  120. package/dist/types/native/{components/Icon → src/components/SliceIcon}/icons.d.ts +1 -0
  121. package/dist/types/native/src/components/SliceIcon/index.d.ts +3 -0
  122. package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.d.ts +3 -0
  123. package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.d.ts +2 -0
  124. package/dist/types/native/src/components/SliceLiquidGlassView/_types.d.ts +17 -0
  125. package/dist/types/native/src/components/SliceLiquidGlassView/index.d.ts +2 -0
  126. package/dist/types/native/src/components/SliceText/SliceText.d.ts +5 -0
  127. package/dist/types/native/src/components/SliceText/_types.d.ts +17 -0
  128. package/dist/types/native/src/components/SliceText/index.d.ts +2 -0
  129. package/dist/types/native/src/components/SliceTextInput/SliceTextInput.d.ts +2 -0
  130. package/dist/types/native/src/components/SliceTextInput/_types.d.ts +58 -0
  131. package/dist/types/native/src/components/SliceTextInput/index.d.ts +2 -0
  132. package/dist/types/native/src/components/index.d.ts +12 -0
  133. package/dist/types/native/src/hooks/index.d.ts +3 -0
  134. package/dist/types/native/src/hooks/useCreateThemedStyles/index.d.ts +1 -0
  135. package/dist/types/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.d.ts +7 -0
  136. package/dist/types/native/src/hooks/useDeviceCapabilities/_types.d.ts +17 -0
  137. package/dist/types/native/src/hooks/useDeviceCapabilities/index.d.ts +2 -0
  138. package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.d.ts +3 -0
  139. package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.d.ts +7 -0
  140. package/dist/types/native/src/index.d.ts +12 -0
  141. package/dist/types/native/src/providers/SliceThemeProvider.d.ts +16 -0
  142. package/dist/types/native/src/providers/index.d.ts +2 -0
  143. package/dist/types/native/src/specs/BackgroundBlurNativeComponent.d.ts +9 -0
  144. package/dist/types/native/src/specs/LiquidGlassNativeComponent.d.ts +9 -0
  145. package/dist/types/native/src/specs/NativeDeviceCapabilities.d.ts +11 -0
  146. package/dist/types/native/{theme → src/theme}/index.d.ts +5 -5
  147. package/dist/types/native/src/types/index.d.ts +1 -0
  148. package/dist/types/native/src/types/sharedTypes.d.ts +14 -0
  149. package/dist/types/native/src/utils/index.d.ts +2 -0
  150. package/dist/types/native/src/utils/sizes/index.d.ts +1 -0
  151. package/dist/types/native/src/utils/sizes/sizes.d.ts +7 -0
  152. package/dist/types/native/src/utils/typography/index.d.ts +1 -0
  153. package/dist/types/native/src/utils/typography/typography.d.ts +7 -0
  154. package/package.json +57 -11
  155. package/platform/android/build.gradle +22 -0
  156. package/platform/android/src/main/AndroidManifest.xml +1 -0
  157. package/platform/android/src/main/java/com/slice/SliceBackgroundBlurManager.java +28 -0
  158. package/platform/android/src/main/java/com/slice/SliceBackgroundBlurView.java +98 -0
  159. package/platform/android/src/main/java/com/slice/SliceDeviceCapabilitiesModule.java +25 -0
  160. package/platform/android/src/main/java/com/slice/SlicePackage.java +25 -0
  161. package/platform/ios/BackgroundBlurSurface.swift +89 -0
  162. package/platform/ios/LiquidGlassSurface.swift +82 -0
  163. package/platform/ios/RCTBackgroundBlurView.h +3 -0
  164. package/platform/ios/RCTBackgroundBlurView.mm +42 -0
  165. package/platform/ios/RCTLiquidGlassView.h +8 -0
  166. package/platform/ios/RCTLiquidGlassView.mm +73 -0
  167. package/platform/ios/SliceDeviceCapabilities.h +4 -0
  168. package/platform/ios/SliceDeviceCapabilities.mm +35 -0
  169. package/react-native.config.js +1 -0
  170. package/src/specs/BackgroundBlurNativeComponent.ts +16 -0
  171. package/src/specs/LiquidGlassNativeComponent.ts +18 -0
  172. package/src/specs/NativeDeviceCapabilities.ts +13 -0
  173. package/dist/types/native/components/Icon/NativeIcon.d.ts +0 -2
  174. package/dist/types/native/components/Icon/index.d.ts +0 -3
  175. package/dist/types/native/index.d.ts +0 -4
  176. /package/dist/types/native/{components/Icon → src/components/SliceIcon}/_types.d.ts +0 -0
  177. /package/dist/types/native/{components/Icon → src/components/SliceIcon}/iconRegistry.d.ts +0 -0
  178. /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,12 @@
1
+ const spacing = {
2
+ xxs: 2,
3
+ xs: 4,
4
+ s: 8,
5
+ m: 16,
6
+ l: 24,
7
+ xl: 32,
8
+ xxl: 64,
9
+ h: 128,
10
+ };
11
+
12
+ export { spacing };
@@ -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 };