Skip to content

Commit

Permalink
Add Storybook
Browse files Browse the repository at this point in the history
* add storybook
  • Loading branch information
sanusart authored Jul 28, 2023
1 parent e4f99b0 commit 41ce2e0
Show file tree
Hide file tree
Showing 32 changed files with 20,720 additions and 21,003 deletions.
47 changes: 27 additions & 20 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
{
"plugins": [
"plugins": [
"@emotion",
"@babel/plugin-proposal-class-properties",
[
"transform-react-remove-prop-types",
{
"mode": "remove",
"ignoreFilenames": ["node_modules"]
}
]
],
"presets": [
"minify",
[
"@babel/preset-env",
{
"loose": true
}
],
"@babel/preset-react"
]
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
],
[
"transform-react-remove-prop-types",
{
"mode": "remove",
"ignoreFilenames": [
"node_modules"
]
}
]
],
"presets": [
"minify",
[
"@babel/preset-env",
{
"loose": true
}
],
"@babel/preset-react"
]
}
2 changes: 2 additions & 0 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"node": "16",
"buildCommand": "build",
"sandboxes": ["react-dropdown-select-nzto7"]
}
21 changes: 21 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
const config = {
stories: ['./stories/*.mdx', './stories/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions'
],
framework: {
name: '@storybook/react-webpack5',
options: {}
},
docs: {
toc: true,
autodocs: true,
defaultName: 'Documentation',
story: { inline: true } // render the story in an iframe
// source: { type: 'code' } // forces the raw source code (rather than the rendered JSX).
}
};
export default config;
7 changes: 7 additions & 0 deletions .storybook/preview-body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- .storybook/preview-body.html -->

<style>
html, body {
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
}
</style>
29 changes: 29 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { DocsPage, Canvas } from '@storybook/addon-docs';
import React from 'react';

const preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
controls: { expanded: true },
matchers: {
color: /(background|color)$/i,
date: /Date$/
}
}
},
decorators: [
(storyFn) => (
<div
style={{
height: 200,
width: 400,
margin: '0 auto'
}}>
{storyFn()}
</div>
)
]
};

export default preview;
6 changes: 6 additions & 0 deletions .storybook/stories/Changelog.mdx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Meta } from '@storybook/addon-docs';
import Changelog from '../CHANGELOG.md';

<Meta title="Changelog" />

<Changelog />
24 changes: 24 additions & 0 deletions .storybook/stories/Select.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Canvas, Meta, Controls } from '@storybook/blocks';

import * as SelectStories from './Select.stories';

<Meta of={SelectStories} />


# Select

Customisable dropdown select for react

## Basic
<Canvas of={SelectStories.Basic} />

## Multi

<Canvas of={SelectStories.Multi} />

## Props

_Select_ has the following properties:

<Controls/>

26 changes: 26 additions & 0 deletions .storybook/stories/Select.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { Select } from '../../src';
import { optionsBase } from '../../docs/src/options';

const options = optionsBase(4);
const baseArgs = {
...Select.defaultProps,
options,
multi: false,
onChange: (values) => console.log(values)
};

export default {
title: 'react-dropdown-select',
component: Select,
parameters: {
docs: {
description: {
component: 'Basic select examples'
}
}
}
};

export const Basic = { args: baseArgs };
export const Multi = { args: { ...baseArgs, multi: true } };
1 change: 1 addition & 0 deletions .storybook/stories/assets/code-brackets.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .storybook/stories/assets/colors.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .storybook/stories/assets/comments.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .storybook/stories/assets/direction.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .storybook/stories/assets/flow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .storybook/stories/assets/plugin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 41ce2e0

Please sign in to comment.