Skip to content

Commit

Permalink
feat: add storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
fbwoolf authored and aulneau committed Jul 7, 2021
1 parent 5ac42de commit 06dd54e
Show file tree
Hide file tree
Showing 7 changed files with 6,485 additions and 2,135 deletions.
7 changes: 7 additions & 0 deletions .changeset/proud-gifts-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@stacks/ui': minor
'@stacks/ui-core': minor
'@stacks/ui-theme': minor
---

This adds storybook to the ui library!
17 changes: 17 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
stories: ['../packages/ui/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
babel: config => {
config.presets[2][1] = { runtime: 'classic' };
return config;
},
typescript: {
check: false,
checkOptions: {},
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: prop => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
},
},
};
10 changes: 10 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"@octokit/core": "3.5.1",
"@stacks/eslint-config": "1.0.9",
"@stacks/prettier-config": "0.0.8",
"@storybook/addon-actions": "^6.2.9",
"@storybook/addon-essentials": "^6.2.9",
"@storybook/addon-links": "^6.2.9",
"@storybook/react": "^6.2.9",
"@types/react": "17.0.11",
"@types/react-dom": "17.0.8",
"eslint": "7.29.0",
Expand Down Expand Up @@ -49,7 +53,9 @@
"changeset:version": "changeset version",
"release": "yarn build && yarn changeset:publish",
"version": "lerna bootstrap",
"postinstall": "patch-package"
"postinstall": "patch-package",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"workspaces": [
"packages/**"
Expand Down
3 changes: 2 additions & 1 deletion packages/ui-theme/src/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const _typography = {
fonts: {
heading:
'"Open Sauce", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
body: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
body:
'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
mono: 'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace',
},
fontSizes: [
Expand Down
34 changes: 34 additions & 0 deletions packages/ui/src/button/button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { Story, Meta } from '@storybook/react';

import { Button } from './index';
import type { ButtonProps } from './types';

export default {
title: 'Button',
component: Button,
} as Meta;

const Template: Story<ButtonProps> = args => {
return <Button {...args} height="40px" width="120px" />;
};

// Modes
export const Primary = Template.bind({});
Primary.args = {
mode: 'primary',
children: 'Primary',
variant: 'solid',
};

export const Secondary = Template.bind({});
Secondary.args = {
mode: 'secondary',
children: 'Secondary',
};

export const Tertiary = Template.bind({});
Tertiary.args = {
mode: 'tertiary',
children: 'Tertiary',
};
Loading

0 comments on commit 06dd54e

Please sign in to comment.