The project is broken down into separate components for each component inside of the components/ folder.
Components are released on npm as @spectrum-css/$COMPONENT, where $COMPONENT corresponds to the folder name in this repository.
Each component has the following files:
index.css- The scale-specific styles for the component: dimensions, layout, etc (these change between scales)skin.css- The theme-specific styles for the component: colors, box-shadows, etc (these change between color stops)docs.yml- The markup examples and documentation for the component, appearing as a single entry in the site navigationdocs/*.yml- Additional examples that appear separately in the site navigation
See documentation generation documentation for more information on the properties available within the .yml files.
- Run
gulp devin the root of the project to begin developing. - Edit
components/$COMPONENT/index.cssandcomponents/$COMPONENT/skin.csswith dimensions and color properties respectively. The documentation will live reload with your changes. - Edit the markup examples within
components/$COMPONENT/docs.ymlandcomponents/$COMPONENT/docs/*.ymlaccordingly. The documentation will live reload with your changes.
Note: If you add dependencies in a component's package.json, be sure to re-run npm run bootstrap so they are linked appropriately.
- Copy the directory for a similar component from
components/and rename it for your new component. - Edit the
package.json, resetting the version number to1.0.0-alpha.0. - Edit the
dependencieswithin thepackage.jsonfile to use only the dependencies your component needs. All components rely on@spectrum-css/varsand@spectrum-css/component-builder, and most rely on@spectrum-css/icon. - Run
gulp devin the root of the project to begin developing - Edit
index.cssandskin.csswith dimensions and color properties respectively. - Edit
docs.ymlanddocs/*.ymlto add markup examples for each of the variants of your component.
Because we use scoped packages, before it can be published with Lerna, you must manually publish the new component as public:
cd components/newcomponent
npm publish --access=public
- If your component requires another component in order to render, it should be declared in both
devDependenciesandpeerDependencies.- The version range included in
peerDependenciesmust satisfy the version included indevDependencies. - If a component appears in
peerDependencies, it must also appear indevDependencies. - This goes for every class used to render the component; even if the class comes from a component that's a dependency of another component you already have a dependency on.
- For instance, if your component requires a button with an icon inside of it, you must explicitly include both
iconandbuttonin bothdevDependenciesandpeerDependencies.
- The version range included in
- If your component has an example that uses another component, but the component isn't required to render your component, it should be declared in
devDependenciesonly.- For instance, if your component is commonly used with a table and includes an example where it is used with a table, but doesn't require table to render itself, you should declare
tableindevDependenciesonly.
- For instance, if your component is commonly used with a table and includes an example where it is used with a table, but doesn't require table to render itself, you should declare
For example, actionbar gets its tokens from vars, and requires button, checkbox, icon, and popover to render, but also has an example where the component is used with a table. Its dependencies should be declared as follows:
{
"name": "@spectrum-css/actionbar",
"peerDependencies": {
"@spectrum-css/button": "^2.0.0",
"@spectrum-css/checkbox": "^2.0.0",
"@spectrum-css/icon": "^2.0.0",
"@spectrum-css/popover": "^2.0.0",
"@spectrum-css/vars": "^2.0.0"
},
"devDependencies": {
"@spectrum-css/button": "^2.0.0",
"@spectrum-css/checkbox": "^2.0.0",
"@spectrum-css/component-builder": "^1.0.0",
"@spectrum-css/icon": "^2.0.0",
"@spectrum-css/popover": "^2.0.0",
"@spectrum-css/table": "^2.0.0",
"@spectrum-css/vars": "^2.0.0"
}
}The release will error out if:
- A package is specified in
peerDependenciesthat does not appear indevDependencies - The version of a package is specified in
devDependenciessatisfy the range defined for that package inpeerDependencies
Any change to a component or a component's dependencies results in a release of that component and all associated bundles. Component releases cannot be done ala carte and must be done from the top-level, managed by lerna.
See Releasing for more information.