preview.jsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import styled from '@emotion/styled'
  2. import { useRef } from 'react'
  3. import useResizeObserver from 'use-resize-observer'
  4. import { GlobalStyles } from '@/styles'
  5. const Wrapper = styled.div`
  6. padding: 10px;
  7. height: calc(100vh - 20px);
  8. & > * + * {
  9. margin-left: 15px;
  10. }
  11. `
  12. const StylesWrapperDecorator = (styleFn) => {
  13. const ref = useRef(null)
  14. const { width, height } = useResizeObserver({ ref, box: 'border-box' })
  15. return (
  16. <Wrapper ref={ref}>
  17. <div style={{ position: 'absolute', fontSize: '12px', right: '4px', top: '4px' }}>
  18. {width}px x {height}px
  19. </div>
  20. <GlobalStyles />
  21. {styleFn()}
  22. </Wrapper>
  23. )
  24. }
  25. export const decorators = [StylesWrapperDecorator]
  26. export const parameters = {
  27. actions: { argTypesRegex: '^on[A-Z].*' },
  28. options: {
  29. storySort: (a, b) => (a.title === b.title ? 0 : a.id.localeCompare(b.id, undefined, { numeric: true })),
  30. },
  31. }
  32. export const argTypes = {
  33. to: { table: { disable: true } },
  34. className: { table: { disable: true } },
  35. onClick: { table: { disable: true } },
  36. onChange: { table: { disable: true } },
  37. as: { table: { disable: true } },
  38. icon: { table: { disable: true } },
  39. children: { table: { disable: true } },
  40. }