Thanks for contributing to the Cloud Four Pattern Library!
npm ci— to install dependenciesnpm start— to run a local instance of Storybook
npm run build— Builds CSS+JS for npm packagenpm run build-storybook— Creates a static storybook site build, for example for publishing the pattern library to Netlify
You can run npm run validate to run all of the checks that will be run in CI (except for building).
You can also run checks individually:
- Linters/formatters:
npm run lint(runs Prettier, ESLint, and Stylelint) - Tests:
npm run test(runs Jest tests) You can also runnpm run test:watchto run Jest in watch mode Note that tests will fail if you have not built the project. If you see tests failing with errors like "file not found indistfolder", try runningnpm run buildand then re-run the tests. - Typechecking
npm run type(runs TypeScript) You can also runnpm run type:watchto run TypeScript in watch mode
cloudfour.com-patterns
├── .github # GitHub workflows and templates
├── .storybook
│ ├── main.js # Settings for Storybook UI
│ └── preview.js # Settings for story previews
├── .style-dictionary
│ ├── config.json # Settings for design token processing
│ └── build.js # Design token build script
├── gulpfile.js
│ └── tasks/*.js # Complex build tasks
├── src
│ ├── **/*.scss # Styles (Sass)
│ ├── **/*.stories.mdx # Documentation (Storybook Docs)
│ ├── **/*.twig # Templates (Twig)
│ └── tokens/* # Design tokens (Style Dictionary)
├── .editorconfig # Low-level code consistency
├── .nvmrc # Node version (used by Netlify)
├── .svgo.yml # Inline SVG optimization settings
├── CONTRIBUTING.md # ⬅️ You are here!
├── README.md # Pattern library install instructions
├── netlify.toml # Netlify build settings
└── package.json # Project info and dependencies
Before you submit a PR, if that PR has changes that will affect consumers of this package, you should run npx changeset on your branch. It will ask you the scope of your changes, and it will ask you to describe them.
If you forget to run npx changeset, changeset-bot will pester you in your PR. It will provide a link you can use to create the changesets file from the GitHub interface.
Use snake_case for Twig template variables.
Follow the Symfony Twig Coding Standards for proper spacing, indentation, and variable guidelines.
This process happens automatically after any PR with a changeset is merged to main.
This is generally not necessary, but in case you need to manually publish a version:
git checkout maingit pull- Make sure you have a clean working tree (
git statusshould show no changes) git checkout -b release-X.Y.Z- Create a new release branch, whereX.Y.Zis the version number you're about to release.npm version [major | minor | patch]- This will bump the version number inpackage.jsonandpackage-lock.json. e.g.,npm version minorto bump from1.1.0to1.2.0.git pushyour branch.- Make a PR, get it approved, and merge your changes to
main. git checkout maingit pull- Make sure you have a clean working tree (
git statusshould show no changes) - Reinstall dependencies and run build:
npm ci && npm run preprocess && npm run build npm publish --access public- This will automatically install and compile everything, run linting, and publish
You can run npm publish --dry-run to see everything that would happen during publish, without actually publishing to the npm registry.
For most stories, we are able to generate a twig source code snippet for Storybook to display automatically. When stories use useEffect or other hooks, the source code snippet cannot be generated automatically, so the JS that was passed to <Story> is shown instead (there may be other cases where this happens as well). In those cases, you can manually pass the source code to <Story>:
import { makeTwigInclude } from '../../make-twig-include';
<Story
name="Story Name"
parameters={{
docs: { source: { code: makeTwigInclude('asdf', { foo: 'bar' }) } },
}}
>
{(args) => template(args)}
</Story>;This generates a source code snippet like this:
{% include 'asdf' with {
"foo": "bar"
} only %}