75 lines
1.7 KiB
TypeScript
75 lines
1.7 KiB
TypeScript
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
import { ref } from 'vue'
|
|
|
|
import { ToggleSwitch as NychToggleSwitch } from '@nychthemeron/library'
|
|
|
|
const meta = {
|
|
title: 'Components/ToggleSwitch',
|
|
component: NychToggleSwitch,
|
|
parameters: {
|
|
layout: 'centered',
|
|
},
|
|
tags: ['autodocs'],
|
|
argTypes: {
|
|
disabled: {
|
|
control: { type: 'boolean' },
|
|
description: 'Disable the switch',
|
|
},
|
|
},
|
|
} satisfies Meta<typeof NychToggleSwitch>
|
|
|
|
export default meta
|
|
type Story = StoryObj<typeof meta>
|
|
|
|
export const Default: Story = {
|
|
render: () => ({
|
|
components: { NychToggleSwitch },
|
|
setup() {
|
|
const on = ref(false)
|
|
return { on }
|
|
},
|
|
template: `<NychToggleSwitch v-model="on" />`,
|
|
}),
|
|
}
|
|
|
|
export const On: Story = {
|
|
render: () => ({
|
|
components: { NychToggleSwitch },
|
|
setup() {
|
|
const on = ref(true)
|
|
return { on }
|
|
},
|
|
template: `<NychToggleSwitch v-model="on" />`,
|
|
}),
|
|
}
|
|
|
|
export const Disabled: Story = {
|
|
render: () => ({
|
|
components: { NychToggleSwitch },
|
|
setup() {
|
|
return {}
|
|
},
|
|
template: `
|
|
<div style="display: flex; gap: 1rem;">
|
|
<NychToggleSwitch :modelValue="false" disabled />
|
|
<NychToggleSwitch :modelValue="true" disabled />
|
|
</div>
|
|
`,
|
|
}),
|
|
}
|
|
|
|
export const WithLabel: Story = {
|
|
render: () => ({
|
|
components: { NychToggleSwitch },
|
|
setup() {
|
|
const nocturnal = ref(true)
|
|
return { nocturnal }
|
|
},
|
|
template: `
|
|
<label style="display: flex; align-items: center; gap: 0.75rem; font-family: var(--font-sans); color: var(--text-body); cursor: pointer;">
|
|
<NychToggleSwitch v-model="nocturnal" />
|
|
{{ nocturnal ? 'Hades (night)' : 'Apollo (day)' }}
|
|
</label>
|
|
`,
|
|
}),
|
|
}
|