@@ -2,7 +2,7 @@ import { Meta } from "@storybook/blocks";
2
2
3
3
import Illustration from " ../assets/images/spectrum_illustration_2x.png" ;
4
4
5
- <Meta title = " Contributing" />
5
+ <Meta title = " Contributing" />
6
6
7
7
<img src = { Illustration } style = { { marginTop: " -20px" , marginBottom: " 20px" }} />
8
8
@@ -31,6 +31,7 @@ For more general information about how to contribute to the Spectrum CSS project
31
31
32
32
Each component has the following files:
33
33
34
+ <<<<<<< HEAD
34
35
- `index.css` - The source file for all styles related to the component. This contains all selectors and css properties for the component.
35
36
- `stories/*.stories.js` - The storybook file that defines the component's stories and the available knobs for the component.
36
37
- `stories/template.js` - The template function that generates the component's mark-up based on the provided settings.
@@ -39,16 +40,42 @@ Each component has the following files:
39
40
Each component outputs the following assets to `dist`:
40
41
41
42
- `index.css`: This asset includes the CSS for the component and is meant to be loaded in conjunction with the tokens for your desired color context and scales.
43
+ =======
44
+ - `index.css` - The source file for all styles related to the component. This contains all selectors and css properties for the component but specifically lacks any custom properties or variables. These values are sourced from the `themes` directory.
45
+ - `themes/*.css` - The theme-specific, component-level custom properties used to style the component. These files are meant to be loaded with the source styles.
46
+ - `stories/*.stories.js` - The storybook file that defines the component's stories and the available knobs for the component.
47
+ - `stories/template.js` - The template function that generates the component's mark-up based on the provided settings.
48
+ - `stories/*.test.js` - The testing grid for visual regression testing in Chromatic.
49
+ - `stories/*.mdx` - This asset generates the component-specific documentation and is rendered in Storybook as the Docs page.
50
+
51
+ Each component outputs the following assets to `dist`:
52
+
53
+ - `index.css`: This asset includes the base CSS and the `themes/spectrum-two.css` definitions (without the system mapping layer). This asset is meant to be used in a environment where only the current Spectrum theme is supported.
54
+ - `index-base.css`: This asset includes only the base CSS; that is, the CSS without any custom property definitions. This can be used in conjunction with `index-theme.css` and the desired `themes/*.css` file to render a themed component.
55
+ - `index-theme.css`: This asset includes only the custom property definitions for the component as mapped to the system variables. This can be used in conjunction with `index-base.css` and the desired `themes/*.css` file to render a themed component.
56
+
57
+ Each component outputs theme-specific assets to `dist/themes`. These assets include the system variables mapped to their global token counterparts. This file is meant to be loaded in conjunction with the `index-base.css` and `index-theme.css` files to render a themed component.
58
+
59
+ - `themes/spectrum-two.css`: Represents the current Spectrum theme, aka Spectrum 2.
60
+ >>>>>>> 27d01dfbc (fix(pagination): deprecate legacy features to align with foundations)
42
61
43
62
## Adding a new component
44
63
45
64
1 . Generate a new component using the ` yarn new component ` command. The generator will prompt you to answer questions about your component.
46
65
2 . Edit the ` dependencies ` within the ` package.json ` file to use only the dependencies your component needs. All components rely on ` @spectrum-css/tokens ` , and most rely on ` @spectrum-css/icon ` .
47
66
3 . Once your folder has been generated, you can run ` yarn start ` in the root of the project to begin developing.
67
+ <<<<<<< HEAD
48
68
4. The `index.css` file is where all of your styles should be added.
49
69
5. Inside the `stories` directory you will find a `template.js` and `*.stories.js` file.
50
70
- In the `*.stories.js` file, define the available knobs and properties for your component, as well as any standard variations you want to surface in [Storybook](https://storybook.js.org/docs/react/writing-stories/introduction).
51
71
- Update the `template.js` file with the markup, using [lit-html syntax](https://lit.dev/docs/templates/overview/) to adjust results based on the provided settings from the Storybook knobs.
72
+ =======
73
+ 4. The `index.css` file is where most of your styles will be added. Add any custom property mappings to the global token library in the `themes/spectrum-two.css` asset.
74
+ 5. Inside the `stories` directory you will find a `template.js`, `*.stories.js`, and `*.mdx` file.
75
+ - In the `*.stories.js` file, define the available knobs and properties for your component, as well as any standard variations you want to surface in [Storybook](https://storybook.js.org/docs/react/writing-stories/introduction).
76
+ - Update the `template.js` file with the markup, using [lit-html syntax](https://lit.dev/docs/templates/overview/) to adjust results based on the provided settings from the Storybook knobs.
77
+ - Update the `*.mdx` file with the documentation for your component.
78
+ >>>>>>> 27d01dfbc (fix(pagination): deprecate legacy features to align with foundations)
52
79
53
80
_ Note_ : Because we use scoped packages, before it can be published, you must manually publish the new component as public:
54
81
@@ -163,6 +190,7 @@ To import shared types into your story, use the following syntax:
163
190
164
191
``` js
165
192
import {
193
+ <<<<<<< HEAD
166
194
isActive ,
167
195
isDisabled ,
168
196
isFocused ,
@@ -185,6 +213,30 @@ export default {
185
213
isFocused: false ,
186
214
isActive: false ,
187
215
},
216
+ ====== =
217
+ isActive,
218
+ isDisabled,
219
+ isFocused,
220
+ isHovered,
221
+ isSelected,
222
+ } from " @spectrum-css/preview/types" ;
223
+
224
+ export default {
225
+ argTypes: {
226
+ isDisabled,
227
+ isSelected,
228
+ isHovered,
229
+ isFocused,
230
+ isActive,
231
+ },
232
+ args: {
233
+ isDisabled: false ,
234
+ isSelected: false ,
235
+ isHovered: false ,
236
+ isFocused: false ,
237
+ isActive: false ,
238
+ },
239
+ >>>>>> > 27d01dfbc (fix (pagination): deprecate legacy features to align with foundations)
188
240
};
189
241
```
190
242
@@ -334,6 +386,7 @@ import { when } from "lit/directives/when.js";
334
386
import " ../index.css" ;
335
387
336
388
export const Template = (
389
+ <<<<<< < HEAD
337
390
{
338
391
rootClass = " spectrum-Tag" ,
339
392
size = " m" ,
@@ -408,6 +461,82 @@ export const Template = (
408
461
)}
409
462
</div >
410
463
` ;
464
+ ====== =
465
+ {
466
+ rootClass = " spectrum-Tag" ,
467
+ size = " m" ,
468
+ iconName,
469
+ avatarUrl,
470
+ label,
471
+ isSelected = false ,
472
+ isEmphasized = false ,
473
+ isDisabled = false ,
474
+ isInvalid = false ,
475
+ hasClearButton = false ,
476
+ id,
477
+ customClasses = [],
478
+ customStyles = {},
479
+ },
480
+ context,
481
+ ) => {
482
+ return html `
483
+ <div
484
+ class =${classMap({
485
+ [rootClass]: true,
486
+ [`${rootClass}--size${size?.toUpperCase()}`]:
487
+ typeof size ! == " undefined" ,
488
+ " is-emphasized" : isEmphasized,
489
+ " is-disabled" : isDisabled,
490
+ " is-invalid" : isInvalid,
491
+ " is-selected" : isSelected,
492
+ ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
493
+ })}
494
+ style=${ styleMap (customStyles)}
495
+ id=${ ifDefined (id)}
496
+ tabindex="0"
497
+ >
498
+ ${ when (avatarUrl && ! iconName, () =>
499
+ Avatar (
500
+ {
501
+ image: avatarUrl,
502
+ size: " 50" ,
503
+ },
504
+ context,
505
+ ),
506
+ )}
507
+ ${ when (iconName, () =>
508
+ Icon (
509
+ {
510
+ iconName,
511
+ customClasses: [` ${ rootClass} s-itemIcon` ],
512
+ },
513
+ context,
514
+ ),
515
+ )}
516
+ <span
517
+ class =${classMap({
518
+ [`${rootClass}s-itemLabel`]: true,
519
+ })}
520
+ >${ label} </span
521
+ >
522
+ ${ when (hasClearButton, () =>
523
+ ClearButton (
524
+ {
525
+ customClasses: [` ${ rootClass} -clearButton` ],
526
+ onclick : (evt ) => {
527
+ const el = evt .target ;
528
+ if (! el) return ;
529
+
530
+ const wrapper = el .closest (rootClass);
531
+ wrapper .parentNode .removeChild (wrapper);
532
+ },
533
+ },
534
+ context,
535
+ ),
536
+ )}
537
+ </div >
538
+ ` ;
539
+ >>>>>> > 27d01dfbc (fix (pagination): deprecate legacy features to align with foundations)
411
540
};
412
541
` ` `
413
542
@@ -424,6 +553,7 @@ import { Variants } from "@spectrum-css/preview/decorators";
424
553
import { Template } from " ./template.js" ;
425
554
426
555
export const AccordionGroup = Variants ({
556
+ <<<<<< < HEAD
427
557
Template,
428
558
testData: [
429
559
{
@@ -442,6 +572,26 @@ export const AccordionGroup = Variants({
442
572
disableAll: true ,
443
573
},
444
574
],
575
+ ====== =
576
+ Template,
577
+ testData: [
578
+ {
579
+ testHeading: " Standard" ,
580
+ },
581
+ {
582
+ testHeading: " Compact" ,
583
+ density: " compact" ,
584
+ collapseAll: true ,
585
+ withStates: false ,
586
+ },
587
+ ],
588
+ stateData: [
589
+ {
590
+ testHeading: " Disabled" ,
591
+ disableAll: true ,
592
+ },
593
+ ],
594
+ >>>>>> > 27d01dfbc (fix (pagination): deprecate legacy features to align with foundations)
445
595
});
446
596
` ` `
447
597
@@ -460,7 +610,11 @@ In the event that you don't want a story to be tested in Chromatic, you can use
460
610
461
611
` ` ` js
462
612
Default .parameters = {
613
+ <<<<<< < HEAD
463
614
chromatic: { disableSnapshot: true },
615
+ ====== =
616
+ chromatic: { disableSnapshot: true },
617
+ >>>>>> > 27d01dfbc (fix (pagination): deprecate legacy features to align with foundations)
464
618
};
465
619
` ` `
466
620
0 commit comments