|
| 1 | +// Copyright (C) 2025 Nethesis S.r.l. |
| 2 | +// SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | + |
| 4 | +import { Meta, StoryObj } from '@storybook/vue3-vite' |
| 5 | +import { NeBadgeV2 } from '../src/main' |
| 6 | +import { faAward } from '@fortawesome/free-solid-svg-icons' |
| 7 | +import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' |
| 8 | + |
| 9 | +const meta: Meta<typeof NeBadgeV2> = { |
| 10 | + title: 'NeBadgeV2', |
| 11 | + component: NeBadgeV2, |
| 12 | + tags: ['autodocs'], |
| 13 | + argTypes: { |
| 14 | + size: { |
| 15 | + options: ['xs', 'sm'], |
| 16 | + control: { type: 'inline-radio' } |
| 17 | + }, |
| 18 | + kind: { |
| 19 | + options: ['primary', 'gray', 'indigo', 'green', 'amber', 'rose', 'blue', 'custom'], |
| 20 | + control: { type: 'inline-radio' } |
| 21 | + } |
| 22 | + }, |
| 23 | + args: { |
| 24 | + size: 'sm', |
| 25 | + kind: 'gray', |
| 26 | + pill: true, |
| 27 | + dismissable: false, |
| 28 | + customKindClasses: '', |
| 29 | + dismissAriaLabel: 'Dismiss' |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +export default meta |
| 34 | +type Story = StoryObj<typeof meta> |
| 35 | + |
| 36 | +const defaultTemplate = `<NeBadgeV2 v-bind="args">Badge</NeBadgeV2>` |
| 37 | + |
| 38 | +export const Default: Story = { |
| 39 | + render: (args) => ({ |
| 40 | + components: { NeBadgeV2 }, |
| 41 | + setup() { |
| 42 | + return { args } |
| 43 | + }, |
| 44 | + template: defaultTemplate |
| 45 | + }), |
| 46 | + args: {} |
| 47 | +} |
| 48 | + |
| 49 | +export const Kind: Story = { |
| 50 | + render: (args) => ({ |
| 51 | + components: { NeBadgeV2 }, |
| 52 | + setup() { |
| 53 | + return { args } |
| 54 | + }, |
| 55 | + template: ` |
| 56 | + <div class="flex flex-wrap gap-8"> |
| 57 | + <NeBadgeV2 v-bind="args" kind="gray">gray</NeBadgeV2> |
| 58 | + <NeBadgeV2 v-bind="args" kind="primary">primary</NeBadgeV2> |
| 59 | + <NeBadgeV2 v-bind="args" kind="indigo">indigo</NeBadgeV2> |
| 60 | + <NeBadgeV2 v-bind="args" kind="green">green</NeBadgeV2> |
| 61 | + <NeBadgeV2 v-bind="args" kind="amber">amber</NeBadgeV2> |
| 62 | + <NeBadgeV2 v-bind="args" kind="rose">rose</NeBadgeV2> |
| 63 | + <NeBadgeV2 v-bind="args" kind="blue">blue</NeBadgeV2> |
| 64 | + <NeBadgeV2 v-bind="args" kind="custom" customKindClasses="bg-fuchsia-100 text-fuchsia-700 dark:bg-fuchsia-700 dark:text-fuchsia-50">custom</NeBadgeV2> |
| 65 | + </div> |
| 66 | + ` |
| 67 | + }), |
| 68 | + args: {} |
| 69 | +} |
| 70 | + |
| 71 | +export const CustomKind: Story = { |
| 72 | + render: (args) => ({ |
| 73 | + components: { NeBadgeV2 }, |
| 74 | + setup() { |
| 75 | + return { args } |
| 76 | + }, |
| 77 | + template: `<NeBadgeV2 v-bind="args">Custom badge</NeBadgeV2>` |
| 78 | + }), |
| 79 | + args: { |
| 80 | + kind: 'custom', |
| 81 | + customKindClasses: 'text-white bg-linear-to-br from-fuchsia-500 to-blue-500' |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +const withIconTemplate = `<NeBadgeV2 v-bind="args"> |
| 86 | + <FontAwesomeIcon :icon="faAward" class="size-4" /> |
| 87 | + Badge |
| 88 | +</NeBadgeV2>` |
| 89 | + |
| 90 | +export const WithIcon: Story = { |
| 91 | + render: (args) => ({ |
| 92 | + components: { NeBadgeV2, FontAwesomeIcon }, |
| 93 | + setup() { |
| 94 | + return { args, faAward } |
| 95 | + }, |
| 96 | + template: withIconTemplate |
| 97 | + }), |
| 98 | + args: {} |
| 99 | +} |
| 100 | + |
| 101 | +export const Dismissable: Story = { |
| 102 | + render: (args) => ({ |
| 103 | + components: { NeBadgeV2 }, |
| 104 | + setup() { |
| 105 | + return { args } |
| 106 | + }, |
| 107 | + template: defaultTemplate |
| 108 | + }), |
| 109 | + args: { |
| 110 | + dismissable: true |
| 111 | + } |
| 112 | +} |
0 commit comments