Development

Pinterest web engineers can visit the internal Gestalt documentation.

Set up your laptop

Set up your Gestalt repository

  • Clone the repo: Fork the Gestalt repo and work off your forked repo, not the pinterest/gestalt repo.
  • Once forked, clone to your local machine using the SSH option
git clone git@github.com:<YOUR_USERNAME>/gestalt.git
  • Use the correct Node.js version to setup the environment locally
cd gestalt && nvm use
If the node version isn't available, you will need to install it.
  • Install project dependencies. Do not run npm install because it will create a package-lock.json file (and also takes considerably longer).
yarn
  • Add pinterest/gestalt as a remote upstream (you'll only need to do this once).
git remote add upstream git@github.com:pinterest/gestalt.git
  • Check your remote configuration
git remote -v
// origin    git@github.com:<YOUR_USERNAME>/gestalt.git (fetch)
// origin    git@github.com:<YOUR_USERNAME>/gestalt.git (push)
// upstream    git@github.com:pinterest/gestalt.git (fetch)
// upstream    git@github.com:pinterest/gestalt.git (push)

Set up Visual Studio Code

  • Open the new /gestalt folder with VS Code.
  • Install the suggested VS Code extensions including vs code-stylelint to lint CSS files.
  • If you want to automatically launch the docs when you open VS Code:
    • In VS Code type CMD+Shift+p
    • Search and select Tasks: "Manage Automatic Tasks in Folder"
    • Select Allow "Automatic Tasks in Folder"
    • Relaunch VS Code

Run the Gestalt documentation server

Whenever you make changes to Gestalt, please test them out locally before making a PR.

To start the documentation server, run yarn start, which will automatically open the docs in a new browser tab.
If that tab doesn't launch automatically, navigate to http://localhost:8888

Create a pull request

  • Rebase your local master branch
git fetch upstream
git rebase upstream/master
  • Create an checkout a branch. Replace the text <feature-branch> with your branch name
git checkout -b <feature-branch> upstream/master
  • Time to make changes to Gestalt! If you are introducing a new component, run the scaffolding command to generate the necessary files. Replace ‘ComponentName‘ with the name of your component.
yarn generate ComponentName
  • Any subsequent component changes might require the following actions.

    • Run unit tests
    yarn jest -u
    
    yarn playwright:test accessibility/
    
    # Start the documentation server (required for updating macOS snapshots)
    yarn start
    #
    # Update macOS snapshots
    yarn playwright:test visual-test/ --update-snapshots
    
    • In order to update the Linux snapshots in the tests, you must build a docker file and then run docker.
    # Build the docker container (only need to do this once)
    yarn docker:build
    #
    # Update the linux snapshots
    yarn docker:run
    
    • Update CSS flow types
    yarn run flow-generate:css
    
    • If you are introducing breaking changes, create a codemod to help users migrate between versions.
    yarn run flow-generate:css
    
  • Commit the changes to your branch. Follow naming conventions for the PR <Component>: <Commit Change Description>

  • When you are done, push your branch up.

git add .
git commit -am "Component: Commit Change Description"
git push -f origin HEAD
  • Go to https://github.com/pinterest/gestalt. A new banner will be displayed, click on 'Compare & Create Pull Request'.

  • Add useful summary and screenshots. We provide a template for the summary to make sure you include all necessary information.

  • Click on Create Draft Pull Request to create your PR. Once you are done committing changes to it, and all the CI tests have passed, click the "Ready for Review" button.

Keeping the PR as a draft until it is ready for review reduces the number of unneeded notifications for maintainers
If you are a Pinterest employee, please let us know on Slack (#gestalt-web) that your PR is ready for review.
  • Ensure checks pass on your Pull Request - having the "Require Semver / Test (pull_request)" check fail is expected, because a Gestalt maintainer needs to add a correct semver label. Read our release and versioning guidelines.

  • After a Gestalt maintainer adds a correct semver label and approves a Pull Request, the PR will be ready to merge. Coordinate with the reviewer to determine when the PR should be merged.

My pull request fails on "Semver / Require Label (pull_request)", how do I fix it?

Nothing you can do to fix it.

A Gestalt Core maintainer will add a semver label (patch release / minor release / major release) when reviewing a PR.

Guidelines

Scope of work

When pushing new changes to GitHub, your PR title should be aligned with the scope of your work. If your goal was to change the default color of a component, keep the scope of changes to that specific task and word the title to exactly reflect those changes.

Changes not allowed

Do not use the following CSS style properties:

  • line-height: Property in CSS that controls the space between lines of text. Not defining a line-height allows the browser to determine line-height based on language which prevents localization issues.

  • height/width: Height & width are CSS properties that can be used for determining the size of static assets such as an icon size. However, components that contain text data should not fix the height & width of the component to prevent incorrect styling under different cases such as localization, longer texts, etc. Consider other alternatives such as padding to define different component sizes.

Avoid:

  • Boolean props: For example, instead of isRTL: boolean or isStart: boolean or isEnd: boolean, use more declarative props such as layoutDirection: rtl | ltr or role: startInput | endInput.

Technical Design Documents

Before starting coding a new component, you must first detail the component specifications in Technical Design Documents (TDD). You can find the TDD template here.

RFCs

Find the RFCs (request for comments) process and repository here.