|
| 1 | +<script context="module" lang="ts"> |
| 2 | + import { CompoundTagRoot, CompoundTagChild } from '$lib/index.js'; |
| 3 | + import type { MetaProps } from '@storybook/addon-svelte-csf'; |
| 4 | +
|
| 5 | + export const meta: MetaProps = { |
| 6 | + title: 'Components/CompoundTag', |
| 7 | + component: CompoundTagRoot |
| 8 | + }; |
| 9 | +</script> |
| 10 | + |
| 11 | +<script> |
| 12 | + import Icon from '$lib/Icon.svelte'; |
| 13 | + import Popover from '$lib/Popover.svelte'; |
| 14 | + import ActionMenu from '$lib/action-menu/index.js'; |
| 15 | + import { Story, Template } from '@storybook/addon-svelte-csf'; |
| 16 | + import { |
| 17 | + IconXCircle, |
| 18 | + IconFilter, |
| 19 | + IconCheck, |
| 20 | + IconX, |
| 21 | + IconInfo, |
| 22 | + IconChevronDoubleRight, |
| 23 | + IconDuplicate |
| 24 | + } from '@appwrite.io/pink-icons-svelte'; |
| 25 | +</script> |
| 26 | + |
| 27 | +<Template let:args> |
| 28 | + <CompoundTagRoot {...args} /> |
| 29 | +</Template> |
| 30 | + |
| 31 | +<Story name="Default" let:args> |
| 32 | + <CompoundTagRoot size={args.size}> |
| 33 | + <CompoundTagChild on:click={() => console.log('Clicked Status')}>Status</CompoundTagChild> |
| 34 | + <CompoundTagChild on:click={() => console.log('Clicked is')}>is</CompoundTagChild> |
| 35 | + <CompoundTagChild selected on:click={() => console.log('Clicked Active')} |
| 36 | + >Active</CompoundTagChild |
| 37 | + > |
| 38 | + <CompoundTagChild aria-label="Dismiss" dismiss> |
| 39 | + <Icon size="s" icon={IconX} /> |
| 40 | + </CompoundTagChild> |
| 41 | + </CompoundTagRoot> |
| 42 | +</Story> |
| 43 | + |
| 44 | +<Story name="Action" let:args> |
| 45 | + <CompoundTagRoot size={args.size}> |
| 46 | + <CompoundTagChild> |
| 47 | + <Icon icon={IconDuplicate} /> |
| 48 | + Action |
| 49 | + </CompoundTagChild> |
| 50 | + <CompoundTagChild aria-label="Dismiss" dismiss> |
| 51 | + <Icon size="s" icon={IconX} /> |
| 52 | + </CompoundTagChild> |
| 53 | + </CompoundTagRoot> |
| 54 | +</Story> |
| 55 | + |
| 56 | +<Story name="Filter Example" let:args> |
| 57 | + <CompoundTagRoot size={args.size}> |
| 58 | + <CompoundTagChild on:click={() => console.log('Clicked field')}> |
| 59 | + <Icon icon={IconFilter} /> |
| 60 | + Build duration |
| 61 | + </CompoundTagChild> |
| 62 | + <CompoundTagChild on:click={() => console.log('Clicked operator')}>is</CompoundTagChild> |
| 63 | + <CompoundTagChild selected on:click={() => console.log('Clicked value')} |
| 64 | + >more than 2 minutes</CompoundTagChild |
| 65 | + > |
| 66 | + <CompoundTagChild on:click={() => console.log('Clicked remove')}> |
| 67 | + <Icon icon={IconXCircle} /> |
| 68 | + </CompoundTagChild> |
| 69 | + </CompoundTagRoot> |
| 70 | +</Story> |
| 71 | + |
| 72 | +<Story name="Status Example" let:args> |
| 73 | + <CompoundTagRoot size={args.size}> |
| 74 | + <CompoundTagChild on:click={() => console.log('Clicked type')}>Status</CompoundTagChild> |
| 75 | + <CompoundTagChild selected on:click={() => console.log('Clicked status')}> |
| 76 | + <Icon icon={IconCheck} /> |
| 77 | + Completed |
| 78 | + </CompoundTagChild> |
| 79 | + <CompoundTagChild on:click={() => console.log('Clicked action')}> |
| 80 | + <Icon icon={IconXCircle} /> |
| 81 | + </CompoundTagChild> |
| 82 | + </CompoundTagRoot> |
| 83 | +</Story> |
| 84 | + |
| 85 | +<Story name="Sizes"> |
| 86 | + <div |
| 87 | + style="display: flex; flex-direction: column; gap: var(--space-6); align-items: flex-start;" |
| 88 | + > |
| 89 | + <CompoundTagRoot size="s"> |
| 90 | + <CompoundTagChild on:click={() => console.log('Clicked Tag')}>Tag</CompoundTagChild> |
| 91 | + <CompoundTagChild on:click={() => console.log('Clicked is')}>is</CompoundTagChild> |
| 92 | + <CompoundTagChild on:click={() => console.log('Clicked Tag')}>Tag</CompoundTagChild> |
| 93 | + <CompoundTagChild dismiss on:click={() => console.log('Clicked close')} |
| 94 | + ><Icon icon={IconX} size="s" /></CompoundTagChild |
| 95 | + > |
| 96 | + </CompoundTagRoot> |
| 97 | + <CompoundTagRoot size="m"> |
| 98 | + <CompoundTagChild on:click={() => console.log('Clicked Tag')}>Tag</CompoundTagChild> |
| 99 | + <CompoundTagChild on:click={() => console.log('Clicked is')}>is</CompoundTagChild> |
| 100 | + <CompoundTagChild on:click={() => console.log('Clicked Tag')}>Tag</CompoundTagChild> |
| 101 | + <CompoundTagChild dismiss on:click={() => console.log('Clicked close')} |
| 102 | + ><Icon icon={IconX} size="s" /></CompoundTagChild |
| 103 | + > |
| 104 | + </CompoundTagRoot> |
| 105 | + </div> |
| 106 | +</Story> |
| 107 | + |
| 108 | +<Story name="With Disabled Child" let:args> |
| 109 | + <CompoundTagRoot size={args.size}> |
| 110 | + <CompoundTagChild on:click={() => console.log('Clicked Tag')}>Tag</CompoundTagChild> |
| 111 | + <CompoundTagChild on:click={() => console.log('Clicked is')}>is</CompoundTagChild> |
| 112 | + <CompoundTagChild disabled on:click={() => console.log('Clicked Tag')}>Tag</CompoundTagChild |
| 113 | + > |
| 114 | + <CompoundTagChild on:click={() => console.log('Clicked close')}>×</CompoundTagChild> |
| 115 | + </CompoundTagRoot> |
| 116 | +</Story> |
| 117 | + |
| 118 | +<Story name="Code Variant" let:args> |
| 119 | + <CompoundTagRoot size={args.size}> |
| 120 | + <CompoundTagChild on:click={() => console.log('Clicked function')} |
| 121 | + >function</CompoundTagChild |
| 122 | + > |
| 123 | + <CompoundTagChild variant="code" on:click={() => console.log('Clicked name')} |
| 124 | + >getUserData</CompoundTagChild |
| 125 | + > |
| 126 | + <CompoundTagChild on:click={() => console.log('Clicked params')}>()</CompoundTagChild> |
| 127 | + <CompoundTagChild on:click={() => console.log('Clicked return')}>return</CompoundTagChild> |
| 128 | + </CompoundTagRoot> |
| 129 | +</Story> |
| 130 | + |
| 131 | +<Story name="With Action Menu" let:args> |
| 132 | + <CompoundTagRoot size={args.size}> |
| 133 | + <CompoundTagChild on:click={() => console.log('Clicked Tag')}>Tag</CompoundTagChild> |
| 134 | + <CompoundTagChild on:click={() => console.log('Clicked is')}>is</CompoundTagChild> |
| 135 | + <Popover let:toggle placement="bottom-start" padding="none"> |
| 136 | + <CompoundTagChild selected on:click={toggle}>Actions</CompoundTagChild> |
| 137 | + <svelte:fragment slot="tooltip"> |
| 138 | + <ActionMenu.Root> |
| 139 | + <ActionMenu.Item.Button |
| 140 | + leadingIcon={IconInfo} |
| 141 | + trailingIcon={IconChevronDoubleRight} |
| 142 | + badge="1" |
| 143 | + > |
| 144 | + Default |
| 145 | + </ActionMenu.Item.Button> |
| 146 | + <ActionMenu.Item.Button |
| 147 | + leadingIcon={IconInfo} |
| 148 | + trailingIcon={IconChevronDoubleRight} |
| 149 | + badge="1" |
| 150 | + > |
| 151 | + Default with a very long text |
| 152 | + </ActionMenu.Item.Button> |
| 153 | + <ActionMenu.Item.Button |
| 154 | + leadingIcon={IconInfo} |
| 155 | + trailingIcon={IconChevronDoubleRight} |
| 156 | + disabled |
| 157 | + > |
| 158 | + Disabled |
| 159 | + </ActionMenu.Item.Button> |
| 160 | + <ActionMenu.Item.Button leadingIcon={IconInfo} status="danger"> |
| 161 | + Danger |
| 162 | + </ActionMenu.Item.Button> |
| 163 | + <ActionMenu.Item.Button leadingIcon={IconInfo} status="danger" disabled> |
| 164 | + Danger Disabled |
| 165 | + </ActionMenu.Item.Button> |
| 166 | + </ActionMenu.Root> |
| 167 | + </svelte:fragment> |
| 168 | + </Popover> |
| 169 | + <CompoundTagChild dismiss on:click={() => console.log('Clicked close')}> |
| 170 | + <Icon icon={IconX} /> |
| 171 | + </CompoundTagChild> |
| 172 | + </CompoundTagRoot> |
| 173 | +</Story> |
0 commit comments