|
| 1 | +import * as React from "react"; |
| 2 | + |
| 3 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 4 | + |
| 5 | +import { NavbarGeneric } from "./NavbarGeneric"; |
| 6 | +import { NavbarCenterSection, NavbarEndSection, NavbarStartSection } from "./NavbarSections"; |
| 7 | + |
| 8 | +const meta = { |
| 9 | + title: "Components/NavbarGeneric", |
| 10 | + component: NavbarGeneric, |
| 11 | + argTypes: { |
| 12 | + behavior: { |
| 13 | + control: "radio", |
| 14 | + options: ["static", "sticky", "fixed"], |
| 15 | + description: "Behavior of the navbar", |
| 16 | + table: { |
| 17 | + defaultValue: { summary: "sticky" }, |
| 18 | + }, |
| 19 | + }, |
| 20 | + variant: { |
| 21 | + control: "radio", |
| 22 | + options: ["default"], |
| 23 | + description: "Visual variant of the navbar", |
| 24 | + table: { |
| 25 | + defaultValue: { summary: "default" }, |
| 26 | + }, |
| 27 | + }, |
| 28 | + }, |
| 29 | +} satisfies Meta<typeof NavbarGeneric>; |
| 30 | + |
| 31 | +export default meta; |
| 32 | + |
| 33 | +type Story = StoryObj<typeof NavbarGeneric>; |
| 34 | + |
| 35 | +const DefaultContent = () => ( |
| 36 | + <> |
| 37 | + <NavbarStartSection> |
| 38 | + <div className="rounded-sm bg-grey-500 p-2">Start Content</div> |
| 39 | + </NavbarStartSection> |
| 40 | + <NavbarCenterSection> |
| 41 | + <div className="rounded-sm bg-grey-500 p-2">Center Content</div> |
| 42 | + </NavbarCenterSection> |
| 43 | + <NavbarEndSection> |
| 44 | + <div className="rounded-sm bg-grey-500 p-2">End Content</div> |
| 45 | + </NavbarEndSection> |
| 46 | + </> |
| 47 | +); |
| 48 | + |
| 49 | +const ScrollDecorator = (Story: React.ComponentType) => ( |
| 50 | + <div className="h-[200vh]"> |
| 51 | + <Story /> |
| 52 | + <div className="p-4">Scroll content</div> |
| 53 | + </div> |
| 54 | +); |
| 55 | + |
| 56 | +export const Default: Story = { |
| 57 | + args: { |
| 58 | + children: <DefaultContent />, |
| 59 | + }, |
| 60 | +}; |
| 61 | + |
| 62 | +export const Static: Story = { |
| 63 | + args: { |
| 64 | + behavior: "static", |
| 65 | + children: <DefaultContent />, |
| 66 | + }, |
| 67 | + argTypes: { |
| 68 | + children: { |
| 69 | + table: { |
| 70 | + disable: true, |
| 71 | + }, |
| 72 | + }, |
| 73 | + }, |
| 74 | + decorators: [ScrollDecorator], |
| 75 | +}; |
| 76 | + |
| 77 | +export const Sticky: Story = { |
| 78 | + args: { |
| 79 | + behavior: "sticky", |
| 80 | + children: <DefaultContent />, |
| 81 | + }, |
| 82 | + argTypes: { |
| 83 | + children: { |
| 84 | + table: { |
| 85 | + disable: true, |
| 86 | + }, |
| 87 | + }, |
| 88 | + }, |
| 89 | + decorators: [ScrollDecorator], |
| 90 | +}; |
| 91 | + |
| 92 | +export const Fixed: Story = { |
| 93 | + args: { |
| 94 | + behavior: "fixed", |
| 95 | + children: <DefaultContent />, |
| 96 | + }, |
| 97 | + argTypes: { |
| 98 | + children: { |
| 99 | + table: { |
| 100 | + disable: true, |
| 101 | + }, |
| 102 | + }, |
| 103 | + }, |
| 104 | + decorators: [ScrollDecorator], |
| 105 | +}; |
| 106 | + |
| 107 | +export const RandomOrder: Story = { |
| 108 | + render: (args) => ( |
| 109 | + <NavbarGeneric {...args}> |
| 110 | + <NavbarEndSection> |
| 111 | + <div className="bg-grey-500 p-2">End First</div> |
| 112 | + </NavbarEndSection> |
| 113 | + <NavbarStartSection> |
| 114 | + <div className="bg-grey-500 p-2">Start Second</div> |
| 115 | + </NavbarStartSection> |
| 116 | + <NavbarCenterSection> |
| 117 | + <div className="bg-grey-500 p-2">Center Last</div> |
| 118 | + </NavbarCenterSection> |
| 119 | + </NavbarGeneric> |
| 120 | + ), |
| 121 | +}; |
| 122 | + |
| 123 | +export const OmittedSections: Story = { |
| 124 | + render: (args) => ( |
| 125 | + <NavbarGeneric {...args}> |
| 126 | + <NavbarStartSection> |
| 127 | + <div className="bg-grey-500 p-2">Only Start</div> |
| 128 | + </NavbarStartSection> |
| 129 | + <NavbarEndSection> |
| 130 | + <div className="bg-grey-500 p-2">And End</div> |
| 131 | + </NavbarEndSection> |
| 132 | + </NavbarGeneric> |
| 133 | + ), |
| 134 | +}; |
0 commit comments