Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #136 from 5app/try-out-storybook
Browse files Browse the repository at this point in the history
chore: Migrate from Docz to Storybook, #135
  • Loading branch information
diondiondion authored Jun 18, 2021
2 parents c45a57d + 3a406d2 commit 65fcc5e
Show file tree
Hide file tree
Showing 166 changed files with 29,735 additions and 84,413 deletions.
1 change: 0 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"plugins": [
"@babel/transform-react-jsx",
"@babel/proposal-object-rest-spread",
"@babel/proposal-class-properties",
"@babel/proposal-optional-chaining",
"@babel/proposal-nullish-coalescing-operator",
"babel-plugin-styled-components"
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
'5app',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'prettier'
'prettier',
],
parser: 'babel-eslint',
parserOptions: {
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist
node_modules
storybook-static
/test/coverage
.DS_Store

.docz/**
yarn-error.log
10 changes: 7 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
!/src
!/test/*.js
package-lock.json
CHANGELOG.md

*.html
*.scss
*.css
*.yml
37 changes: 37 additions & 0 deletions .storybook/GlobalStyles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {createGlobalStyle} from 'styled-components';

const GlobalStyles = createGlobalStyle`
* {
box-sizing: border-box;
}
*:focus:not(:focus-visible) {
outline: none;
}
*:focus:not(.focus-visible) {
outline: none;
}
html, body, div, span, h1, h2, h3, h4, h5, p, blockquote, pre, a, dl, dt, dd, ol, ul, li, fieldset, form, label, article, aside, header, footer, menu, nav, section, audio, video, figure, figcaption {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
}
input {
margin: 0;
padding: 0;
}
ul, ol {
list-style: none;
}
body {
font-family: 'Open Sans', sans-serif;
}
`;

export default GlobalStyles;
16 changes: 16 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
stories: [
'../src/**/*.stories.mdx',
'../src/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
{
name: '@storybook/addon-docs',
options: {
transcludeMarkdown: true,
},
},
],
};
6 changes: 6 additions & 0 deletions .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {addons} from '@storybook/addons';

addons.setConfig({
panelPosition: 'right',
initialActive: 'sidebar',
});
48 changes: 48 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';
import {Canvas} from '@storybook/addon-docs/blocks';

import 'focus-visible';

import ThemeSection from '../src/ThemeSection';
import theme from '../src/theme';

import GlobalStyles from './GlobalStyles';

export const decorators = [
Story => (
<ThemeSection name="page" baseTheme={theme}>
<GlobalStyles />
{Story()}
</ThemeSection>
),
];

export const parameters = {
actions: {argTypesRegex: '^on[A-Z].*'},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
options: {
storySort: {
order: ['base5-ui', 'Components'],
},
},
backgrounds: {
disable: true,
grid: {
disable: true,
},
},
docs: {
components: {
Canvas: ({children, ...props}) => (
<ThemeSection name="page" baseTheme={theme}>
<Canvas {...props}>{children}</Canvas>
</ThemeSection>
),
},
},
};
89 changes: 87 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,91 @@

[![Greenkeeper badge](https://badges.greenkeeper.io/5app/base5-ui.svg)](https://greenkeeper.io/)

Welcome to base5-UI, 5app's library of reusable React components. base5-UI's focus lies on providing easy-to-use base & layout components for building highly themeable pages.
Welcome to base5-ui, 5app's library of reusable React components. base5-ui's focus lies on providing easy-to-use base & layout components for building highly themeable pages.

[View the full Readme](https://5app.github.io/base5-ui)
## Installation

base5-ui is built on styled-components, so if you're not using it already, install it along with base5-ui.

```
npm i base5-ui styled-components
```

## Running the component library locally

base5-ui comes with its own documentation tool & development playground powered by [Storybook](https://storybook.js.org/). To check it out locally, clone this repo to your local machine, install its dependencies (`npm i`), and finally run the following command:

```
npm run storybook
```

The documentation environment should then open in your browser at http://localhost:6006, letting you browse all available components to inspect their API, read documentation and see usage examples.

## Using base5-ui

To use the components of base5-ui, your app needs to be wrapped in a `<ThemeSection>` that provides each component with global and local theme information.

A basic app setup using the default base5-ui theme looks like this:

```jsx
import React from 'react';
import ReactDOM from 'react-dom';

import ThemeSection from 'base5-ui/ThemeSection';
import Button from 'base5-ui/Button';

import theme from 'base5-ui/theme';

function App() {
return (
<ThemeSection name="page" baseTheme={theme}>
<Button>Hello world!</Button>
</ThemeSection>
);
}

const rootElement = document.getElementById('root');

ReactDOM.render(<App />, rootElement);
```

## Updating the repo

> Want to add/edit icons? Please follow the steps outlined in the [icons README](/src/icons/README.mdx) before continuing here.
To publish changes to the components in this repo, please follow these steps. The online docs will automatically be updated after the changes were merged to the master branch.

- Commit your changes using semantic versioning prefixes:
1. `fix:` or `refactor:` for a patch release (x.x.+1)
2. `feat:` for a minor release (x.+1.0)
3. Add `BREAKING CHANGE:` to the beginning of the commit message's body for a major release: +1.0.0)
4. Use `chore:` or `style:` for housekeeping tasks that don't require a release
- Submit a PR or push to the `master` branch

## Updating just the docs

If you did not make any changes to components and only want to update the docs in our online [component library](https://5app.github.io/base5-ui), just submit a PR or push to the `master` branch directly using a `docs:` prefix for the commit message.

## Tests

Execute `npm test` or `npm run test` to run the tests

Execute `npm run test:cover` to run the tests with coverage analysis.

- A summary report such as the following will be available in the terminal:

```
=============================== Coverage summary ===============================
Statements : 76.38% ( 524/686 )
Branches : 53.81% ( 120/223 )
Functions : 87.06% ( 148/170 )
Lines : 77.04% ( 520/675 )
================================================================================
Test Suites: 12 passed, 12 total
Tests: 3 skipped, 32 passed, 35 total
Snapshots: 0 total
Time: 3.818s
```

- A detailed html code analysis report will be available at `./test/coverage/index.html`
The detailed report provides a good insight on what to test and how well the component is tested.
11 changes: 0 additions & 11 deletions doczrc.js

This file was deleted.

8 changes: 0 additions & 8 deletions gatsby-node.js

This file was deleted.

10 changes: 8 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ module.exports = {
collectCoverageFrom: [
'**/*.{js}',
'!**/docz/**',
'!**/src-icons/**',
'!**/node_modules/**',
'!**/test/**',
],
coveragePathIgnorePatterns: ['/node_modules/', '/docz/', '/test/'],
modulePathIgnorePatterns: ['/node_modules/', '/docz/'],
coveragePathIgnorePatterns: [
'/node_modules/',
'/.storybook/',
'/.src-icons/',
'/test/',
],
modulePathIgnorePatterns: ['/node_modules/', '/.storybook/'],
};
Loading

0 comments on commit 65fcc5e

Please sign in to comment.