Nychthemeron/packages/playground/stories/Checkbox.stories.ts
Matthew L McPeak 8751c150cd
All checks were successful
ci / build (push) Successful in 19s
ci / publish (push) Successful in 11s
ci / publish-docs (push) Successful in 41s
Inital Commit
2026-06-14 14:50:44 -04:00

111 lines
3.4 KiB
TypeScript

import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { Checkbox as NychCheckbox, CheckboxGroup as NychCheckboxGroup } from '@nychthemeron/library'
const meta = {
title: 'Components/Checkbox',
component: NychCheckbox,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: {
disabled: {
control: { type: 'boolean' },
description: 'Disable the checkbox',
},
},
} satisfies Meta<typeof NychCheckbox>
export default meta
type Story = StoryObj<typeof meta>
export const Default: Story = {
render: () => ({
components: { NychCheckbox },
setup() {
const checked = ref(false)
return { checked }
},
template: `<NychCheckbox v-model="checked" binary />`,
}),
}
export const Checked: Story = {
render: () => ({
components: { NychCheckbox },
setup() {
const checked = ref(true)
return { checked }
},
template: `<NychCheckbox v-model="checked" binary />`,
}),
}
export const Disabled: Story = {
render: () => ({
components: { NychCheckbox },
setup() {
const checked = ref(true)
return { checked }
},
template: `
<div style="display: flex; gap: 1rem;">
<NychCheckbox :modelValue="false" binary disabled />
<NychCheckbox :modelValue="true" binary disabled />
</div>
`,
}),
}
export const WithLabels: Story = {
render: () => ({
components: { NychCheckbox },
setup() {
const offerings = ref(['honey'])
return { offerings }
},
template: `
<div style="display: flex; flex-direction: column; gap: 0.75rem; font-family: var(--font-sans); color: var(--text-body);">
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<NychCheckbox v-model="offerings" value="honey" /> Honey
</label>
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<NychCheckbox v-model="offerings" value="wine" /> Wine
</label>
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<NychCheckbox v-model="offerings" value="laurel" /> Laurel
</label>
<p style="color: var(--text-muted); margin-top: 0.25rem;">Offerings: {{ offerings.join(', ') || 'none' }}</p>
</div>
`,
}),
}
// CheckboxGroup holds the array v-model and shares a name across children.
export const Group: Story = {
render: () => ({
components: { NychCheckbox, NychCheckboxGroup },
setup() {
const offerings = ref(['honey'])
return { offerings }
},
template: `
<div style="font-family: var(--font-sans); color: var(--text-body);">
<NychCheckboxGroup v-model="offerings" name="offerings">
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<NychCheckbox value="honey" /> Honey
</label>
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<NychCheckbox value="wine" /> Wine
</label>
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<NychCheckbox value="laurel" /> Laurel
</label>
</NychCheckboxGroup>
<p style="color: var(--text-muted); margin-top: 0.75rem;">Offerings: {{ offerings.join(', ') || 'none' }}</p>
</div>
`,
}),
}