Skip to content

Commit

Permalink
Merge pull request #122 from HelixDesignSystem/JSX-docs-view
Browse files Browse the repository at this point in the history
Add JSX docs view to all components
  • Loading branch information
100stacks committed Dec 1, 2020
2 parents d4d839a + ff951d0 commit b02ce0d
Show file tree
Hide file tree
Showing 24 changed files with 307 additions and 140 deletions.
2 changes: 2 additions & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { configure, addDecorator, setAddon } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';
import HelixUI from 'helix-ui';
import 'helix-ui/dist/css/helix-ui.min.css';
import { jsxDecorator } from 'storybook-addon-jsx';

addDecorator(jsxDecorator);
addDecorator(withKnobs);

// Requires require.context from Webpack
Expand Down
1 change: 1 addition & 0 deletions .storybook/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import '@storybook/addon-knobs/register';
import '@storybook/addon-actions/register';
import '@storybook/addon-viewport/register';
import '@storybook/addon-options/register';
import 'storybook-addon-jsx/register';

addons.setConfig({
theme: helixTheme,
Expand Down
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
A React wrapper of the [Helix UI Webcomponents Library](https://github.com/HelixDesignSystem/helix-ui/)

🚀 Alpha release is [here](https://helix-react.netlify.app)! Check out how to get started below! 🌻


</div>

<hr />
Expand All @@ -25,7 +23,6 @@
- [Helix UI Webcomponent Snippet From Documentation](#helix-ui-webcomponent-snippet-from-documentation)
- [Our Implementation](#our-implementation)
- [Guiding Principles](#guiding-principles)
- [Storybook](#-storybook)
- [Issues](#issues)
- [🐛 Bugs](#-bugs)
- [💡 Feature Requests](#-feature-requests)
Expand Down Expand Up @@ -110,6 +107,7 @@ Follow the [Getting Started with HelixUI](https://helixdesignsystem.github.io/he
</footer>
</Modal>
```
[See Helix-React Storybook docs for more examples](https://helix-react.netlify.app/)

## Guiding Principles

Expand All @@ -118,27 +116,6 @@ Each wrapper corresponds with a component listed on the [Helix UI documentation]

![helix-ui-documentation](https://user-images.githubusercontent.com/22566333/82083617-07f70700-96b8-11ea-9581-da1796737e52.png)

## 📚 Storybook
[Storybook](https://storybook.js.org/) is an open source tool for developing UI components
in isolation for React, Vue, and Angular.
You can use this as a playground for all our components.

1. Install Dependencies

```bash
yarn install
```

2. Run Storybook

```bash
npm start
```
The script should automatically open Storybook in your browser, but you can always navigate to `http://localhost:6006/?path=/story`

3. Play Around
<img width="639" alt="Screen Shot 2020-05-15 at 2 32 35 PM" src="https://user-images.githubusercontent.com/22566333/82084224-f5c99880-96b8-11ea-92e2-403b3f4378db.png">

## Issues

_Looking to contribute? Look for the [Good First Issue][good-first-issue]
Expand All @@ -161,6 +138,27 @@ a 👍. This helps maintainers prioritize what to work on.

For questions related to using the library, please file an issue on GitHub.

## 📚 Setting up a Local Dev Environment
[Storybook](https://storybook.js.org/) is an open source tool for developing UI components
in isolation for React, Vue, and Angular.
You can use this as a playground for all our components.

1. Install Dependencies

```bash
yarn install
```

2. Run Storybook

```bash
npm start
```
The script should automatically open Storybook in your browser, but you can always navigate to `http://localhost:6006/?path=/story`

3. Play Around
<img width="639" alt="Screen Shot 2020-05-15 at 2 32 35 PM" src="https://user-images.githubusercontent.com/22566333/82084224-f5c99880-96b8-11ea-92e2-403b3f4378db.png">

## Contributors

Thanks goes to these people:
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@
"husky": "^4.2.5",
"microbundle": "^0.12.3",
"prettier": "^2.0.4",
"prop-types": "^15.7.2",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"prop-types": "^15.7.2"
"storybook-addon-jsx": "^7.3.4"
},
"dependencies": {
"use-onclickoutside": "^0.3",
"classnames": "^2.x"
"classnames": "^2.x",
"use-onclickoutside": "^0.3"
},
"peerDependencies": {
"helix-ui": "^0.24.0",
Expand Down
11 changes: 8 additions & 3 deletions src/Alert/stories.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { addParameters, storiesOf } from '@storybook/react';
import { boolean, select, text } from '@storybook/addon-knobs/react';
import Alert from './index';
import { action } from '@storybook/addon-actions';
import { callback } from '../storyUtils';

addParameters({
jsx: { skip: 0 },
});

const TYPES = {
info: 'info',
Expand All @@ -24,8 +29,8 @@ storiesOf('Alert', module).add('All Knobs', () => {
{...(status && { status })}
{...(persist && { persist })}
{...(type && { type })}
onDismiss={action('onDismiss')}
onSubmit={action('onSubmit')}
onDismiss={callback(action('onDismiss'))}
onSubmit={callback(action('onSubmit'))}
>
{content}
</Alert>
Expand Down
6 changes: 5 additions & 1 deletion src/Breadcrumb/stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { addParameters, storiesOf } from '@storybook/react';
import Breadcrumb from './index';

addParameters({
jsx: { skip: 0 },
});

storiesOf('Breadcrumb', module)
.add('Multiple Breadcrumbs', () => {
return (
Expand Down
6 changes: 5 additions & 1 deletion src/Button/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import Button from './';
import { Icons } from '../Icon';
import React from 'react';
import centered from '@storybook/addon-centered/react';
import { storiesOf } from '@storybook/react';
import { addParameters, storiesOf } from '@storybook/react';
import { boolean, select, text } from '@storybook/addon-knobs/react';

addParameters({
jsx: { skip: 2 },
});

const SIZES = {
small: 'Small',
'': 'Medium',
Expand Down
9 changes: 6 additions & 3 deletions src/Checkbox/stories.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';
import { action } from '@storybook/addon-actions';
import { boolean, text } from '@storybook/addon-knobs/react';
import { storiesOf } from '@storybook/react';

import { addParameters, storiesOf } from '@storybook/react';
import Checkbox from './index';
import { callback } from '../storyUtils';

addParameters({
jsx: { skip: 0 },
});
storiesOf('Checkbox', module).add('All Knobs', () => {
let label = text('label', 'check me out');
let checked = boolean('checked', false);
Expand All @@ -19,7 +22,7 @@ storiesOf('Checkbox', module).add('All Knobs', () => {
{...(indeterminate && { indeterminate })}
{...(required && { required })}
{...(label && { label })}
onChange={action('onChange')}
onChange={callback(action('onChange'))}
/>
);
});
11 changes: 7 additions & 4 deletions src/ChoiceTile/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import React from 'react';
import { action } from '@storybook/addon-actions';
import { optionsKnob as options } from '@storybook/addon-knobs';
import { boolean, select, text } from '@storybook/addon-knobs/react';
import { storiesOf } from '@storybook/react';

import { addParameters, storiesOf } from '@storybook/react';
import ChoiceTile from './index';
import { getShortText } from '../storyUtils';
import { callback, getShortText } from '../storyUtils';

addParameters({
jsx: { skip: 1 },
});

const SIZES = {
small: 'small',
Expand Down Expand Up @@ -45,7 +48,7 @@ storiesOf('Choice Tile', module).add('All Knobs', () => {
{...(size && { size })}
icon={icon}
name="choiceTileDemo"
onChange={action('onChange')}
onChange={callback(action('onChange'))}
style={{ width: 200, float: 'left' }}
title={title || defaultTitle}
>
Expand Down
13 changes: 8 additions & 5 deletions src/Drawer/stories.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React from 'react';
import { action } from '@storybook/addon-actions';
import { boolean, select, text } from '@storybook/addon-knobs/react';
import { storiesOf } from '@storybook/react';

import { addParameters, storiesOf } from '@storybook/react';
import Drawer from './index';
import Button from '../Button';
import Div from '../Div';
import { getLongText } from '../storyUtils';
import { callback, getLongText } from '../storyUtils';

addParameters({
jsx: { skip: 0 },
});

const SIZES = {
small: 'small',
Expand Down Expand Up @@ -34,8 +37,8 @@ storiesOf('Drawer', module).add('All Knobs', () => {
<Drawer
{...(open && { open })}
{...(size && { size })}
onOpen={action('onOpen')}
onClose={action('onClose')}
onOpen={callback(action('onOpen'))}
onClose={callback(action('onClose'))}
id="drawer-id"
>
{<header>{header || defaultHeader}</header>}
Expand Down
6 changes: 5 additions & 1 deletion src/Icon/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React from 'react';
import Icon, { Icons } from './';
import centered from '@storybook/addon-centered/react';
import { select } from '@storybook/addon-knobs/react';
import { storiesOf } from '@storybook/react';
import { addParameters, storiesOf } from '@storybook/react';

addParameters({
jsx: { skip: 2 },
});

storiesOf('Icon', module)
.addDecorator(centered)
Expand Down
22 changes: 12 additions & 10 deletions src/Modal/stories.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { addParameters, storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { boolean, select, text } from '@storybook/addon-knobs/react';
import Modal from './index';
import Div from '../Div';
import Button from '../Button';
import { getLongText } from '../storyUtils';
import { callback, getLongText } from '../storyUtils';

addParameters({
jsx: { skip: 0 },
});

const SIZES = {
small: 'small',
Expand All @@ -23,20 +27,18 @@ storiesOf('Modal', module).add('All Knobs', () => {
const smallText =
'This is the body of a demo modal. Interaction with content behind this modal cannot take place until this modal is closed.\n';
const longText = [1, 2, 3, 4, 5].map(() => <p>{getLongText()}</p>);
const defaultFooter = (
<>
<Button variant="primary">Confirm</Button>
<Button variant="tertiary">Cancel</Button>
</>
);
const defaultFooter = [
<Button variant="primary">Confirm</Button>,
<Button variant="tertiary">Cancel</Button>,
];

return (
<Modal
{...(open && { open })}
{...(size && { size })}
open={open}
onOpen={action('onOpen')}
onClose={action('onClose')}
onOpen={callback(action('onOpen'))}
onClose={callback(action('onClose'))}
>
{header && (
<header>
Expand Down
11 changes: 8 additions & 3 deletions src/Pill/stories.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import React from 'react';
import { action } from '@storybook/addon-actions';
import { boolean, text, select } from '@storybook/addon-knobs/react';
import { storiesOf } from '@storybook/react';
import { addParameters, storiesOf } from '@storybook/react';
import Pill from './index';
import Status from './Status';
import { callback } from '../storyUtils';

addParameters({
jsx: { skip: 0 },
});

storiesOf('Pill', module)
.add('All Knobs', () => {
let persist = boolean('persist', false);
let pillText = text('pill text', 'status: unicorns!');
return (
<Pill onDismiss={action('onDismiss')} {...(persist && { persist })}>
<Pill onDismiss={callback(action('onDismiss'))} {...(persist && { persist })}>
{pillText}
</Pill>
);
Expand All @@ -20,7 +25,7 @@ storiesOf('Pill', module)
let pillText = text('pill text', 'default');
let variant = select('variant', ['default', 'grey', 'purple', 'subdued']);
return (
<Status variant={variant} {...(filled && { filled })}>
<Status variant={variant || ''} {...(filled && { filled })}>
{pillText}
</Status>
);
Expand Down
Loading

0 comments on commit b02ce0d

Please sign in to comment.