Whiting Story

import React from 'react'
import './Center.sass'

const Center = ({ children, ...restProps }) => {
  return <div className="center">{children}</div>
}

export default Center

컨테이너 역할을 하는 Center 컴포넌트를 생성 후 버튼 스토리 컴포넌트에 적용한다.

export const RedButton = () => (
  <Center>
    <Button2 red>Red</Button2>
  </Center>
)

위의 방법처럼 직접적으로 추가할 수 있고 아래 처럼 Decorators을 사용해서 한번에 적용할 수 있다.

import React from 'react'
import Button2 from './Button2'
import Center from '../Center/Center'

export default {
  title: 'Form/Button2',
  component: Button2,
  decorators: [(story) => <Center>{story()}</Center>],
}

export const Primary = () => <Button2 primary>Primary</Button2>
가운데 정렬이 된다.

Args

args 를 사용해서 전달하려는 속성을 객체로 한 번에 전달 할 수있다.

스토리 묶기

Button 컴포넌트와 Input 컴포넌트를 같이 사용한다.

생성한 컴포넌트를 같이 사용할 수 있다.

Last updated

Was this helpful?