@marigold/system 0.1.0 → 0.3.2

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 (47) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/Box.d.ts +14 -0
  3. package/dist/Global.d.ts +2 -0
  4. package/dist/SVG.d.ts +6 -0
  5. package/dist/SVG.stories.d.ts +5 -0
  6. package/dist/index.d.ts +6 -3
  7. package/dist/normalize.d.ts +144 -0
  8. package/dist/system.cjs.development.js +350 -144
  9. package/dist/system.cjs.development.js.map +1 -1
  10. package/dist/system.cjs.production.min.js +1 -1
  11. package/dist/system.cjs.production.min.js.map +1 -1
  12. package/dist/system.esm.js +342 -140
  13. package/dist/system.esm.js.map +1 -1
  14. package/dist/theme.d.ts +136 -0
  15. package/dist/types.d.ts +1 -2
  16. package/dist/useTheme.d.ts +11 -5
  17. package/dist/variant.d.ts +29 -0
  18. package/package.json +4 -6
  19. package/src/Box.test.tsx +308 -0
  20. package/src/Box.tsx +199 -0
  21. package/src/Global.test.tsx +57 -0
  22. package/src/Global.tsx +34 -0
  23. package/src/SVG.stories.tsx +48 -0
  24. package/src/SVG.test.tsx +82 -0
  25. package/src/SVG.tsx +24 -0
  26. package/src/index.ts +6 -3
  27. package/src/normalize.test.tsx +15 -0
  28. package/src/normalize.ts +100 -0
  29. package/src/theme.ts +157 -0
  30. package/src/types.ts +0 -2
  31. package/src/useTheme.test.tsx +22 -14
  32. package/src/useTheme.tsx +37 -9
  33. package/src/variant.test.ts +93 -0
  34. package/src/variant.ts +54 -0
  35. package/dist/cache.d.ts +0 -4
  36. package/dist/reset.d.ts +0 -24
  37. package/dist/useClassname.d.ts +0 -2
  38. package/dist/useStyles.d.ts +0 -15
  39. package/src/Colors.stories.mdx +0 -455
  40. package/src/cache.ts +0 -4
  41. package/src/concepts-principles.mdx +0 -84
  42. package/src/reset.ts +0 -108
  43. package/src/useClassname.test.tsx +0 -70
  44. package/src/useClassname.ts +0 -23
  45. package/src/useStyles.test.tsx +0 -286
  46. package/src/useStyles.ts +0 -63
  47. package/src/writeComponent.stories.mdx +0 -126
