jp-composter 0.1.0

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 (194) hide show
  1. package/dist/index.d.mts +997 -0
  2. package/dist/index.d.ts +997 -0
  3. package/dist/index.js +36837 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +36778 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +66 -0
  8. package/src/SliceUI/IconMoon.tsx +33 -0
  9. package/src/SliceUI/assets/Anatomy diagram copy.svg +19 -0
  10. package/src/SliceUI/assets/Anatomy diagram.svg +19 -0
  11. package/src/SliceUI/assets/Anatomycheck.svg +15 -0
  12. package/src/SliceUI/assets/Anatomyinput.svg +32 -0
  13. package/src/SliceUI/assets/Checkbox.jpg +0 -0
  14. package/src/SliceUI/assets/Diagram copy.svg +15 -0
  15. package/src/SliceUI/assets/Diagram.jpg +0 -0
  16. package/src/SliceUI/assets/Diagram.svg +15 -0
  17. package/src/SliceUI/assets/Frame 5 copy.png +0 -0
  18. package/src/SliceUI/assets/Frame 5.png +0 -0
  19. package/src/SliceUI/assets/Frame 65.png +0 -0
  20. package/src/SliceUI/assets/Frame_65.png +0 -0
  21. package/src/SliceUI/assets/Icon copy.svg +3 -0
  22. package/src/SliceUI/assets/Icon.svg +3 -0
  23. package/src/SliceUI/assets/Icon_Bridging copy.svg +39 -0
  24. package/src/SliceUI/assets/Icon_Bridging.svg +39 -0
  25. package/src/SliceUI/assets/Icon_Consistent copy.svg +39 -0
  26. package/src/SliceUI/assets/Icon_Consistent.svg +39 -0
  27. package/src/SliceUI/assets/Icon_Plug copy.svg +38 -0
  28. package/src/SliceUI/assets/Icon_Plug.svg +38 -0
  29. package/src/SliceUI/assets/Icon_Reusable copy.svg +39 -0
  30. package/src/SliceUI/assets/Icon_Reusable.svg +39 -0
  31. package/src/SliceUI/assets/Layer_1.png +0 -0
  32. package/src/SliceUI/assets/accessibility.png +0 -0
  33. package/src/SliceUI/assets/accessibility.svg +1 -0
  34. package/src/SliceUI/assets/addon-library.png +0 -0
  35. package/src/SliceUI/assets/assets.png +0 -0
  36. package/src/SliceUI/assets/avif-test-image.avif +0 -0
  37. package/src/SliceUI/assets/bridging.svg +13 -0
  38. package/src/SliceUI/assets/consistent.svg +11 -0
  39. package/src/SliceUI/assets/context.png +0 -0
  40. package/src/SliceUI/assets/discord.svg +1 -0
  41. package/src/SliceUI/assets/docs.png +0 -0
  42. package/src/SliceUI/assets/figma-plugin.png +0 -0
  43. package/src/SliceUI/assets/github.svg +1 -0
  44. package/src/SliceUI/assets/resources/Anatomy diagram.svg +19 -0
  45. package/src/SliceUI/assets/resources/Anatomycheck.svg +15 -0
  46. package/src/SliceUI/assets/resources/Anatomyinput.svg +32 -0
  47. package/src/SliceUI/assets/resources/Diagram.svg +15 -0
  48. package/src/SliceUI/assets/resources/Frame 5.png +0 -0
  49. package/src/SliceUI/assets/resources/Frame 65.png +0 -0
  50. package/src/SliceUI/assets/resources/Icon.svg +3 -0
  51. package/src/SliceUI/assets/resources/Icon_Bridging.svg +39 -0
  52. package/src/SliceUI/assets/resources/Icon_Consistent.svg +39 -0
  53. package/src/SliceUI/assets/resources/Icon_Plug.svg +38 -0
  54. package/src/SliceUI/assets/resources/Icon_Reusable.svg +39 -0
  55. package/src/SliceUI/assets/resources/fonts/FontIcon.json +150 -0
  56. package/src/SliceUI/assets/resources/fonts/Lato-Black.ttf +0 -0
  57. package/src/SliceUI/assets/resources/fonts/Lato-Bold.ttf +0 -0
  58. package/src/SliceUI/assets/resources/fonts/Lato-Heavy.ttf +0 -0
  59. package/src/SliceUI/assets/resources/fonts/Lato-Medium.ttf +0 -0
  60. package/src/SliceUI/assets/resources/fonts/Lato-Regular.ttf +0 -0
  61. package/src/SliceUI/assets/resources/fonts/Lato.woff2 +0 -0
  62. package/src/SliceUI/assets/resources/fonts/icomoon.eot +0 -0
  63. package/src/SliceUI/assets/resources/fonts/icomoon.svg +601 -0
  64. package/src/SliceUI/assets/resources/fonts/icomoon.ttf +0 -0
  65. package/src/SliceUI/assets/resources/fonts/icomoon.woff +0 -0
  66. package/src/SliceUI/assets/resources/fonts/selection.json +1 -0
  67. package/src/SliceUI/assets/share.png +0 -0
  68. package/src/SliceUI/assets/styling.png +0 -0
  69. package/src/SliceUI/assets/testing.png +0 -0
  70. package/src/SliceUI/assets/theming.png +0 -0
  71. package/src/SliceUI/assets/tutorials.svg +1 -0
  72. package/src/SliceUI/assets/youtube.svg +1 -0
  73. package/src/SliceUI/automation/helper.ts +29 -0
  74. package/src/SliceUI/avatar/Avatar.tsx +237 -0
  75. package/src/SliceUI/avatar/Token.ts +116 -0
  76. package/src/SliceUI/avatar/Type.ts +36 -0
  77. package/src/SliceUI/avatar/helper.ts +53 -0
  78. package/src/SliceUI/badge/Badge.tsx +308 -0
  79. package/src/SliceUI/badge/Token.ts +202 -0
  80. package/src/SliceUI/badge/Type.ts +46 -0
  81. package/src/SliceUI/badge/helper.ts +39 -0
  82. package/src/SliceUI/button/Button.tsx +243 -0
  83. package/src/SliceUI/button/Token.ts +138 -0
  84. package/src/SliceUI/button/Type.ts +34 -0
  85. package/src/SliceUI/button/helper.ts +125 -0
  86. package/src/SliceUI/checkbox/Checkbox.tsx +176 -0
  87. package/src/SliceUI/checkbox/Token.ts +128 -0
  88. package/src/SliceUI/checkbox/Type.ts +35 -0
  89. package/src/SliceUI/chip/Chip.tsx +290 -0
  90. package/src/SliceUI/chip/Token.ts +151 -0
  91. package/src/SliceUI/chip/Type.ts +43 -0
  92. package/src/SliceUI/chip/helper.ts +40 -0
  93. package/src/SliceUI/colors/Pallete.ts +151 -0
  94. package/src/SliceUI/colors/Token.ts +110 -0
  95. package/src/SliceUI/colors/Type.ts +56 -0
  96. package/src/SliceUI/contextProvider/context.tsx +108 -0
  97. package/src/SliceUI/divider/Divider.tsx +109 -0
  98. package/src/SliceUI/divider/Token.ts +18 -0
  99. package/src/SliceUI/divider/Type.ts +26 -0
  100. package/src/SliceUI/icon/CustomIcon.ts +4 -0
  101. package/src/SliceUI/icon/IcoMoonIcon.tsx +11 -0
  102. package/src/SliceUI/icon/Icon.tsx +38 -0
  103. package/src/SliceUI/icon/Token.ts +14 -0
  104. package/src/SliceUI/icon/Type.ts +13 -0
  105. package/src/SliceUI/icon/selection.json +1 -0
  106. package/src/SliceUI/input/Input.tsx +573 -0
  107. package/src/SliceUI/input/ToDo.md +99 -0
  108. package/src/SliceUI/input/Token.ts +372 -0
  109. package/src/SliceUI/input/Type.ts +109 -0
  110. package/src/SliceUI/input/components/InputPortal.tsx +211 -0
  111. package/src/SliceUI/input/components/NativeBottomSheet.tsx +296 -0
  112. package/src/SliceUI/input/components/SelectChip.tsx +185 -0
  113. package/src/SliceUI/input/components/SelectList.tsx +173 -0
  114. package/src/SliceUI/input/components/SelectListItem.tsx +377 -0
  115. package/src/SliceUI/input/components/SelectScrollbarStyle.ts +44 -0
  116. package/src/SliceUI/input/hooks/useCustomScrollbar.ts +17 -0
  117. package/src/SliceUI/input/hooks/useInputState.ts +41 -0
  118. package/src/SliceUI/input/hooks/useLabelAnimation.ts +132 -0
  119. package/src/SliceUI/input/hooks/useOutsideClick.ts +38 -0
  120. package/src/SliceUI/input/hooks/useSelectLogic.ts +338 -0
  121. package/src/SliceUI/input/utils/inputUtils.ts +120 -0
  122. package/src/SliceUI/input/utils/selectUtils.ts +85 -0
  123. package/src/SliceUI/input/utils/styleUtils.ts +50 -0
  124. package/src/SliceUI/input/variants/CurrencyInput/CurrencyInput.tsx +16 -0
  125. package/src/SliceUI/input/variants/CurrencyInput/NativeCurrencyInput.tsx +181 -0
  126. package/src/SliceUI/input/variants/CurrencyInput/WebCurrencyInput.tsx +163 -0
  127. package/src/SliceUI/input/variants/CurrencyInput/types.ts +17 -0
  128. package/src/SliceUI/input/variants/PhoneInput/NativePhoneInput.tsx +189 -0
  129. package/src/SliceUI/input/variants/PhoneInput/PhoneInput.tsx +16 -0
  130. package/src/SliceUI/input/variants/PhoneInput/WebPhoneInput.tsx +291 -0
  131. package/src/SliceUI/input/variants/PhoneInput/types.ts +22 -0
  132. package/src/SliceUI/input/variants/SelectInput/SelectInput.tsx +407 -0
  133. package/src/SliceUI/input/variants/SelectInput/types.ts +34 -0
  134. package/src/SliceUI/input/variants/TextInput.tsx +68 -0
  135. package/src/SliceUI/layout/Box.tsx +38 -0
  136. package/src/SliceUI/layout/Center.tsx +38 -0
  137. package/src/SliceUI/layout/Divider.tsx +37 -0
  138. package/src/SliceUI/layout/Grid.tsx +75 -0
  139. package/src/SliceUI/layout/PageContainer.tsx +60 -0
  140. package/src/SliceUI/layout/ScrollContainer.tsx +72 -0
  141. package/src/SliceUI/layout/Spacer.tsx +54 -0
  142. package/src/SliceUI/layout/Stack.tsx +97 -0
  143. package/src/SliceUI/layout/StickyHeader.tsx +71 -0
  144. package/src/SliceUI/radio/RadioButton.tsx +130 -0
  145. package/src/SliceUI/radio/Token.ts +197 -0
  146. package/src/SliceUI/radio/Type.ts +35 -0
  147. package/src/SliceUI/react-native.config.js +3 -0
  148. package/src/SliceUI/responsive/Type.ts +7 -0
  149. package/src/SliceUI/responsive/helper.ts +53 -0
  150. package/src/SliceUI/switch/Switch.tsx +119 -0
  151. package/src/SliceUI/switch/Token.ts +205 -0
  152. package/src/SliceUI/switch/Type.ts +26 -0
  153. package/src/SliceUI/tab/TabItem.tsx +204 -0
  154. package/src/SliceUI/tab/Tabs.tsx +110 -0
  155. package/src/SliceUI/tab/Token.ts +282 -0
  156. package/src/SliceUI/tab/Type.ts +66 -0
  157. package/src/SliceUI/tab/helper.ts +53 -0
  158. package/src/SliceUI/table/Table.tsx +388 -0
  159. package/src/SliceUI/table/TableCell.tsx +158 -0
  160. package/src/SliceUI/table/TableFooter.tsx +353 -0
  161. package/src/SliceUI/table/TableHeader.tsx +247 -0
  162. package/src/SliceUI/table/TableRow.tsx +218 -0
  163. package/src/SliceUI/table/Token.ts +252 -0
  164. package/src/SliceUI/table/Type.ts +213 -0
  165. package/src/SliceUI/table/helper.ts +376 -0
  166. package/src/SliceUI/table/index.ts +53 -0
  167. package/src/SliceUI/theme/dummyColors.tsx +7 -0
  168. package/src/SliceUI/theme/theme.ts +107 -0
  169. package/src/SliceUI/typography/BaseTypographyToken.ts +62 -0
  170. package/src/SliceUI/typography/FoundationToken.ts +48 -0
  171. package/src/SliceUI/typography/Token.ts +228 -0
  172. package/src/SliceUI/typography/Type.ts +20 -0
  173. package/src/SliceUI/typography/Typography.tsx +99 -0
  174. package/src/SliceUI/values/BorderRadius.ts +17 -0
  175. package/src/SliceUI/values/BorderWidth.ts +7 -0
  176. package/src/SliceUI/values/Dimension.ts +35 -0
  177. package/src/SliceUI/values/IconSizes.ts +13 -0
  178. package/src/SliceUI/values/Spacing.ts +22 -0
  179. package/src/declarations.d.ts +8 -0
  180. package/src/index.tsx +119 -0
  181. package/src/stories/Colors.mdx +1418 -0
  182. package/src/stories/Dimensions.mdx +60 -0
  183. package/src/stories/GetStarted.mdx +90 -0
  184. package/src/stories/Introduction.mdx +136 -0
  185. package/src/stories/Shape.mdx +126 -0
  186. package/src/stories/Spacing.mdx +104 -0
  187. package/src/stories/Typography.mdx +454 -0
  188. package/src/stories/Utils.mdx +277 -0
  189. package/src/stories/story-components/AddIcon.js +13 -0
  190. package/src/stories/story-components/RectangleWithBox.jsx +51 -0
  191. package/src/stories/story-components/RoundedRectangle.jsx +18 -0
  192. package/src/stories/story-components/RoundedWithWhiteInside.jsx +33 -0
  193. package/src/stories/story-components/WhiteRoundedRectangle.jsx +107 -0
  194. package/src/stories/story-components/svgPaths.js +126 -0
