@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,15 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Motion for Slice UI
5
+ */
6
+ const motion = {
7
+ 'motion-magnet': 'cubic-bezier(0.352, 0.003, 0.993, -0.052)',
8
+ 'motion-water': 'cubic-bezier(0.36, 0, 0.64, 1)',
9
+ 'motion-spring': 'linear(0, 0.001 0.3%, 0.008 0.7%, 0.034 1.5%, 0.076 2.3%, 0.138 3.2%, 0.275 4.8%, 0.713 9.4%, 0.836 10.9%, 0.933 12.3%, 1.011 13.7%, 1.074 15.2%, 1.096 15.9%, 1.116 16.7%, 1.132 17.5%, 1.142 18.3%, 1.148 19.1%, 1.15 20%, 1.148 21%, 1.142 22%, 1.133 22.9%, 1.12 24%, 1.048 29.1%, 1.015 31.8%, 1.002 33.3%, 0.991 34.9%, 0.983 36.5%, 0.979 38.1%, 0.977 39.9%, 0.979 42%, 0.997 51.7%, 1.003 57.7%, 1 77%, 1)',
10
+ 'motion-magnet-duration': '0.5s',
11
+ 'motion-water-duration': '0.25s',
12
+ 'motion-spring-duration': '1s',
13
+ };
14
+
15
+ exports.motion = motion;
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ /** Convert Slice's explicit CSS curves without importing the React Native runtime. */
4
+ function easing(css) {
5
+ if (css.startsWith('cubic-bezier(')) {
6
+ const [x1, y1, x2, y2] = css.slice(13, -1).split(',').map(Number);
7
+ const sample = (t, a, b) => 3 * (1 - t) ** 2 * t * a + 3 * (1 - t) * t ** 2 * b + t ** 3;
8
+ return (progress) => {
9
+ if (progress <= 0)
10
+ return 0;
11
+ if (progress >= 1)
12
+ return 1;
13
+ let low = 0;
14
+ let high = 1;
15
+ for (let i = 0; i < 30; i++) {
16
+ const middle = (low + high) / 2;
17
+ if (sample(middle, x1, x2) < progress)
18
+ low = middle;
19
+ else
20
+ high = middle;
21
+ }
22
+ return sample((low + high) / 2, y1, y2);
23
+ };
24
+ }
25
+ if (!css.startsWith('linear('))
26
+ throw new Error(`Unsupported Slice easing: ${css}`);
27
+ const points = css
28
+ .slice(7, -1)
29
+ .split(',')
30
+ .map((entry, index, entries) => {
31
+ const [value, percent] = entry.trim().split(/\s+/).map(Number.parseFloat);
32
+ return { value, position: percent === undefined ? index / (entries.length - 1) : percent / 100 };
33
+ });
34
+ return (progress) => {
35
+ if (progress <= 0)
36
+ return points[0].value;
37
+ for (let i = 1; i < points.length; i++) {
38
+ const left = points[i - 1];
39
+ const right = points[i];
40
+ if (progress <= right.position)
41
+ return (left.value + ((right.value - left.value) * (progress - left.position)) / (right.position - left.position));
42
+ }
43
+ return points[points.length - 1].value;
44
+ };
45
+ }
46
+
47
+ exports.easing = easing;
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const spacing = {
4
+ xxs: 2,
5
+ xs: 4,
6
+ s: 8,
7
+ m: 16,
8
+ l: 24,
9
+ xl: 32,
10
+ xxl: 64,
11
+ h: 128,
12
+ };
13
+
14
+ exports.spacing = spacing;
@@ -0,0 +1,190 @@
1
+ 'use strict';
2
+
3
+ // base family
4
+ const fontFamily = `var(--slice-font-family, "Funnel Sans")`;
5
+ // base weights
6
+ const fontWeights = {
7
+ regular: 360,
8
+ medium: 420,
9
+ bold: 500,
10
+ extra: 560,
11
+ };
12
+ // base sizes
13
+ const fontSizes = {
14
+ xs: '0.75rem',
15
+ s: '0.875rem',
16
+ m: '0.9375rem',
17
+ l: '1rem',
18
+ xl: '1.0625rem',
19
+ h1: '4.25rem',
20
+ h2: '3.5rem',
21
+ h3: '2.75rem',
22
+ h4: '2rem',
23
+ h5: '1.5rem',
24
+ h6: '1.0625rem',
25
+ };
26
+ // base line heights
27
+ const lineHeights = {
28
+ xs: '116.67%',
29
+ m: '133.33%',
30
+ l: '140%',
31
+ xl: '142.86%',
32
+ xxl: '162.5%',
33
+ };
34
+ // base letter spacing
35
+ const letterSpacings = {
36
+ xs: '0.00625em',
37
+ s: '0.009375em',
38
+ m: '0.0125em',
39
+ l: '0.015625em',
40
+ };
41
+ // ** new styles aligned to lyra */
42
+ const type = {
43
+ 'body-xs-regular': `
44
+ font-family: ${fontFamily};
45
+ font-weight: ${fontWeights.regular};
46
+ font-size: ${fontSizes.xs};
47
+ line-height: ${lineHeights.m};
48
+ text-decoration: none;
49
+ letter-spacing: ${letterSpacings.m}`,
50
+ 'body-xs-medium': `
51
+ font-family: ${fontFamily};
52
+ font-weight: ${fontWeights.medium};
53
+ font-size: ${fontSizes.xs};
54
+ line-height: ${lineHeights.m};
55
+ text-decoration: none;
56
+ letter-spacing: ${letterSpacings.m}`,
57
+ 'body-xs-bold': `
58
+ font-family: ${fontFamily};
59
+ font-weight: ${fontWeights.bold};
60
+ font-size: ${fontSizes.xs};
61
+ line-height: ${lineHeights.m};
62
+ text-decoration: none;
63
+ letter-spacing: ${letterSpacings.l}`,
64
+ 'body-s-regular': `
65
+ font-family: ${fontFamily};
66
+ font-weight: ${fontWeights.regular};
67
+ font-size: ${fontSizes.s};
68
+ line-height: ${lineHeights.xl};
69
+ text-decoration: none;
70
+ letter-spacing: ${letterSpacings.s}`,
71
+ 'body-s-medium': `
72
+ font-family: ${fontFamily};
73
+ font-weight: ${fontWeights.medium};
74
+ font-size: ${fontSizes.s};
75
+ line-height: ${lineHeights.xl};
76
+ text-decoration: none;
77
+ letter-spacing: ${letterSpacings.s}`,
78
+ 'body-s-bold': `
79
+ font-family: ${fontFamily};
80
+ font-weight: ${fontWeights.bold};
81
+ font-size: ${fontSizes.s};
82
+ line-height: ${lineHeights.xl};
83
+ text-decoration: none;
84
+ letter-spacing: ${letterSpacings.m}`,
85
+ 'body-m-regular': `
86
+ font-family: ${fontFamily};
87
+ font-weight: ${fontWeights.regular};
88
+ font-size: ${fontSizes.m};
89
+ line-height: ${lineHeights.l};
90
+ text-decoration: none;
91
+ letter-spacing: ${letterSpacings.s}`,
92
+ 'body-m-medium': `
93
+ font-family: ${fontFamily};
94
+ font-weight: ${fontWeights.medium};
95
+ font-size: ${fontSizes.m};
96
+ line-height: ${lineHeights.l};
97
+ text-decoration: none;
98
+ letter-spacing: ${letterSpacings.s}`,
99
+ 'body-m-bold': `
100
+ font-family: ${fontFamily};
101
+ font-weight: ${fontWeights.bold};
102
+ font-size: ${fontSizes.m};
103
+ line-height: ${lineHeights.l};
104
+ text-decoration: none;
105
+ letter-spacing: ${letterSpacings.m}`,
106
+ 'body-l-regular': `
107
+ font-family: ${fontFamily};
108
+ font-weight: ${fontWeights.regular};
109
+ font-size: ${fontSizes.l};
110
+ line-height: ${lineHeights.xxl};
111
+ text-decoration: none;
112
+ letter-spacing: ${letterSpacings.xs}`,
113
+ 'body-l-medium': `
114
+ font-family: ${fontFamily};
115
+ font-weight: ${fontWeights.medium};
116
+ font-size: ${fontSizes.l};
117
+ line-height: ${lineHeights.xxl};
118
+ text-decoration: none;
119
+ letter-spacing: ${letterSpacings.xs}`,
120
+ 'body-l-bold': `
121
+ font-family: ${fontFamily};
122
+ font-weight: ${fontWeights.bold};
123
+ font-size: ${fontSizes.l};
124
+ line-height: ${lineHeights.xxl};
125
+ text-decoration: none;
126
+ letter-spacing: ${letterSpacings.s}`,
127
+ 'body-xl-regular': `
128
+ font-family: ${fontFamily};
129
+ font-weight: ${fontWeights.regular};
130
+ font-size: ${fontSizes.xl};
131
+ line-height: ${lineHeights.xxl};
132
+ text-decoration: none;
133
+ letter-spacing: ${letterSpacings.xs}`,
134
+ 'body-xl-medium': `
135
+ font-family: ${fontFamily};
136
+ font-weight: ${fontWeights.medium};
137
+ font-size: ${fontSizes.xl};
138
+ line-height: ${lineHeights.xxl};
139
+ text-decoration: none;
140
+ letter-spacing: ${letterSpacings.xs}`,
141
+ 'body-xl-bold': `
142
+ font-family: ${fontFamily};
143
+ font-weight: ${fontWeights.bold};
144
+ font-size: ${fontSizes.xl};
145
+ line-height: ${lineHeights.xxl};
146
+ text-decoration: none;
147
+ letter-spacing: ${letterSpacings.s}`,
148
+ h1: `
149
+ font-family: ${fontFamily};
150
+ font-weight: ${fontWeights.extra};
151
+ font-size: ${fontSizes.h1};
152
+ line-height: ${lineHeights.xs};
153
+ letter-spacing: ${letterSpacings.m}`,
154
+ h2: `
155
+ font-family: ${fontFamily};
156
+ font-weight: ${fontWeights.extra};
157
+ font-size: ${fontSizes.h2};
158
+ line-height: ${lineHeights.xs};
159
+ letter-spacing: ${letterSpacings.m}`,
160
+ h3: `
161
+ font-family: ${fontFamily};
162
+ font-weight: ${fontWeights.extra};
163
+ font-size: ${fontSizes.h3};
164
+ line-height: ${lineHeights.xs};
165
+ letter-spacing: ${letterSpacings.m}`,
166
+ h4: `
167
+ font-family: ${fontFamily};
168
+ font-weight: ${fontWeights.extra};
169
+ font-size: ${fontSizes.h4};
170
+ line-height: ${lineHeights.xs};
171
+ letter-spacing: ${letterSpacings.m}`,
172
+ h5: `
173
+ font-family: ${fontFamily};
174
+ font-weight: ${fontWeights.extra};
175
+ font-size: ${fontSizes.h5};
176
+ line-height: ${lineHeights.xs};
177
+ letter-spacing: ${letterSpacings.m}`,
178
+ h6: `
179
+ font-family: ${fontFamily};
180
+ font-weight: ${fontWeights.extra};
181
+ font-size: ${fontSizes.h6};
182
+ line-height: ${lineHeights.xs};
183
+ letter-spacing: ${letterSpacings.m}`,
184
+ };
185
+
186
+ exports.fontSizes = fontSizes;
187
+ exports.fontWeights = fontWeights;
188
+ exports.letterSpacings = letterSpacings;
189
+ exports.lineHeights = lineHeights;
190
+ exports.type = type;
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Internal utility converting size props to an absolute number
5
+ */
6
+ function sizeToNumber(size) {
7
+ if (!size)
8
+ return 48;
9
+ if (typeof size === 'number')
10
+ return size;
11
+ switch (size) {
12
+ case 's': {
13
+ return 40;
14
+ }
15
+ case 'm': {
16
+ return 48;
17
+ }
18
+ case 'l': {
19
+ return 56;
20
+ }
21
+ default:
22
+ return 48;
23
+ }
24
+ }
25
+ /** Resolve radius presets; invalid or negative values produce square corners. */
26
+ function borderRadiusToNumber(borderRadius) {
27
+ if (typeof borderRadius === 'number')
28
+ return Number.isFinite(borderRadius) ? Math.max(0, borderRadius) : 0;
29
+ switch (borderRadius) {
30
+ case 'pill':
31
+ return 1000;
32
+ case 'rectangular':
33
+ return 4;
34
+ default:
35
+ return 0;
36
+ }
37
+ }
38
+
39
+ exports.borderRadiusToNumber = borderRadiusToNumber;
40
+ exports.sizeToNumber = sizeToNumber;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Simple utility to take text style and returns a defined line height factor
5
+ * Since there is no relative/percent in native, looks for the fontsize and
6
+ * derives an absolute line height from the font size
7
+ */
8
+ function lineHeightTextStyle(styles, lineHeightFactor = 1.2) {
9
+ if (!Number.isFinite(lineHeightFactor) || lineHeightFactor < 0 || lineHeightFactor > 2) {
10
+ throw new Error('lineHeightFactor must be a number between 0 and 2');
11
+ }
12
+ const fontSize = styles.fontSize ?? 16;
13
+ const lineHeight = lineHeightFactor * fontSize;
14
+ return { ...styles, lineHeight };
15
+ }
16
+
17
+ exports.lineHeightTextStyle = lineHeightTextStyle;