@@ -1,455 +0,0 @@
1
- import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
2
-
3
- <Meta title="Colours" />
4
-
5
- # Colours
6
-
7
- The following colours are used in the b2b-theme.
8
-
9
- ## Colour Values
10
-
11
- <Canvas>
12
- <Story name="Gray">
13
- <div style={{ padding: '0.5rem 1rem', fontFamily: 'Inter' }}>
14
- <h2>Gray</h2>
15
- <div style={{ display: 'inline-block', width: '260px' }}>
16
- <div
17
- style={{
18
- background: '#ffffff',
19
- color: 'black',
20
- padding: '8px',
21
- display: 'flex',
22
- justifyContent: 'space-between',
23
- }}
24
- >
25
- <span>Gray00</span>
26
- <span>#ffffff</span>
27
- </div>
28
- <div
29
- style={{
30
- background: '#fafafa',
31
- color: 'black',
32
- padding: '8px',
33
- display: 'flex',
34
- justifyContent: 'space-between',
35
- }}
36
- >
37
- <span>Gray10</span>
38
- <span>#fafafa</span>
39
- </div>
40
- <div
41
- style={{
42
- background: '#f3f3f3',
43
- color: 'black',
44
- padding: '8px',
45
- display: 'flex',
46
- justifyContent: 'space-between',
47
- }}
48
- >
49
- <span>Gray20</span>
50
- <span>#f3f3f3</span>
51
- </div>
52
- <div
53
- style={{
54
- background: '#e3e3e3',
55
- color: 'black',
56
- padding: '8px',
57
- display: 'flex',
58
- justifyContent: 'space-between',
59
- }}
60
- >
61
- <span>Gray30</span>
62
- <span>#e3e3e3</span>
63
- </div>
64
- <div
65
- style={{
66
- background: '#cccccc',
67
- color: 'black',
68
- padding: '8px',
69
- display: 'flex',
70
- justifyContent: 'space-between',
71
- }}
72
- >
73
- <span>Gray40</span>
74
- <span>#cccccc</span>
75
- </div>
76
- <div
77
- style={{
78
- background: '#8d8d8d',
79
- color: 'white',
80
- padding: '8px',
81
- display: 'flex',
82
- justifyContent: 'space-between',
83
- }}
84
- >
85
- <span>Gray50</span>
86
- <span>#8d8d8d</span>
87
- </div>
88
- <div
89
- style={{
90
- background: '#6d6d6d',
91
- color: 'white',
92
- padding: '8px',
93
- display: 'flex',
94
- justifyContent: 'space-between',
95
- }}
96
- >
97
- <span>Gray60</span>
98
- <span>#6d6d6d</span>
99
- </div>
100
- <div
101
- style={{
102
- background: '#4b4b4b',
103
- color: 'white',
104
- padding: '8px',
105
- display: 'flex',
106
- justifyContent: 'space-between',
107
- }}
108
- >
109
- <span>Gray70 (Text Black)</span>
110
- <span>#4b4b4b</span>
111
- </div>
112
- <div
113
- style={{
114
- background: '#2b2b2b',
115
- color: 'white',
116
- padding: '8px',
117
- display: 'flex',
118
- justifyContent: 'space-between',
119
- }}
120
- >
121
- <span>Gray80</span>
122
- <span>#2b2b2b</span>
123
- </div>
124
- <div
125
- style={{
126
- background: '#0f0f0f',
127
- color: 'white',
128
- padding: '8px',
129
- display: 'flex',
130
- justifyContent: 'space-between',
131
- }}
132
- >
133
- <span>Gray90</span>
134
- <span>#0f0f0f</span>
135
- </div>
136
- </div>
137
- </div>
138
- </Story>
139
- <Story name="Orange">
140
- <div style={{ padding: '0.5rem 1rem', fontFamily: 'Inter' }}>
141
- <h2>Orange</h2>
142
- <div style={{ display: 'inline-block', width: '260px' }}>
143
- <div
144
- style={{
145
- background: '#fff8f1',
146
- color: 'black',
147
- padding: '8px',
148
- display: 'flex',
149
- justifyContent: 'space-between',
150
- }}
151
- >
152
- <span>Orange10</span>
153
- <span>#fff8f1</span>
154
- </div>
155
- <div
156
- style={{
157
- background: '#fdcca0',
158
- color: 'black',
159
- padding: '8px',
160
- display: 'flex',
161
- justifyContent: 'space-between',
162
- }}
163
- >
164
- <span>Orange20</span>
165
- <span>#fdcca0</span>
166
- </div>
167
- <div
168
- style={{
169
- background: '#f8ac67',
170
- color: 'black',
171
- padding: '8px',
172
- display: 'flex',
173
- justifyContent: 'space-between',
174
- }}
175
- >
176
- <span>Orange40</span>
177
- <span>#f8ac67</span>
178
- </div>
179
- <div
180
- style={{
181
- background: '#fa8005',
182
- color: 'black',
183
- padding: '8px',
184
- display: 'flex',
185
- justifyContent: 'space-between',
186
- }}
187
- >
188
- <span>Orange60 (Primary)</span>
189
- <span>#fa8005</span>
190
- </div>
191
- <div
192
- style={{
193
- background: '#ea5200',
194
- color: 'black',
195
- padding: '8px',
196
- display: 'flex',
197
- justifyContent: 'space-between',
198
- }}
199
- >
200
- <span>Orange70</span>
201
- <span>#ea5200</span>
202
- </div>
203
- <div
204
- style={{
205
- background: '#ae440a',
206
- color: 'black',
207
- padding: '8px',
208
- display: 'flex',
209
- justifyContent: 'space-between',
210
- }}
211
- >
212
- <span>Orange80</span>
213
- <span>#ae440a</span>
214
- </div>
215
- </div>
216
- </div>
217
- </Story>
218
- <Story name="Blue">
219
- <div style={{ padding: '0.5rem 1rem', fontFamily: 'Inter' }}>
220
- <h2>Blue</h2>
221
- <div style={{ display: 'inline-block', width: '260px' }}>
222
- <div
223
- style={{
224
- background: '#e8f4fa',
225
- color: 'black',
226
- padding: '8px',
227
- display: 'flex',
228
- justifyContent: 'space-between',
229
- }}
230
- >
231
- <span>Blue10</span>
232
- <span>#e8f4fa</span>
233
- </div>
234
- <div
235
- style={{
236
- background: '#c1f0fc',
237
- color: 'black',
238
- padding: '8px',
239
- display: 'flex',
240
- justifyContent: 'space-between',
241
- }}
242
- >
243
- <span>Blue20</span>
244
- <span>#c1f0fc</span>
245
- </div>
246
- <div
247
- style={{
248
- background: '#67dfff',
249
- color: 'black',
250
- padding: '8px',
251
- display: 'flex',
252
- justifyContent: 'space-between',
253
- }}
254
- >
255
- <span>Blue40</span>
256
- <span>#67dfff</span>
257
- </div>
258
- <div
259
- style={{
260
- background: '#3ab3d5',
261
- color: 'white',
262
- padding: '8px',
263
- display: 'flex',
264
- justifyContent: 'space-between',
265
- }}
266
- >
267
- <span>Blue60</span>
268
- <span>#3ab3d5</span>
269
- </div>
270
- <div
271
- style={{
272
- background: '#1d67b6',
273
- color: 'white',
274
- padding: '8px',
275
- display: 'flex',
276
- justifyContent: 'space-between',
277
- }}
278
- >
279
- <span>Blue70</span>
280
- <span>#1d67b6</span>
281
- </div>
282
- <div
283
- style={{
284
- background: '#0c3a6b',
285
- color: 'white',
286
- padding: '8px',
287
- display: 'flex',
288
- justifyContent: 'space-between',
289
- }}
290
- >
291
- <span>Blue80</span>
292
- <span>#0c3a6b</span>
293
- </div>
294
- </div>
295
- </div>
296
- </Story>
297
- <Story name="Green">
298
- <div style={{ padding: '0.5rem 1rem', fontFamily: 'Inter' }}>
299
- <h2>Green</h2>
300
- <div style={{ display: 'inline-block', width: '260px' }}>
301
- <div
302
- style={{
303
- background: '#f9fed0',
304
- color: 'black',
305
- padding: '8px',
306
- display: 'flex',
307
- justifyContent: 'space-between',
308
- }}
309
- >
310
- <span>Green10</span>
311
- <span>#f9fed0</span>
312
- </div>
313
- <div
314
- style={{
315
- background: '#e8f57b',
316
- color: 'black',
317
- padding: '8px',
318
- display: 'flex',
319
- justifyContent: 'space-between',
320
- }}
321
- >
322
- <span>Green20</span>
323
- <span>#e8f57b</span>
324
- </div>
325
- <div
326
- style={{
327
- background: '#bacb2a',
328
- color: 'black',
329
- padding: '8px',
330
- display: 'flex',
331
- justifyContent: 'space-between',
332
- }}
333
- >
334
- <span>Green40</span>
335
- <span>#bacb2a</span>
336
- </div>
337
- <div
338
- style={{
339
- background: '#8bbd26',
340
- color: 'black',
341
- padding: '8px',
342
- display: 'flex',
343
- justifyContent: 'space-between',
344
- }}
345
- >
346
- <span>Green60</span>
347
- <span>#8bbd26</span>
348
- </div>
349
- <div
350
- style={{
351
- background: '#44a112',
352
- color: 'white',
353
- padding: '8px',
354
- display: 'flex',
355
- justifyContent: 'space-between',
356
- }}
357
- >
358
- <span>Green70</span>
359
- <span>#44a112</span>
360
- </div>
361
- <div
362
- style={{
363
- background: '#215107',
364
- color: 'white',
365
- padding: '8px',
366
- display: 'flex',
367
- justifyContent: 'space-between',
368
- }}
369
- >
370
- <span>Green80</span>
371
- <span>#215107</span>
372
- </div>
373
- </div>
374
- </div>
375
- </Story>
376
- <Story name="Red">
377
- <div style={{ padding: '0.5rem 1rem', fontFamily: 'Inter' }}>
378
- <h2>Red</h2>
379
- <div style={{ display: 'inline-block', width: '260px' }}>
380
- <div
381
- style={{
382
- background: '#fff8f8',
383
- color: 'black',
384
- padding: '8px',
385
- display: 'flex',
386
- justifyContent: 'space-between',
387
- }}
388
- >
389
- <span>Red10</span>
390
- <span>#fff8f8</span>
391
- </div>
392
- <div
393
- style={{
394
- background: '#fec8c9',
395
- color: 'black',
396
- padding: '8px',
397
- display: 'flex',
398
- justifyContent: 'space-between',
399
- }}
400
- >
401
- <span>Red20</span>
402
- <span>#fec8c9</span>
403
- </div>
404
- <div
405
- style={{
406
- background: '#f38a8a',
407
- color: 'black',
408
- padding: '8px',
409
- display: 'flex',
410
- justifyContent: 'space-between',
411
- }}
412
- >
413
- <span>Red40</span>
414
- <span>#f38a8a</span>
415
- </div>
416
- <div
417
- style={{
418
- background: '#dd4142',
419
- color: 'black',
420
- padding: '8px',
421
- display: 'flex',
422
- justifyContent: 'space-between',
423
- }}
424
- >
425
- <span>Red60</span>
426
- <span>#dd4142</span>
427
- </div>
428
- <div
429
- style={{
430
- background: '#8b0027',
431
- color: 'white',
432
- padding: '8px',
433
- display: 'flex',
434
- justifyContent: 'space-between',
435
- }}
436
- >
437
- <span>Red70</span>
438
- <span>#8b0027</span>
439
- </div>
440
- <div
441
- style={{
442
- background: '#4d0419',
443
- color: 'white',
444
- padding: '8px',
445
- display: 'flex',
446
- justifyContent: 'space-between',
447
- }}
448
- >
449
- <span>Red80</span>
450
- <span>#4d0419</span>
451
- </div>
452
- </div>
453
- </div>
454
- </Story>
455
- </Canvas>
package/src/cache.ts DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * Expose cache from emotion so we can use the same cache when doing SSR.
3
- */
4
- export { cache } from '@emotion/css';
@@ -1,84 +0,0 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
2
-
3
- <Meta title="Guides/Concepts & Principles" />
4
-
5
- ## Design Tokens
6
-
7
- The term _design tokens_ originates from the [Lightning Design System](https://www.lightningdesignsystem.com/design-tokens/). They are the "visual design atoms" of a design system. Similar to variables in CSS or Sass, design tokens are used to capture low-level values and then used to create the look and feel of your product. This helps with maintaining a consistent and scalable visual system for UI development.
8
-
9
- ```css
10
- /* button.css */
11
- .button {
12
- color: #1f1235;
13
- background: #ff6e6c;
14
- height: 24px;
15
- }
16
- ```
17
-
18
- ```scss
19
- /* colors.scss */
20
- $color-primary: #ff6e6c;
21
- $color-text: #1f1235;
22
-
23
- /* sizes.scss */
24
- $size-6: 24px;
25
-
26
- /* button.scss */
27
- .button {
28
- color: $color-text;
29
- background: $color-primary;
30
- height: $size-6;
31
- }
32
- ```
33
-
34
- _Read more:_
35
-
36
- - [Lightning Design System: Design Tokens](https://www.lightningdesignsystem.com/design-tokens/)
37
- - [CSS Tricks: What are Design Tokens?](https://css-tricks.com/what-are-design-tokens/)
38
-
39
- ## Rhythm & Harmony
40
-
41
- Instead of choosing arbitrary numbers for our typography, we make use of a _modular scale_. "By using culturally relevant, historically pleasing ratios to create modular scales and basing the measurements in our compositions on values from those scales, we can achieve a visual harmony not found in layouts that use arbitrary, conventional, or easily divisible numbers." ([_More Meaningful Typography_](https://alistapart.com/article/more-meaningful-typography/))
42
-
43
- Applied to web typography, this means we choose a base font size and apply a ratio to it. The ratio is then squared to generate an ascending scale.
44
-
45
- ```scss
46
- /* perfect fifth */
47
- $ratio: 1.5;
48
-
49
- /* browser default */
50
- $base: 16px;
51
-
52
- /**
53
- * The formular is always "$base * $ratio ** $level", the level is a integer.
54
- * The resulting value is usually rounded to avoid poor sub-pixel rendering.
55
- *
56
- * Note that in the below example the number is not equal to the $level in
57
- * the formula.
58
- */
59
- $fontSize-0: 10px;
60
- $fontSize-1: 16px;
61
- $fontSize-2: 24px;
62
- $fontSize-3: 36px;
63
- /* etc. */
64
- ```
65
-
66
- A similar concept can be applied to spacing and sizing of elements. To maintain a aesthetically pleasing rhythm between elements, we adopt the _8pt grid_. This means that multiples of 8 are used to define dimensions, paddings and margins. As a result, all of our measurements follow the same rule and we automatically get a more consistent UI.
67
-
68
- ```scss
69
- /* 8pt grid */
70
- $size-0: 0px;
71
- $size-1: 8px;
72
- $size-2: 16px;
73
- $size-3: 32px;
74
- $size-4: 64px;
75
- $size-5: 128px;
76
- $size-6: 256px;
77
- $size-7: 512px;
78
- ```
79
-
80
- Read more:
81
-
82
- - [A List Apart: More Meaningful Typography](https://alistapart.com/article/more-meaningful-typography/)
83
- - [Type Scale Calculator](https://type-scale.com/)
84
- - [Bryn Jackson's 8-Point Grid](https://spec.fm/specifics/8-pt-grid)
package/src/reset.ts DELETED
@@ -1,108 +0,0 @@
1
- import { css } from '@emotion/css';
2
-
3
- const base = css({
4
- boxSizing: 'border-box',
5
- margin: 0,
6
- padding: 0,
7
- minWidth: 0,
8
- fontSize: '100%',
9
- font: 'inherit',
10
- verticalAlign: 'baseline',
11
- WebkitTapHighlightColor: 'transparent',
12
- });
13
-
14
- // Content
15
- // ---------------
16
- const block = css({
17
- display: 'block',
18
- });
19
-
20
- const list = css({
21
- listStyle: 'none',
22
- });
23
-
24
- const table = css({
25
- borderCollapse: 'collapse',
26
- borderSpacing: 0,
27
- });
28
-
29
- // Typography
30
- // ---------------
31
- const a = css({
32
- textDecoration: 'none',
33
- touchAction: 'manipulation'
34
- });
35
-
36
- const quote = css({
37
- quotes: 'none',
38
- selectors: {
39
- '&:before, &:after': {
40
- content: "''",
41
- },
42
- },
43
- });
44
-
45
- // Form Elements
46
- // ---------------
47
- const button = css({
48
- display: 'block',
49
- appearance: 'none',
50
- background: 'transparent',
51
- textAlign: 'center',
52
- touchAction: 'manipulation'
53
- });
54
-
55
- const input = css({
56
- display: 'block',
57
- appearance: 'none',
58
- selectors: {
59
- '&::-ms-clear': {
60
- display: 'none',
61
- },
62
- '&::-webkit-search-cancel-button': {
63
- WebkitAppearance: 'none',
64
- },
65
- },
66
- });
67
-
68
- const select = css({
69
- display: 'block',
70
- appearance: 'none',
71
- selectors: {
72
- '&::-ms-expand': {
73
- display: 'none',
74
- },
75
- },
76
- });
77
-
78
- const textarea = css({
79
- display: 'block',
80
- appearance: 'none',
81
- });
82
-
83
- // Reset
84
- // ---------------
85
- export const reset = {
86
- article: block,
87
- aside: block,
88
- details: block,
89
- figcaption: block,
90
- figure: block,
91
- footer: block,
92
- header: block,
93
- hgroup: block,
94
- menu: block,
95
- nav: block,
96
- section: block,
97
- ul: list,
98
- ol: list,
99
- blockquote: quote,
100
- q: quote,
101
- a,
102
- base,
103
- table,
104
- select,
105
- button,
106
- textarea,
107
- input,
108
- } as const;