All Projects → airbnb → react-component-variations

airbnb / react-component-variations

Licence: MIT license
No description, website, or topics provided.

Programming Languages

javascript
184084 projects - #8 most used programming language

react-component-variations

⚠️ Warning: this project is still very alpha

This project is:

  • A format called "variations" for specifying React component examples and providing documentation for them.
  • Tools for finding, validating, and iterating over variations.

A variation looks like:

// ButtonVariationProvider.jsx

import React from 'react';
import Button from '../components/Button';

export default function ButtonVariationProvider({ action }) {
  return {
    component: Button,

    usage: 'Buttons are things you click on!',

    variations: [
      {
        title: 'Default',
        render: () => <Button onClick={() => action('onClick')}>click me!</Button>,
      },
      {
        title: 'Disabled',
        render: () => <Button disabled>Nope</Button>
      }
    ],
  };
}

We also have "consumers" that use the variation provider to perform tasks. Example consumers are:

  • Rendering variations in Storybook
  • Running in tests with Enzyme
  • Taking screenshots with Happo
  • Checking for accessibility violations with Axe

Contribution Guidelines:

  1. Fork this Repo
  2. Install dependencies by running npm install in the root of the project directory.
  3. To run lint and test run locally, in the project root run npm test. To run tests only, npm run tests-only.

Make sure new helpers and traversal functions have related tests.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].