@apple-pie/slice-native 0.1.4 → 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.
- package/README.md +196 -6
- package/dist/cjs/components.js +15 -0
- package/dist/cjs/hooks.js +7 -0
- package/dist/cjs/index.js +18 -812
- package/dist/cjs/providers.js +9 -0
- package/dist/cjs/src/components/SliceButton/SliceButton.js +119 -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/SliceText/SliceText.js +21 -0
- package/dist/cjs/src/components/SliceTextInput/SliceTextInput.js +87 -0
- package/dist/cjs/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +13 -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/typography/typography.js +17 -0
- package/dist/cjs/theme.js +23 -538
- package/dist/cjs/utils.js +7 -0
- package/dist/esm/components.mjs +5 -0
- package/dist/esm/hooks.mjs +1 -0
- package/dist/esm/index.mjs +8 -813
- package/dist/esm/providers.mjs +1 -0
- package/dist/esm/src/components/SliceButton/SliceButton.mjs +117 -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/SliceText/SliceText.mjs +19 -0
- package/dist/esm/src/components/SliceTextInput/SliceTextInput.mjs +85 -0
- package/dist/esm/src/hooks/useCreateThemedStyles/useCreateThemedStyles.mjs +11 -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/typography/typography.mjs +15 -0
- package/dist/esm/theme.mjs +7 -522
- package/dist/esm/utils.mjs +1 -0
- package/dist/types/native/index.d.ts +8 -4
- package/dist/types/native/src/components/SliceButton/SliceButton.d.ts +5 -0
- package/dist/types/native/src/components/SliceButton/_types.d.ts +47 -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/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 +36 -0
- package/dist/types/native/src/components/SliceTextInput/index.d.ts +2 -0
- package/dist/types/native/src/components/index.d.ts +8 -0
- package/dist/types/native/src/hooks/index.d.ts +1 -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/providers/SliceThemeProvider.d.ts +16 -0
- package/dist/types/native/src/providers/index.d.ts +2 -0
- package/dist/types/native/{theme → src/theme}/index.d.ts +5 -5
- package/dist/types/native/src/utils/index.d.ts +1 -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 +32 -3
- 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/{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,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,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 };
|