|
| 1 | +import React, { useState } from "react"; |
| 2 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 3 | +import { library } from "@fortawesome/fontawesome-svg-core"; |
| 4 | +import { fas } from "@fortawesome/free-solid-svg-icons"; |
| 5 | +import { IconPicker } from "~/IconPicker"; |
| 6 | + |
| 7 | +const meta: Meta<typeof IconPicker> = { |
| 8 | + title: "Components/Form/IconPicker", |
| 9 | + component: IconPicker, |
| 10 | + tags: ["autodocs"], |
| 11 | + argTypes: { |
| 12 | + onChange: { action: "onChange" } |
| 13 | + }, |
| 14 | + parameters: { |
| 15 | + layout: "padded" |
| 16 | + }, |
| 17 | + render: args => { |
| 18 | + const [value, setValue] = useState(args.value); |
| 19 | + return <IconPicker {...args} value={value} onChange={setValue} />; |
| 20 | + } |
| 21 | +}; |
| 22 | + |
| 23 | +// @ts-expect-error |
| 24 | +library.add(fas); |
| 25 | + |
| 26 | +export default meta; |
| 27 | +type Story = StoryObj<typeof IconPicker>; |
| 28 | + |
| 29 | +export const Default: Story = { |
| 30 | + args: { |
| 31 | + icons: [ |
| 32 | + { prefix: "fas", name: "trash-restore-alt" }, |
| 33 | + { prefix: "fas", name: "trash-can-arrow-up" }, |
| 34 | + { prefix: "fas", name: "naira-sign" }, |
| 35 | + { prefix: "fas", name: "cart-arrow-down" }, |
| 36 | + { prefix: "fas", name: "walkie-talkie" }, |
| 37 | + { prefix: "fas", name: "file-edit" }, |
| 38 | + { prefix: "fas", name: "file-pen" }, |
| 39 | + { prefix: "fas", name: "receipt" }, |
| 40 | + { prefix: "fas", name: "pen-square" }, |
| 41 | + { prefix: "fas", name: "pencil-square" }, |
| 42 | + { prefix: "fas", name: "square-pen" }, |
| 43 | + { prefix: "fas", name: "suitcase-rolling" }, |
| 44 | + { prefix: "fas", name: "person-circle-exclamation" }, |
| 45 | + { prefix: "fas", name: "chevron-down" }, |
| 46 | + { prefix: "fas", name: "battery" }, |
| 47 | + { prefix: "fas", name: "battery-5" }, |
| 48 | + { prefix: "fas", name: "battery-full" }, |
| 49 | + { prefix: "fas", name: "skull-crossbones" }, |
| 50 | + { prefix: "fas", name: "code-compare" }, |
| 51 | + { prefix: "fas", name: "list-dots" }, |
| 52 | + { prefix: "fas", name: "list-ul" }, |
| 53 | + { prefix: "fas", name: "school-lock" }, |
| 54 | + { prefix: "fas", name: "tower-cell" }, |
| 55 | + { prefix: "fas", name: "long-arrow-alt-down" }, |
| 56 | + { prefix: "fas", name: "down-long" }, |
| 57 | + { prefix: "fas", name: "ranking-star" }, |
| 58 | + { prefix: "fas", name: "chess-king" }, |
| 59 | + { prefix: "fas", name: "person-harassing" }, |
| 60 | + { prefix: "fas", name: "brazilian-real-sign" }, |
| 61 | + { prefix: "fas", name: "landmark-alt" }, |
| 62 | + { prefix: "fas", name: "landmark-dome" }, |
| 63 | + { prefix: "fas", name: "arrow-up" }, |
| 64 | + { prefix: "fas", name: "television" }, |
| 65 | + { prefix: "fas", name: "tv-alt" }, |
| 66 | + { prefix: "fas", name: "tv" }, |
| 67 | + { prefix: "fas", name: "shrimp" }, |
| 68 | + { prefix: "fas", name: "tasks" }, |
| 69 | + { prefix: "fas", name: "list-check" }, |
| 70 | + { prefix: "fas", name: "jug-detergent" }, |
| 71 | + { prefix: "fas", name: "user-circle" }, |
| 72 | + { prefix: "fas", name: "circle-user" }, |
| 73 | + { prefix: "fas", name: "user-shield" }, |
| 74 | + { prefix: "fas", name: "wind" }, |
| 75 | + { prefix: "fas", name: "car-crash" }, |
| 76 | + { prefix: "fas", name: "car-burst" }, |
| 77 | + { prefix: "fas", name: "y" }, |
| 78 | + { prefix: "fas", name: "snowboarding" }, |
| 79 | + { prefix: "fas", name: "person-snowboarding" }, |
| 80 | + { prefix: "fas", name: "shipping-fast" }, |
| 81 | + { prefix: "fas", name: "truck-fast" } |
| 82 | + ] |
| 83 | + } |
| 84 | +}; |
| 85 | + |
| 86 | +export const WithLabel: Story = { |
| 87 | + args: { |
| 88 | + ...Default.args, |
| 89 | + label: "Any field label" |
| 90 | + } |
| 91 | +}; |
| 92 | + |
| 93 | +export const WithLabelRequired: Story = { |
| 94 | + args: { |
| 95 | + ...Default.args, |
| 96 | + label: "Any field label", |
| 97 | + required: true |
| 98 | + } |
| 99 | +}; |
| 100 | + |
| 101 | +export const WithDescription: Story = { |
| 102 | + args: { |
| 103 | + ...Default.args, |
| 104 | + description: "Provide the required information for processing your request." |
| 105 | + } |
| 106 | +}; |
| 107 | + |
| 108 | +export const WithNotes: Story = { |
| 109 | + args: { |
| 110 | + ...Default.args, |
| 111 | + note: "Note: Ensure your selection or input is accurate before proceeding." |
| 112 | + } |
| 113 | +}; |
| 114 | + |
| 115 | +export const WithErrors: Story = { |
| 116 | + args: { |
| 117 | + ...Default.args, |
| 118 | + validation: { |
| 119 | + isValid: false, |
| 120 | + message: "This field is required." |
| 121 | + } |
| 122 | + } |
| 123 | +}; |
| 124 | + |
| 125 | +export const Disabled: Story = { |
| 126 | + args: { |
| 127 | + ...Default.args, |
| 128 | + label: "Any field label", |
| 129 | + disabled: true |
| 130 | + } |
| 131 | +}; |
| 132 | + |
| 133 | +export const FullExample: Story = { |
| 134 | + args: { |
| 135 | + ...Default.args, |
| 136 | + label: "Any field label", |
| 137 | + required: true, |
| 138 | + description: "Provide the required information for processing your request.", |
| 139 | + note: "Note: Ensure your selection or input is accurate before proceeding.", |
| 140 | + validation: { |
| 141 | + isValid: false, |
| 142 | + message: "This field is required." |
| 143 | + } |
| 144 | + } |
| 145 | +}; |
0 commit comments