-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3. Create first atomic component #3
Milestone
Comments
Example story file: // Button.stories.ts|tsx
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import Button from './Button';
export default {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
argTypes: {
variant: {
control: 'select',
options: [
'default',
'primary',
'success',
'info',
'warning',
'danger',
'dark',
],
},
size: { control: 'select', options: ['sm', 'md', 'lg', 'xl'] },
disabled: { control: 'boolean' },
},
args: {
variant: 'default',
size: 'md',
disabled: false,
children: 'I am a button',
},
} as ComponentMeta<typeof Button>;
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;
export const Default = Template.bind({});
export const Disabled = Template.bind({});
Disabled.args = {
disabled: true,
};
export const Primary = Template.bind({});
Primary.args = {
variant: 'primary',
};
export const PrimaryDisabled = Template.bind({});
PrimaryDisabled.args = {
variant: 'primary',
disabled: true,
};
export const Small = Template.bind({});
Small.args = {
size: 'sm',
};
export const Medium = Template.bind({});
Medium.args = {
size: 'md',
};
export const Large = Template.bind({});
Large.args = {
size: 'lg',
};
export const ExtraLarge = Template.bind({});
ExtraLarge.args = {
size: 'xl',
};
|
You may run into issues when installing storybook.
{
"type": "commonjs"
}
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
{
name: '@storybook/addon-postcss',
options: {
postcssLoaderOptions: {
implementation: require('postcss'),
},
},
},
] Last thing you will need to do is go to Good luck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
feature/mvp
has changed on theremote
(origin/feature/mvp
) because you merged your last pull request, and you will need to sync it with your localfeature/mvp
, google itfeature/mvp
that you will calldevelop/btn-component
components
, its where you will put all your reusable componentspackage.json
to easily run it from terminalButton.tsx
component, Style it using Tailwind=> https://www.figma.com/file/iGqblG6oUcIuLDnvcoltfR/Foodie-collection?node-id=1%3A4
forwarding Refs
- you want to use it in this component as you are actually just creating a whole new<button>
that is supposed to work like a native one=> https://reactjs.org/docs/forwarding-refs.html
Button.stories.tsx
, the component should handle passed mouse events and native HTML attributes, like[type]
or[disabled]
develop/btn-component
->feature/mvp
The text was updated successfully, but these errors were encountered: