103 lines
3 KiB
TypeScript
103 lines
3 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'],
|
|
} 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" />`,
|
|
}),
|
|
}
|
|
|
|
export const Checked: Story = {
|
|
render: () => ({
|
|
components: { NychCheckbox },
|
|
setup() {
|
|
const checked = ref(true)
|
|
return { checked }
|
|
},
|
|
template: `<NychCheckbox v-model="checked" />`,
|
|
}),
|
|
}
|
|
|
|
export const Disabled: Story = {
|
|
render: () => ({
|
|
components: { NychCheckbox },
|
|
template: `
|
|
<div style="display: flex; gap: 1rem;">
|
|
<NychCheckbox :model-value="false" disabled />
|
|
<NychCheckbox :model-value="true" disabled />
|
|
</div>
|
|
`,
|
|
}),
|
|
}
|
|
|
|
export const WithLabels: Story = {
|
|
render: () => ({
|
|
components: { NychCheckbox },
|
|
setup() {
|
|
const honey = ref(true)
|
|
const wine = ref(false)
|
|
const laurel = ref(false)
|
|
return { honey, wine, laurel }
|
|
},
|
|
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="honey" /> Honey
|
|
</label>
|
|
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
|
|
<NychCheckbox v-model="wine" /> Wine
|
|
</label>
|
|
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
|
|
<NychCheckbox v-model="laurel" /> Laurel
|
|
</label>
|
|
</div>
|
|
`,
|
|
}),
|
|
}
|
|
|
|
// CheckboxGroup shares layout and a name across children; each checkbox still owns its own v-model.
|
|
export const Group: Story = {
|
|
render: () => ({
|
|
components: { NychCheckbox, NychCheckboxGroup },
|
|
setup() {
|
|
const honey = ref(true)
|
|
const wine = ref(false)
|
|
const laurel = ref(false)
|
|
return { honey, wine, laurel }
|
|
},
|
|
template: `
|
|
<div style="font-family: var(--font-sans); color: var(--text-body);">
|
|
<NychCheckboxGroup name="offerings">
|
|
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
|
|
<NychCheckbox v-model="honey" /> Honey
|
|
</label>
|
|
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
|
|
<NychCheckbox v-model="wine" /> Wine
|
|
</label>
|
|
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
|
|
<NychCheckbox v-model="laurel" /> Laurel
|
|
</label>
|
|
</NychCheckboxGroup>
|
|
</div>
|
|
`,
|
|
}),
|
|
}
|