Skip to content

Commit

Permalink
docs: upgrade storybook, update doc structure and order
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdyman committed Jan 14, 2020
1 parent 9be371a commit 24c34e5
Show file tree
Hide file tree
Showing 14 changed files with 571 additions and 440 deletions.
4 changes: 0 additions & 4 deletions .storybook/addons.js

This file was deleted.

35 changes: 0 additions & 35 deletions .storybook/config.js

This file was deleted.

54 changes: 54 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const path = require('path');

module.exports = {
addons: [
'@storybook/addon-storysource',
'@storybook/addon-viewport',
'@storybook/addon-knobs',
'@storybook/addon-actions',
'@storybook/addon-links',
{
name: '@storybook/addon-docs',
options: {
configureJSX: true,
},
},
{
name: '@storybook/preset-typescript',
options: {
tsDocgenLoaderOptions: {
tsconfigPath: path.resolve(__dirname, '../tsconfig.json'),
propFilter: prop => {
// Filter out props from styled-components
if (
prop.name === 'as' ||
prop.name === 'ref' ||
prop.name === 'theme'
) {
return false;
}

if (prop.parent == null) {
return true;
}

// Filter outs props from react types
return (
prop.parent.fileName.indexOf('node_modules/@types/react') < 0
);
},
},
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname, '../example'),
path.resolve(__dirname, '../docs'),
],
},
},
],
stories: [
'../docs/docs/Intro.story.mdx',
'../docs/docs/**/*.story.(mdx|tsx)',
'../docs/demos/**/*.story.(mdx|tsx)',
],
};
13 changes: 13 additions & 0 deletions .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { addons } from '@storybook/addons';
import { create } from '@storybook/theming/create';

addons.setConfig({
showAddonsPanel: true,
panelPosition: 'bottom',
theme: create({
base: 'dark',
brandTitle: 'React Compare Slider',
brandUrl: 'https://github.com/nerdyman/react-compare-slider',
gridCellSize: 12,
}),
});
44 changes: 0 additions & 44 deletions .storybook/presets.js

This file was deleted.

6 changes: 6 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<style type="text/css">
body {
margin: 0;
padding: 0;
}
</style>
38 changes: 38 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks';
import { withKnobs } from '@storybook/addon-knobs';
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
import { addDecorator, addParameters } from '@storybook/react';
import { themes } from '@storybook/theming';

addDecorator(withKnobs);

addParameters({
docs: {
container: DocsContainer,
page: DocsPage,
},
options: {
showRoots: true,
storySort: (a, b) => {
if (a[0].includes('docs-')) {
if (a[0].includes('intro-')) {
return -1;
}

return 0;
}

return 1;
},
theme: {
...themes.dark,
appBorderRadius: 3,
colorSecondary: '#b464fa',
barSelectedColor: '#b464fa',
},
},
viewport: {
viewports: INITIAL_VIEWPORTS,
// defaultViewport: 'Initial',
},
});
25 changes: 25 additions & 0 deletions docs/blocks/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';

export const StoryContainer: React.FC<any> = ({ style, ...props }) => (
<div
style={{
minHeight: '100vh',
...style,
}}
{...props}
></div>
);

export const StoryNote: React.FC<any> = ({ style, ...props }) => (
<p
style={{
fontFamily: 'sans-serif',
padding: '0.5rem',
borderRadius: '0.25rem',
backgroundColor: 'rgba(0, 0, 0, 0.85)',
color: 'white',
...style,
}}
{...props}
/>
);
Loading

0 comments on commit 24c34e5

Please sign in to comment.