Senior Engineer
Statens Kartverk
esphen_
esphen
espen.dev
npm create react-app .
npx @storybook/cli init
npm run dev
import { ButtonHTMLAttributes } from 'react';
import StyledButton from './style';
export interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
/** This is a description of primary */
primary?: boolean;
size?: 'small' | 'medium' | 'large';
children?: React.ReactNode;
}
export const Button = ({
primary = false,
size = 'medium',
children,
...props
}: Props) => (
<StyledButton {...props} primary={primary} size={size}>
{children}
</StyledButton>
)
import { ComponentStory, ComponentMeta } from '@storybook/react';
import { Button } from "ui";
export default {
title: 'Example/Button',
component: Button,
} as ComponentMeta<typeof Button>;
const Template: ComponentStory<typeof Button> = (args) => (
<Button {...args} />
);
export const Primary = Template.bind({});
Primary.args = {
primary: true,
children: 'Button',
};
export const Secondary = Template.bind({});
Secondary.args = {
children: 'Button',
};
https://slides.com/esphen/komponentbasert-utvikling