@apple-pie/slice-native 0.1.3 → 0.1.6

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 (74) hide show
  1. package/README.md +196 -6
  2. package/dist/cjs/components.js +15 -0
  3. package/dist/cjs/hooks.js +7 -0
  4. package/dist/cjs/index.js +18 -805
  5. package/dist/cjs/providers.js +9 -0
  6. package/dist/cjs/src/components/SliceButton/SliceButton.js +119 -0
  7. package/dist/cjs/src/components/SliceIcon/SliceIcon.js +20 -0
  8. package/dist/cjs/src/components/SliceIcon/iconRegistry.js +668 -0
  9. package/dist/cjs/src/components/SliceIcon/icons.js +144 -0
  10. package/dist/cjs/src/components/SliceText/SliceText.js +21 -0
  11. package/dist/cjs/src/components/SliceTextInput/SliceTextInput.js +87 -0
  12. package/dist/cjs/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +13 -0
  13. package/dist/cjs/src/providers/SliceThemeProvider.js +37 -0
  14. package/dist/cjs/src/theme/colors/colors.js +253 -0
  15. package/dist/cjs/src/theme/corners/corners.js +14 -0
  16. package/dist/cjs/src/theme/elevations/elevations.js +17 -0
  17. package/dist/cjs/src/theme/motion/motion.js +15 -0
  18. package/dist/cjs/src/theme/motion.js +47 -0
  19. package/dist/cjs/src/theme/spacing/spacing.js +14 -0
  20. package/dist/cjs/src/theme/type/type.js +190 -0
  21. package/dist/cjs/src/utils/typography/typography.js +17 -0
  22. package/dist/cjs/theme.js +23 -538
  23. package/dist/cjs/utils.js +7 -0
  24. package/dist/esm/components.mjs +5 -0
  25. package/dist/esm/hooks.mjs +1 -0
  26. package/dist/esm/index.mjs +8 -806
  27. package/dist/esm/providers.mjs +1 -0
  28. package/dist/esm/src/components/SliceButton/SliceButton.mjs +117 -0
  29. package/dist/esm/src/components/SliceIcon/SliceIcon.mjs +18 -0
  30. package/dist/esm/src/components/SliceIcon/iconRegistry.mjs +666 -0
  31. package/dist/esm/src/components/SliceIcon/icons.mjs +142 -0
  32. package/dist/esm/src/components/SliceText/SliceText.mjs +19 -0
  33. package/dist/esm/src/components/SliceTextInput/SliceTextInput.mjs +85 -0
  34. package/dist/esm/src/hooks/useCreateThemedStyles/useCreateThemedStyles.mjs +11 -0
  35. package/dist/esm/src/providers/SliceThemeProvider.mjs +33 -0
  36. package/dist/esm/src/theme/colors/colors.mjs +249 -0
  37. package/dist/esm/src/theme/corners/corners.mjs +12 -0
  38. package/dist/esm/src/theme/elevations/elevations.mjs +15 -0
  39. package/dist/esm/src/theme/motion/motion.mjs +13 -0
  40. package/dist/esm/src/theme/motion.mjs +45 -0
  41. package/dist/esm/src/theme/spacing/spacing.mjs +12 -0
  42. package/dist/esm/src/theme/type/type.mjs +184 -0
  43. package/dist/esm/src/utils/typography/typography.mjs +15 -0
  44. package/dist/esm/theme.mjs +7 -522
  45. package/dist/esm/utils.mjs +1 -0
  46. package/dist/types/native/index.d.ts +8 -4
  47. package/dist/types/native/src/components/SliceButton/SliceButton.d.ts +5 -0
  48. package/dist/types/native/src/components/SliceButton/_types.d.ts +47 -0
  49. package/dist/types/native/src/components/SliceButton/index.d.ts +2 -0
  50. package/dist/types/native/src/components/SliceIcon/SliceIcon.d.ts +2 -0
  51. package/dist/types/native/{components/Icon → src/components/SliceIcon}/icons.d.ts +2 -0
  52. package/dist/types/native/src/components/SliceIcon/index.d.ts +3 -0
  53. package/dist/types/native/src/components/SliceText/SliceText.d.ts +5 -0
  54. package/dist/types/native/src/components/SliceText/_types.d.ts +17 -0
  55. package/dist/types/native/src/components/SliceText/index.d.ts +2 -0
  56. package/dist/types/native/src/components/SliceTextInput/SliceTextInput.d.ts +2 -0
  57. package/dist/types/native/src/components/SliceTextInput/_types.d.ts +36 -0
  58. package/dist/types/native/src/components/SliceTextInput/index.d.ts +2 -0
  59. package/dist/types/native/src/components/index.d.ts +8 -0
  60. package/dist/types/native/src/hooks/index.d.ts +1 -0
  61. package/dist/types/native/src/hooks/useCreateThemedStyles/index.d.ts +1 -0
  62. package/dist/types/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.d.ts +7 -0
  63. package/dist/types/native/src/providers/SliceThemeProvider.d.ts +16 -0
  64. package/dist/types/native/src/providers/index.d.ts +2 -0
  65. package/dist/types/native/{theme → src/theme}/index.d.ts +5 -5
  66. package/dist/types/native/src/utils/index.d.ts +1 -0
  67. package/dist/types/native/src/utils/typography/index.d.ts +1 -0
  68. package/dist/types/native/src/utils/typography/typography.d.ts +7 -0
  69. package/package.json +32 -3
  70. package/dist/types/native/components/Icon/NativeIcon.d.ts +0 -2
  71. package/dist/types/native/components/Icon/index.d.ts +0 -3
  72. /package/dist/types/native/{components/Icon → src/components/SliceIcon}/_types.d.ts +0 -0
  73. /package/dist/types/native/{components/Icon → src/components/SliceIcon}/iconRegistry.d.ts +0 -0
  74. /package/dist/types/native/{theme → src/theme}/motion.d.ts +0 -0
@@ -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,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;