|
| 1 | +import React from "react"; |
| 2 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 3 | +import { Search } from "./Search"; |
| 4 | + |
| 5 | +const meta = { |
| 6 | + title: "Components/Search", |
| 7 | + component: Search, |
| 8 | + parameters: { |
| 9 | + layout: "centered", |
| 10 | + }, |
| 11 | + tags: ["autodocs"], |
| 12 | + argTypes: { |
| 13 | + size: { |
| 14 | + control: "select", |
| 15 | + options: ["small", "default", "large"], |
| 16 | + description: "Size of the search input", |
| 17 | + }, |
| 18 | + showIcon: { |
| 19 | + control: "boolean", |
| 20 | + description: "Whether to show the search icon", |
| 21 | + }, |
| 22 | + placeholder: { |
| 23 | + control: "text", |
| 24 | + description: "Placeholder text", |
| 25 | + }, |
| 26 | + disabled: { |
| 27 | + control: "boolean", |
| 28 | + description: "Whether the input is disabled", |
| 29 | + }, |
| 30 | + }, |
| 31 | +} satisfies Meta<typeof Search>; |
| 32 | + |
| 33 | +export default meta; |
| 34 | +type Story = StoryObj<typeof meta>; |
| 35 | + |
| 36 | +export const Default: Story = { |
| 37 | + args: { |
| 38 | + placeholder: "Decoding Bitcoin....", |
| 39 | + style: { width: "269px" }, |
| 40 | + }, |
| 41 | +}; |
| 42 | + |
| 43 | +export const Hover: Story = { |
| 44 | + args: { |
| 45 | + placeholder: "Decoding Bitcoin....", |
| 46 | + style: { width: "269px" }, |
| 47 | + }, |
| 48 | + parameters: { |
| 49 | + pseudo: { hover: true }, |
| 50 | + }, |
| 51 | +}; |
| 52 | + |
| 53 | +export const Focused: Story = { |
| 54 | + args: { |
| 55 | + placeholder: "Decoding Bitcoin....", |
| 56 | + defaultValue: "Bitc", |
| 57 | + autoFocus: true, |
| 58 | + style: { width: "269px" }, |
| 59 | + }, |
| 60 | +}; |
| 61 | + |
| 62 | +export const WithValue: Story = { |
| 63 | + args: { |
| 64 | + placeholder: "Search...", |
| 65 | + defaultValue: "Bitcoin technology", |
| 66 | + style: { width: "269px" }, |
| 67 | + }, |
| 68 | +}; |
| 69 | + |
| 70 | +export const WithoutIcon: Story = { |
| 71 | + args: { |
| 72 | + placeholder: "Decoding Bitcoin....", |
| 73 | + showIcon: false, |
| 74 | + style: { width: "269px" }, |
| 75 | + }, |
| 76 | +}; |
| 77 | + |
| 78 | +export const Disabled: Story = { |
| 79 | + args: { |
| 80 | + placeholder: "Decoding Bitcoin....", |
| 81 | + disabled: true, |
| 82 | + style: { width: "269px" }, |
| 83 | + }, |
| 84 | +}; |
| 85 | + |
| 86 | +export const Small: Story = { |
| 87 | + args: { |
| 88 | + placeholder: "Search...", |
| 89 | + size: "small", |
| 90 | + style: { width: "200px" }, |
| 91 | + }, |
| 92 | +}; |
| 93 | + |
| 94 | +export const Large: Story = { |
| 95 | + args: { |
| 96 | + placeholder: "Decoding Bitcoin....", |
| 97 | + size: "large", |
| 98 | + style: { width: "350px" }, |
| 99 | + }, |
| 100 | +}; |
| 101 | + |
| 102 | +export const FullWidth: Story = { |
| 103 | + args: { |
| 104 | + placeholder: "Decoding Bitcoin....", |
| 105 | + containerClassName: "w-full", |
| 106 | + style: { width: "500px" }, |
| 107 | + }, |
| 108 | +}; |
| 109 | + |
| 110 | +export const CustomStyling: Story = { |
| 111 | + args: { |
| 112 | + placeholder: "Custom styled search...", |
| 113 | + inputClassName: "bg-bdp-hover-primary", |
| 114 | + iconClassName: "text-bdp-accent", |
| 115 | + style: { width: "300px" }, |
| 116 | + }, |
| 117 | +}; |
| 118 | + |
| 119 | +export const AllStates: Story = { |
| 120 | + args: { |
| 121 | + placeholder: "Decoding Bitcoin....", |
| 122 | + style: { width: "269px" }, |
| 123 | + }, |
| 124 | + parameters: { |
| 125 | + docs: { |
| 126 | + description: { |
| 127 | + story: "This story shows the search component in its default state. You can interact with it to see hover and focus states.", |
| 128 | + }, |
| 129 | + }, |
| 130 | + }, |
| 131 | +}; |
| 132 | + |
0 commit comments