@@ -0,0 +1,454 @@
1
+ import {Meta} from '@storybook/addon-docs/blocks';
2
+ import Frame_65 from '../SliceUI/assets/Frame_65.png';
3
+
4
+ <Meta title="Tokens/Typography" />
5
+
6
+ # Typography tokens
7
+
8
+ <h3 style={{fontWeight: 'normal', fontFamily: 'Lato'}}>
9
+ Slice’s shape tokens define corner radius and border width to bring
10
+ consistency to how elements look and feel. By standardizing these values, we
11
+ create a more unified visual style across buttons, cards, inputs, and other UI
12
+ components.
13
+ </h3>{' '}
14
+
15
+ ---
16
+
17
+ # Foundation typography
18
+
19
+ <h3 style={{fontWeight: 'normal', fontFamily: 'Lato'}}>
20
+ Lato is our primary typeface, chosen for its clean lines and legibility across
21
+ digital interfaces.
22
+ </h3>
23
+ <img
24
+ src={Frame_65}
25
+ alt="A wall of logos representing different styling technologies"
26
+ />
27
+
28
+ <table
29
+ style={{
30
+ borderCollapse: 'separate',
31
+ borderSpacing: 0,
32
+ width: '100%',
33
+ borderRadius: '24px',
34
+ overflow: 'hidden',
35
+ border: '1px solid #ccc',
36
+ }}>
37
+ <thead>
38
+ <tr>
39
+ <th
40
+ style={{
41
+ borderBottom: '1px solid #ccc',
42
+ textAlign: 'left',
43
+ background: '#f9f9f9',
44
+ borderTopLeftRadius: '24px',
45
+ borderRight: '1px solid #ccc',
46
+ padding: '12px 16px',
47
+ fontWeight: '600',
48
+ fontSize: '14px',
49
+ width: '50%',
50
+ }}>
51
+ Font Weight
52
+ </th>
53
+ <th
54
+ style={{
55
+ borderBottom: '1px solid #ccc',
56
+ padding: '8px',
57
+ textAlign: 'left',
58
+ background: '#f9f9f9',
59
+ borderTopRightRadius: '24px',
60
+ width: '50%',
61
+ }}>
62
+ Token Name
63
+ </th>
64
+ </tr>
65
+ </thead>
66
+ <tbody>
67
+ {[
68
+ {weight: 'Regular', token: 'font-weight-regular'},
69
+ {weight: 'Medium', token: 'font-weight-medium'},
70
+ {weight: 'Bold', token: 'font-weight-bold'},
71
+ {weight: 'Heavy', token: 'font-weight-heavy'},
72
+ {weight: 'Black', token: 'font-weight-black'},
73
+ ].map(({weight, token}, i, arr) => (
74
+ <tr key={token} style={{backgroundColor: '#fff'}}>
75
+ <td
76
+ style={{
77
+ borderRight: '1px solid #fff',
78
+ borderBottom: i === arr.length - 1 ? 'none' : '1px solid #fff',
79
+ padding: '8px',
80
+ borderBottomLeftRadius: i === arr.length - 1 ? '24px' : 0,
81
+ padding: '12px 16px',
82
+ borderTop: '1px solid #eee',
83
+ }}>
84
+ {weight}
85
+ </td>
86
+ <td
87
+ style={{
88
+ borderBottom: i === arr.length - 1 ? 'none' : '1px solid #fff',
89
+ padding: '8px',
90
+ borderBottomRightRadius: i === arr.length - 1 ? '24px' : 0,
91
+ }}>
92
+ {token}
93
+ </td>
94
+ </tr>
95
+ ))}
96
+ </tbody>
97
+ </table>
98
+
99
+ <table
100
+ style={{
101
+ borderCollapse: 'separate',
102
+ borderSpacing: 0,
103
+ width: '100%',
104
+ borderRadius: '24px',
105
+ overflow: 'hidden',
106
+ border: '1px solid #ccc',
107
+ }}>
108
+ <thead>
109
+ <tr>
110
+ <th
111
+ style={{
112
+ borderBottom: '1px solid #ccc',
113
+ textAlign: 'left',
114
+ background: '#f9f9f9',
115
+ borderTopLeftRadius: '24px',
116
+ borderRight: '1px solid #ccc',
117
+ padding: '12px 16px',
118
+ fontWeight: '600',
119
+ fontSize: '14px',
120
+ width: '50%',
121
+ }}>
122
+ Font Size
123
+ </th>
124
+ <th
125
+ style={{
126
+ borderBottom: '1px solid #ccc',
127
+ padding: '12px 16px',
128
+ textAlign: 'left',
129
+ background: '#f9f9f9',
130
+ borderTopRightRadius: '24px',
131
+ fontWeight: '600',
132
+ fontSize: '14px',
133
+ width: '50%',
134
+ }}>
135
+ Value
136
+ </th>
137
+ </tr>
138
+ </thead>
139
+ <tbody>
140
+ {[
141
+ '05 (10 px)',
142
+ '06 (12 px)',
143
+ '07 (14 px)',
144
+ '08 (16 px)',
145
+ '09 (18 px)',
146
+ '10 (20 px)',
147
+ '12 (24 px)',
148
+ '16 (32 px)',
149
+ '18 (40 px)',
150
+ '19 (48 px)',
151
+ '20 (56 px)',
152
+ '21 (64 px)',
153
+ '22 (72 px)',
154
+ ].map((val, i, arr) => {
155
+ const isLast = i === arr.length - 1;
156
+ return (
157
+ <tr key={i} style={{backgroundColor: '#fff'}}>
158
+ <td
159
+ style={{
160
+ borderRight: '1px solid #fff',
161
+ borderBottom: isLast ? 'none' : '1px solid #fff',
162
+ padding: '12px 16px',
163
+ borderBottomLeftRadius: isLast ? '24px' : 0,
164
+ borderTop: '1px solid #eee',
165
+ }}>
166
+ font-size-{(i + 1) * 100}
167
+ </td>
168
+ <td
169
+ style={{
170
+ borderBottom: isLast ? 'none' : '1px solid #fff',
171
+ padding: '12px 16px',
172
+ borderBottomRightRadius: isLast ? '24px' : 0,
173
+ borderTop: '1px solid #eee',
174
+ }}>
175
+ Dimension-{val}
176
+ </td>
177
+ </tr>
178
+ );
179
+ })}
180
+ </tbody>
181
+ </table>
182
+
183
+ <table
184
+ style={{
185
+ borderCollapse: 'separate',
186
+ borderSpacing: 0,
187
+ width: '100%',
188
+ borderRadius: '24px',
189
+ overflow: 'hidden',
190
+ border: '1px solid #ccc',
191
+ }}>
192
+ <thead>
193
+ <tr>
194
+ <th
195
+ style={{
196
+ borderBottom: '1px solid #ccc',
197
+ textAlign: 'left',
198
+ background: '#f9f9f9',
199
+ borderTopLeftRadius: '24px',
200
+ borderRight: '1px solid #ccc',
201
+ padding: '12px 16px',
202
+ fontWeight: '600',
203
+ fontSize: '18px',
204
+ width: '50%',
205
+ }}>
206
+ Line height
207
+ </th>
208
+ <th
209
+ style={{
210
+ borderBottom: '1px solid #ccc',
211
+ padding: '12px 16px',
212
+ textAlign: 'left',
213
+ background: '#f9f9f9',
214
+ borderTopRightRadius: '24px',
215
+ fontWeight: '600',
216
+ fontSize: '14px',
217
+ width: '50%',
218
+ }}>
219
+ Value
220
+ </th>
221
+ </tr>
222
+ </thead>
223
+ <tbody>
224
+ {[
225
+ '07 (14 px)',
226
+ '09 (18 px)',
227
+ '10 (20 px)',
228
+ '12 (24 px)',
229
+ '14 (26 px)',
230
+ '16 (32 px)',
231
+ '18 (40 px)',
232
+ '19 (48 px)',
233
+ '20 (56 px)',
234
+ '21 (64 px)',
235
+ '22 (72 px)',
236
+ '23 (80 px)',
237
+ ].map((val, i, arr) => {
238
+ const isLast = i === arr.length - 1;
239
+ return (
240
+ <tr key={i} style={{backgroundColor: '#fff'}}>
241
+ <td
242
+ style={{
243
+ borderRight: '1px solid #fff',
244
+ borderBottom: isLast ? 'none' : '1px solid #fff',
245
+ padding: '12px 16px',
246
+ borderBottomLeftRadius: isLast ? '12px' : 0,
247
+ borderTop: '1px solid #eee',
248
+ }}>
249
+ font-line-height-{(i + 1) * 100}
250
+ </td>
251
+ <td
252
+ style={{
253
+ borderBottom: isLast ? 'none' : '1px solid #fff',
254
+ padding: '12px 16px',
255
+ borderBottomRightRadius: isLast ? '24px' : 0,
256
+ borderTop: '1px solid #eee',
257
+ }}>
258
+ Dimension-{val}
259
+ </td>
260
+ </tr>
261
+ );
262
+ })}
263
+ </tbody>
264
+ </table>
265
+
266
+ # Typography style
267
+
268
+ <table
269
+ style={{
270
+ borderCollapse: 'separate',
271
+ borderSpacing: 0,
272
+ width: '100%',
273
+ borderRadius: '24px',
274
+ overflow: 'hidden',
275
+ border: '1px solid #ccc',
276
+ fontFamily: 'Lato, sans-serif',
277
+ }}>
278
+ <thead>
279
+ <tr>
280
+ <th
281
+ style={{
282
+ borderBottom: '1px solid #ccc',
283
+ textAlign: 'left',
284
+ background: '#f9f9f9',
285
+ borderTopLeftRadius: '24px',
286
+ borderRight: '1px solid #ccc',
287
+ padding: '12px 16px',
288
+ fontWeight: '600',
289
+ fontSize: '18px',
290
+ width: '50%',
291
+ }}>
292
+ Title
293
+ </th>
294
+ <th
295
+ style={{
296
+ borderBottom: '1px solid #ccc',
297
+ padding: '12px 16px',
298
+ textAlign: 'left',
299
+ background: '#f9f9f9',
300
+ borderTopRightRadius: '24px',
301
+ fontWeight: '600',
302
+ fontSize: '18px',
303
+ width: '50%',
304
+ }}>
305
+ Value
306
+ </th>
307
+ </tr>
308
+ </thead>
309
+ <tbody>
310
+ {[
311
+ {
312
+ title: 'Display 1',
313
+ value: [
314
+ 'fontWeight: font-weight-bold',
315
+ 'fontSize: font-size-display-1',
316
+ 'lineHeight: font-line-height-display-1',
317
+ ],
318
+ },
319
+ {
320
+ title: 'Display 2',
321
+ value: [
322
+ 'fontWeight: font-weight-bold',
323
+ 'fontSize: font-size-display-2',
324
+ 'lineHeight: font-line-height-display-2',
325
+ ],
326
+ },
327
+ {
328
+ title: 'Display 3',
329
+ value: [
330
+ 'fontWeight: font-weight-bold',
331
+ 'fontSize: font-size-display-3',
332
+ 'lineHeight: font-line-height-display-3',
333
+ ],
334
+ },
335
+ {
336
+ title: 'Display 4',
337
+ value: [
338
+ 'fontWeight: font-weight-bold',
339
+ 'fontSize: font-size-display-4',
340
+ 'lineHeight: font-line-height-display-4',
341
+ ],
342
+ },
343
+ {
344
+ title: 'Heading 1',
345
+ value: [
346
+ 'fontWeight: font-weight-bold',
347
+ 'fontSize: font-size-heading-1',
348
+ 'lineHeight: font-line-height-heading-1',
349
+ ],
350
+ },
351
+ {
352
+ title: 'Heading 2',
353
+ value: [
354
+ 'fontWeight: font-weight-bold',
355
+ 'fontSize: font-size-heading-2',
356
+ 'lineHeight: font-line-height-heading-2',
357
+ ],
358
+ },
359
+ {
360
+ title: 'Heading 3',
361
+ value: [
362
+ 'fontWeight: font-weight-bold',
363
+ 'fontSize: font-size-heading-3',
364
+ 'lineHeight: font-line-height-heading-3',
365
+ ],
366
+ },
367
+ {
368
+ title: 'Heading 4',
369
+ value: [
370
+ 'fontWeight: font-weight-bold',
371
+ 'fontSize: font-size-heading-4',
372
+ 'lineHeight: font-line-height-heading-4',
373
+ ],
374
+ },
375
+ {
376
+ title: 'Heading 5',
377
+ value: [
378
+ 'fontWeight: font-weight-bold',
379
+ 'fontSize: font-size-heading-5',
380
+ 'lineHeight: font-line-height-heading-5',
381
+ ],
382
+ },
383
+ {
384
+ title: 'Body 1',
385
+ value: [
386
+ 'fontWeight: font-weight-bold',
387
+ 'fontSize: font-size-body-1',
388
+ 'lineHeight: font-line-height-body-1',
389
+ ],
390
+ },
391
+ {
392
+ title: 'Body 2',
393
+ value: [
394
+ 'fontWeight: font-weight-bold',
395
+ 'fontSize: font-size-body-2',
396
+ 'lineHeight: font-line-height-body-2',
397
+ ],
398
+ },
399
+ {
400
+ title: 'Body 3',
401
+ value: [
402
+ 'fontWeight: font-weight-bold',
403
+ 'fontSize: font-size-body-3',
404
+ 'lineHeight: font-line-height-body-3',
405
+ ],
406
+ },
407
+ {
408
+ title: 'Body 4',
409
+ value: [
410
+ 'fontWeight: font-weight-bold',
411
+ 'fontSize: font-size-body-4',
412
+ 'lineHeight: font-line-height-body-4',
413
+ ],
414
+ },
415
+ // Add more rows as needed...
416
+ ].map(({title, value}, i, arr) => {
417
+ const isLast = i === arr.length - 1;
418
+ return (
419
+ <tr key={title} style={{backgroundColor: '#fff'}}>
420
+ <td
421
+ style={{
422
+ borderRight: '1px solid #fff',
423
+ borderBottom: isLast ? 'none' : '1px solid #fff',
424
+ padding: '12px 16px',
425
+ borderBottomLeftRadius: isLast ? '12px' : 0,
426
+ borderTop: '1px solid #eee',
427
+ fontSize: '20px',
428
+ }}>
429
+ {title}
430
+ </td>
431
+ <td
432
+ style={{
433
+ borderBottom: isLast ? 'none' : '1px solid #fff',
434
+ padding: '12px 16px',
435
+ borderBottomRightRadius: isLast ? '12px' : 0,
436
+ borderTop: '1px solid #eee',
437
+ fontSize: '20px',
438
+ }}>
439
+ {value.map((line, idx) => {
440
+ const parts = line.split(':');
441
+ const label = parts[0]?.trim() || '';
442
+ const val = parts.slice(1).join(':').trim();
443
+ return (
444
+ <div key={idx} className="custom-value">
445
+ <strong>{label}:</strong> {val}
446
+ </div>
447
+ );
448
+ })}
449
+ </td>
450
+ </tr>
451
+ );
452
+ })}
453
+ </tbody>
454
+ </table>
@@ -0,0 +1,277 @@
1
+ # Utility Functions
2
+
3
+ SliceUI provides a set of utility functions to help you work with the design system more effectively. These utilities make it easier to handle common tasks like theming, responsive design, and styling.
4
+
5
+ ## Theme Context Utilities
6
+
7
+ ### useSliceTheme
8
+
9
+ The `useSliceTheme` hook provides access to the current theme context:
10
+
11
+ ```jsx
12
+ import {useSliceTheme} from '@foodhub/slice-ui';
13
+
14
+ function MyComponent() {
15
+ const theme = useSliceTheme();
16
+
17
+ return (
18
+ <div
19
+ style={{
20
+ color: theme.colors.colorForegroundPrimary,
21
+ padding: theme.spacing.medium,
22
+ }}>
23
+ Hello World
24
+ </div>
25
+ );
26
+ }
27
+ ```
28
+
29
+ ### SliceThemeProvider
30
+
31
+ Wrap your application with `SliceThemeProvider` to provide theme context:
32
+
33
+ ```jsx
34
+ import {SliceThemeProvider} from '@foodhub/slice-ui';
35
+
36
+ function App() {
37
+ return (
38
+ <SliceThemeProvider>
39
+ <YourApp />
40
+ </SliceThemeProvider>
41
+ );
42
+ }
43
+ ```
44
+
45
+ ## Responsive Utilities
46
+
47
+ ### useResponsiveValue
48
+
49
+ Get responsive values based on screen size:
50
+
51
+ ```jsx
52
+ import {useResponsiveValue} from '@foodhub/slice-ui';
53
+
54
+ function MyComponent() {
55
+ const padding = useResponsiveValue({
56
+ mobile: 'small',
57
+ tablet: 'medium',
58
+ desktop: 'large',
59
+ });
60
+
61
+ return <div style={{padding}}>Responsive Content</div>;
62
+ }
63
+ ```
64
+
65
+ ### getResponsiveValue
66
+
67
+ Get a responsive value without using a hook:
68
+
69
+ ```jsx
70
+ import {getResponsiveValue} from '@foodhub/slice-ui';
71
+
72
+ const styles = {
73
+ padding: getResponsiveValue({
74
+ mobile: 'small',
75
+ tablet: 'medium',
76
+ desktop: 'large',
77
+ }),
78
+ };
79
+ ```
80
+
81
+ ## Color Utilities
82
+
83
+ ### getColorWithOpacity
84
+
85
+ Add opacity to a color:
86
+
87
+ ```jsx
88
+ import {getColorWithOpacity} from '@foodhub/slice-ui';
89
+
90
+ const styles = {
91
+ backgroundColor: getColorWithOpacity(theme.colors.primary, '0.5'),
92
+ };
93
+ ```
94
+
95
+ ### getContrastColor
96
+
97
+ Get a contrasting color for text:
98
+
99
+ ```jsx
100
+ import {getContrastColor} from '@foodhub/slice-ui';
101
+
102
+ const styles = {
103
+ color: getContrastColor(theme.colors.primary),
104
+ };
105
+ ```
106
+
107
+ ## Spacing Utilities
108
+
109
+ ### getSpacing
110
+
111
+ Get spacing value with multiplier:
112
+
113
+ ```jsx
114
+ import {getSpacing} from '@foodhub/slice-ui';
115
+
116
+ const styles = {
117
+ margin: getSpacing('medium', 2), // 2x medium spacing
118
+ };
119
+ ```
120
+
121
+ ### getResponsiveSpacing
122
+
123
+ Get responsive spacing:
124
+
125
+ ```jsx
126
+ import {getResponsiveSpacing} from '@foodhub/slice-ui';
127
+
128
+ const styles = {
129
+ padding: getResponsiveSpacing({
130
+ mobile: 'small',
131
+ tablet: 'medium',
132
+ desktop: 'large',
133
+ }),
134
+ };
135
+ ```
136
+
137
+ ## Typography Utilities
138
+
139
+ ### getTypographyStyle
140
+
141
+ Get typography style with custom properties:
142
+
143
+ ```jsx
144
+ import {getTypographyStyle} from '@foodhub/slice-ui';
145
+
146
+ const styles = {
147
+ ...getTypographyStyle('body1', {
148
+ color: theme.colors.primary,
149
+ textAlign: 'center',
150
+ }),
151
+ };
152
+ ```
153
+
154
+ ### getResponsiveTypography
155
+
156
+ Get responsive typography:
157
+
158
+ ```jsx
159
+ import {getResponsiveTypography} from '@foodhub/slice-ui';
160
+
161
+ const styles = {
162
+ ...getResponsiveTypography({
163
+ mobile: 'body2',
164
+ tablet: 'body1',
165
+ desktop: 'heading3',
166
+ }),
167
+ };
168
+ ```
169
+
170
+ ## Component-Specific Utilities
171
+
172
+ ### getButtonStyles
173
+
174
+ Get button styles based on variant and size:
175
+
176
+ ```jsx
177
+ import {getButtonStyles} from '@foodhub/slice-ui';
178
+
179
+ const styles = {
180
+ ...getButtonStyles('primary', 'medium'),
181
+ };
182
+ ```
183
+
184
+ ### getInputStyles
185
+
186
+ Get input styles based on state and size:
187
+
188
+ ```jsx
189
+ import {getInputStyles} from '@foodhub/slice-ui';
190
+
191
+ const styles = {
192
+ ...getInputStyles('default', 'medium'),
193
+ };
194
+ ```
195
+
196
+ ## Best Practices
197
+
198
+ 1. **Theme Context**
199
+
200
+ - Always use `useSliceTheme` to access theme values
201
+ - Don't access theme values directly from imports
202
+ - Keep theme context at the root of your application
203
+
204
+ 2. **Color Management**
205
+
206
+ - Use semantic color tokens
207
+ - Use color utilities for opacity and contrast
208
+ - Maintain consistent color usage across components
209
+
210
+ 3. **Spacing Consistency**
211
+
212
+ - Use the spacing scale
213
+ - Use spacing utilities for calculations
214
+ - Maintain consistent spacing across components
215
+
216
+ 4. **Typography Hierarchy**
217
+ - Use typography utilities for consistent text styles
218
+ - Follow the typography scale
219
+ - Use responsive typography for different screen sizes
220
+
221
+ ## Complete Example
222
+
223
+ Here's a complete example showing how to use multiple utilities together:
224
+
225
+ ```jsx
226
+ import {
227
+ useSliceTheme,
228
+ useResponsiveValue,
229
+ getColorWithOpacity,
230
+ getSpacing,
231
+ getTypographyStyle,
232
+ } from '@foodhub/slice-ui';
233
+
234
+ function Card({title, content}) {
235
+ const theme = useSliceTheme();
236
+ const padding = useResponsiveValue({
237
+ mobile: 'small',
238
+ tablet: 'medium',
239
+ desktop: 'large',
240
+ });
241
+
242
+ const styles = {
243
+ container: {
244
+ backgroundColor: getColorWithOpacity(theme.colors.primary, '0.1'),
245
+ padding: getSpacing(padding),
246
+ borderRadius: theme.dimensions.borderRadius.medium,
247
+ },
248
+ title: {
249
+ ...getTypographyStyle('heading2', {
250
+ color: theme.colors.colorForegroundPrimary,
251
+ marginBottom: getSpacing('small'),
252
+ }),
253
+ },
254
+ content: {
255
+ ...getTypographyStyle('body1', {
256
+ color: theme.colors.colorForegroundSecondary,
257
+ }),
258
+ },
259
+ };
260
+
261
+ return (
262
+ <div style={styles.container}>
263
+ <h2 style={styles.title}>{title}</h2>
264
+ <p style={styles.content}>{content}</p>
265
+ </div>
266
+ );
267
+ }
268
+ ```
269
+
270
+ This example demonstrates:
271
+
272
+ - Using theme context
273
+ - Responsive values
274
+ - Color utilities
275
+ - Spacing utilities
276
+ - Typography utilities
277
+ - Component-specific styling