modal.stories.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import type { Meta, StoryObj } from '@storybook/react-webpack5'
  2. import { figmaDesignUrl } from './../../../.storybook/utils/figma-design-url'
  3. import {
  4. OLModal,
  5. OLModalHeader,
  6. OLModalBody,
  7. OLModalFooter,
  8. OLModalTitle,
  9. } from '@/shared/components/ol/ol-modal'
  10. import OLButton from '@/shared/components/ol/ol-button'
  11. type Story = StoryObj<typeof OLModal>
  12. export const Default: Story = {
  13. args: {
  14. title: 'Heading',
  15. children: (
  16. <p>
  17. Always use the modal actions in the footer and use descriptive words for
  18. them.
  19. </p>
  20. ),
  21. footer: (
  22. <>
  23. <OLButton variant="secondary">Cancel</OLButton>
  24. <OLButton variant="primary">Primary</OLButton>
  25. </>
  26. ),
  27. },
  28. parameters: figmaDesignUrl(
  29. 'https://www.figma.com/design/V7Ogph1Ocs4ux2A4WMNAh7/Overleaf---Components?m=auto&node-id=3488-82657&m=dev'
  30. ),
  31. }
  32. export const Informative: Story = {
  33. parameters: figmaDesignUrl(
  34. 'https://www.figma.com/design/V7Ogph1Ocs4ux2A4WMNAh7/Overleaf---Components?m=auto&node-id=3488-86576&m=dev'
  35. ),
  36. args: {
  37. title: 'Informative',
  38. children: (
  39. <p>
  40. Presents information for the user to be aware of and doesn’t require any
  41. action.
  42. </p>
  43. ),
  44. },
  45. }
  46. export const Acknowledgment: Story = {
  47. parameters: figmaDesignUrl(
  48. 'https://www.figma.com/design/V7Ogph1Ocs4ux2A4WMNAh7/Overleaf---Components?m=auto&node-id=3488-86581&m=dev'
  49. ),
  50. args: {
  51. title: 'Acknowledgment',
  52. children: (
  53. <p>
  54. System requires an acknowledgment from the user. Usually contains only
  55. one primary button.
  56. </p>
  57. ),
  58. footer: <OLButton variant="primary">Accept</OLButton>,
  59. },
  60. }
  61. export const Danger: Story = {
  62. parameters: figmaDesignUrl(
  63. 'https://www.figma.com/design/V7Ogph1Ocs4ux2A4WMNAh7/Overleaf---Components?m=auto&node-id=3488-86586&m=dev'
  64. ),
  65. args: {
  66. title: 'Danger',
  67. children: <p>Used for destructive or irreversible actions.</p>,
  68. footer: (
  69. <>
  70. <OLButton variant="secondary">Cancel</OLButton>
  71. <OLButton variant="danger">Delete</OLButton>
  72. </>
  73. ),
  74. },
  75. }
  76. const meta: Meta<typeof OLModal> = {
  77. title: 'Shared / Components / Modal',
  78. component: OLModal,
  79. parameters: {
  80. controls: {
  81. include: ['size', 'title'],
  82. },
  83. },
  84. argTypes: {
  85. size: {
  86. control: 'radio',
  87. options: ['lg', 'md', 'sm'],
  88. },
  89. },
  90. args: {
  91. show: true,
  92. size: 'sm',
  93. onHide: () => {},
  94. },
  95. render: ({ title, children, footer, ...args }) => (
  96. <OLModal {...args}>
  97. <OLModalHeader>
  98. <OLModalTitle>{title}</OLModalTitle>
  99. </OLModalHeader>
  100. <OLModalBody>{children}</OLModalBody>
  101. {footer && <OLModalFooter>{footer}</OLModalFooter>}
  102. </OLModal>
  103. ),
  104. }
  105. export default meta