First, on behalf of the core maintainers, I'd like to thank you for wanting to contribute and make the user experience for your end-users better and improve the developer experience of this library. 👍🎉 -- @interactivellama
If you are adding or changing component props, the first step is to propose the feature so that others have time to comment on it. Please submit a props proposal such as this one for Dueling Picklist as an issue.
- Setup
- Adding a new prop
- How to add a new component
- Contributing Guidelines
- The review process
- Testing the documentation site (internal)
- Fork this repository (button in upper right). Install git and clone your fork locally with
git clone [email protected]:[YOUR-USER]/design-system-react.git
. This library only supports use ofgit-bash
in Windows. The default command prompt may not work. - Create a topic branch locally such as
menu-alignment-fix
. - Install Node and NPM.
npm install
to install development dependencies. npm start
to start Storybook. View stories at http://localhost:9001. Modify the source code to update component stories in the sidebar.- Read the Codebase Overview to learn concepts and best practices for the codebase and to confirm contribution is within project scope.
- This library is open to
data
,ref
,style
, andclassName
on any element within reason, but especially open to it for the “primary part of a component” such as form elements such asinput
or a clickable elements such asbutton
, since these are often used for testing purposes or form submission. This is probably a better way to write unit tests, anyway, since SLDS class changes are not considered breaking changes.ref
callbacks should be within anobject
named refs with typically a key name of the HTML tag name. These should be tested with a Mocha callback.style
props should bestyle[SUFFIX]
and be tested with a Jest DOM snapshot by adding a Story to Storybook.className
props should beclassName[SUFFIX]
and bePropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string])
and be tested with a Jest DOM snapshot by adding a Story to Storybook.
- Create a new issue or add to an existing one.
- List out all public props, so that props can be consistent across the library. Here is an example. You are proposing an API that hopefully will never have to be changed.
- Build out the component file structure
- Add a new folder to
/components
withindex.jsx
. All component files in this folder are public. Non-public subcomponents should be in aprivate
subfolder.
- Add a new folder to
- Connect the newly created files
- Add a
component.json
file beneath the new folder. This will serve as the component's primary configuration file and looks like the below example:{ "component": "accordion", "status": "prod", "display-name": "Accordions", "classKey": "Accordion", "SLDS-component-path": "/components/accordion", "dependencies": [ { "component": "panel", "classKey": "AccordionPanel" } ], "site-stories": [ "/__examples__/base.jsx" ], "url-slug": "accordions" }
- Add the component's name to
/utilities/constants.js
- Create dev storybook stories and documentation site examples in
/components/[COMPONENT]/__examples__/
. - Add Storybook examples in
/components/[COMPONENT]/__docs__/storybook-stories.jsx
. - List examples to be used for the documentation site under the
"site-stories"
array incomponent.json
as shown in the above example. - Review the tests readme
- Create snapshot tests from Storybook examples. Most props that don't involve user events can be tested here instead of with Mocha.
npm run test:dom-snapshot -- --watchAll
will run DOM snapshot tests interactively and watch changed files.npm run test:dom-snapshot:update
will update snapshots. - Add callback prop tests in Mocha test framework to
/components/[COMPONENT]/__tests__/
. Mocha tests are a last resort and should not be used for simple markup queries. These tests can be viewed athttp://localhost:8001
- Add a
- All components should have a comment description of the component before the class declaration in the source code. This should be copied from the subtitle or "lead" of the SLDS website component page. All props should have
propType
with a prop description comment before it that will be used on the documentation site.npm test
will audit that these source code comments exist or warn withcomponents/component-docs.json has an empty string in it
error if they do not. - Run
npm run prepare-components
in the terminal and look over the changes afterwards. (NOTE: this is also ran first when runningnpm test
) This will automatically perform the following:- Adds public component exports to
/components/index.js
if not already present - Generates updated
/components/site-stories.js
file with examples listed in"site-stories"
section ofcomponent.json
for use in the documentation site - Copies contents of
component.json
into the"components"
section ofpackage.json
- Adds public component exports to
- Push to your username's forked repository.
- Submit a well-documented pull request targeting
master
from your forked repository. GitHub pull requests should have a descriptive title, a brief summary, @mention several relevant people to review the code, add helpful GitHub comments on lines where you have questions or concerns. All contributors must sign a Contributor License Agreement. - For large additions, make sure your tests pass, then mention @interactivellama and request a view, and we'll review your code, suggest any needed changes, and hopefully merge it in soon. Thank you!
- Are you a first-time contributor? If you would like a simple task to start out with, you might consider these issues or run
npm run lint
and fix a few warnings. - UX pattern / design must exist in SLDS. Components in the process of being added to SLDS will be considered as prototypes.
- All new props and components need tests. Please review the testing readme
- Contributions of components with a subset of SLDS variants will be considered. Please consider your architecture in view of the other variants and create an issue before starting just to be certain.
- Follow this library's
prettier
(code style) andeslint
(code quality) settings.npm run lint:fix
will run Prettier and write style changes to your files.- You can enable this behavior at save in your editor, too. For instance, in Visual Studio Code, run the prettier extension and set
"editor.formatOnSave": true
andprettier.eslintIntegration: true
.
- You can enable this behavior at save in your editor, too. For instance, in Visual Studio Code, run the prettier extension and set
- If you are adding a feature, add a story to the React Storybook that uses your feature, so that reviewers can test it.
- Add enough Storybook stories and testing examples to show use of all component prop and values--if they are enumerated. All examples that are present for a component in the SLDS website should be created as a Storybook story and imported into the documentation site examples.
- Prop description tables on the documentation site are generated from
propType
comments within the component. Usenpm run build:docs
to confirm comment compatibility. Introductory component descriptions are generated from the comment directly before the component declaration with react-docgen. - All props descriptions should have a Tested with snapshot testing. or Tested with Mocha framework. notice in them.
- Read through the modified/added code in the pull request.
git clone
this repository. Pull down the pull requested branch. It will be within the contributor's forked repository. For instance,git checkout -b interactivellama-data-table-width master
thengit pull [email protected]:interactivellama/design-system-react.git data-table-width
. You could also create an additional remote and pull down the branch directly.- Run
npm install
andnpm start
. - Review the appropriate Storybook stories at
http://localhost:9001/
. - Review tests. Open
http://localhost:8001/
and confirm that tests are passing in your browser. - Compare component markup to SLDS markup. Reviewing the snapshot strings is the easiest way. Add year-first date and commit SHA to
last-slds-markup-review
in package.json and push to pull request branch. - Request a review of the new component/feature by the Salesforce UX Accessibility Team. Add year-first review date, and commit SHA,
last-accessibility-review
, topackage.json
and push to pull request branch.{ "component": "", "status": "prod", "display-name": "", "last-accessibility-review": { "date-iso-8601": "2017/12/31", "commit-sha": "" }, "last-slds-markup-review": { "date-iso-8601": "2017/12/30", "commit-sha": "" }, "SLDS-component-path": "" },
- While the contributor's branch is checked out, run
npm run local-update
within locally cloned site repo to confirm the site will function correctly at the next release. This will also build the bundle (npm run dist
) and use the bundle in the documentation site and confirm that the bundle works.
- Pull down the documentation site (currently private) and place in the same parent folder as this library:
git clone [email protected]:salesforce-ux/design-system-react-site.git
and runnpm install
. - Run
npm run local-update
from withindesign-system-react-site
to build, copy, and serve a local version of this library into the site. You should be able to now view the updated site athttp://localhost:8080/
and resolve any issues with updated documentation.