Skip to content

Commit

Permalink
add storybook components
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kordonets authored and DaleMcGrew committed Dec 9, 2023
1 parent 4f1c30b commit f58e5ef
Show file tree
Hide file tree
Showing 31 changed files with 999 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
const config = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-onboarding",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-webpack5",
options: {
builder: {
useSWC: true,
},
},
},
docs: {
autodocs: "tag",
},
};
export default config;
14 changes: 14 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @type { import('@storybook/react').Preview } */
const preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
17 changes: 13 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/js/common/components/Style/Colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const colors = {
primary: '#0834CD',
primaryHover: '#09288A',
secondaryHover: '#F5F7FD',
darkGrey: '#454F69',
middleGrey: '#8C92A2',
grey: '#AEB2BE',
lightGrey: '#E5E6EA',
white: '#ffffff',
};

export default colors;
50 changes: 50 additions & 0 deletions src/js/common/stories/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// import React from 'react';
// import PropTypes from 'prop-types';
// import './button.css';

// /**
// * Primary UI component for user interaction
// */
// export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
// const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
// return (
// <button
// type="button"
// className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
// style={backgroundColor && { backgroundColor }}
// {...props}
// >
// {label}
// </button>
// );
// };

// Button.propTypes = {
// /**
// * Is this the principal call to action on the page?
// */
// primary: PropTypes.bool,
// /**
// * What background color to use
// */
// backgroundColor: PropTypes.string,
// /**
// * How large should the button be?
// */
// size: PropTypes.oneOf(['small', 'medium', 'large']),
// /**
// * Button contents
// */
// label: PropTypes.string.isRequired,
// /**
// * Optional click handler
// */
// onClick: PropTypes.func,
// };

// Button.defaultProps = {
// backgroundColor: null,
// primary: false,
// size: 'medium',
// onClick: undefined,
// };
88 changes: 88 additions & 0 deletions src/js/common/stories/Button.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import React from 'react';
import styled from 'styled-components';
import Button from '../../components/Buttons/BaseButton';

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
export default {
title: 'Example/Button',
component: Button,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
layout: 'centered',
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
// More on argTypes: https://storybook.js.org/docs/api/argtypes
// argTypes: {
// backgroundColor: { control: 'color' },
// },
args: {
primary: true,
},
};

export const Primary = {
args: {
primary: true,
label: 'Button',
},
};

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const AllButtons = (args) => (
<ButtonContainer>
<Button {...Primary.args} primary size="large" label="Primary Large Disabled Button" />
<Button {...Primary.args} primary={false} size="large" label="PrimaryLarge Disabled Button" />
<Button {...Primary.args} primary label="Primary Medium Button" />
<Button {...PrimaryDisabled.args} primary={false} label="Primary Medium Disabled Button" />
<Button {...Primary.args} primary size="small" label="Primary Small Button" />
<Button {...PrimaryDisabled.args} primary={false} size="small" label="Primary Small Disabled" />
<Button {...Secondary.args} secondary label="Secondary Button" />
</ButtonContainer>
);

export const PrimaryDisabled = {
args: {
primary: false,
label: 'Button',
},
};

export const Secondary = {
args: {
secondary: true,
label: 'Button',
},
};

export const Large = {
args: {
primary: true,
size: 'large',
label: 'Button',
},
};

export const Medium = {
args: {
primary: true,
size: 'medium',
label: 'Button',
},
};

export const Small = {
args: {
primary: true,
size: 'small',
label: 'Button',
},
};

const ButtonContainer = styled.div`
display: flex;
align-items: center;
justify-content: center;
gap: 34px;
flex-direction: column;
`;
Loading

0 comments on commit f58e5ef

Please sign in to comment.