Compare commits

...

4 Commits

Author SHA1 Message Date
GitHub Action
21eb87cc0c [automated] Apply ESLint and Oxfmt fixes 2026-03-06 01:56:58 +00:00
Dante
13693de67b Merge branch 'main' into feat/storybook-button-widget-stories 2026-03-06 10:54:13 +09:00
dante01yoon
3d8a51c092 test: add Storybook stories for WidgetWithControl
Stories for all 4 control modes (Randomize, Fixed, Increment, Decrement)
plus WithLabel. Uses WidgetInputText as the inner component.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 16:30:42 +09:00
dante01yoon
b96951de24 test: add Storybook stories for WidgetButton
Stories: Default, WithIcon, WithLabel, WithLabelAndIcon, NoCallback.
Interactive controls for label and iconClass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 16:25:38 +09:00
3 changed files with 242 additions and 1 deletions

View File

@@ -247,7 +247,7 @@ const handleFocusOut = (event: FocusEvent) => {
const getNavigationDotClass = (index: number) =>
cn(
'w-2 h-2 rounded-full transition-all duration-200 border-0 cursor-pointer',
'size-2 cursor-pointer rounded-full border-0 transition-all duration-200',
index === currentIndex.value
? 'bg-base-foreground'
: 'bg-base-foreground/50 hover:bg-base-foreground/80'

View File

@@ -0,0 +1,133 @@
import type {
ComponentPropsAndSlots,
Meta,
StoryObj
} from '@storybook/vue3-vite'
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
import WidgetButton from './WidgetButton.vue'
interface StoryArgs extends ComponentPropsAndSlots<typeof WidgetButton> {
label: string
iconClass: string
}
const meta: Meta<StoryArgs> = {
title: 'Widgets/WidgetButton',
component: WidgetButton,
tags: ['autodocs'],
parameters: { layout: 'centered' },
argTypes: {
label: { control: 'text' },
iconClass: { control: 'text' }
},
args: {
label: '',
iconClass: ''
},
decorators: [
(story) => ({
components: { story },
template: '<div class="w-60"><story /></div>'
})
]
}
export default meta
type Story = StoryObj<typeof meta>
function createWidget(
overrides: {
name?: string
label?: string
iconClass?: string
callback?: () => void
} = {}
): SimplifiedWidget<void> {
return {
name: overrides.name ?? 'Run',
type: 'button',
value: undefined,
label: overrides.label,
callback: overrides.callback,
options: {
...(overrides.iconClass ? { iconClass: overrides.iconClass } : {})
}
}
}
export const Default: Story = {
render: (args) => ({
components: { WidgetButton },
setup() {
const widget = createWidget({
label: args.label || undefined,
iconClass: args.iconClass || undefined,
callback: () => {}
})
return { widget }
},
template: '<WidgetButton :widget="widget" />'
})
}
export const WithIcon: Story = {
args: { iconClass: 'pi pi-star' },
render: (args) => ({
components: { WidgetButton },
setup() {
const widget = createWidget({
name: 'Favorite',
iconClass: args.iconClass || 'pi pi-star',
callback: () => {}
})
return { widget }
},
template: '<WidgetButton :widget="widget" />'
})
}
export const WithLabel: Story = {
args: { label: 'Execute Workflow' },
render: (args) => ({
components: { WidgetButton },
setup() {
const widget = createWidget({
name: 'run',
label: args.label || 'Execute Workflow',
callback: () => {}
})
return { widget }
},
template: '<WidgetButton :widget="widget" />'
})
}
export const WithLabelAndIcon: Story = {
args: { label: 'Save', iconClass: 'pi pi-save' },
render: (args) => ({
components: { WidgetButton },
setup() {
const widget = createWidget({
name: 'save',
label: args.label || 'Save',
iconClass: args.iconClass || 'pi pi-save',
callback: () => {}
})
return { widget }
},
template: '<WidgetButton :widget="widget" />'
})
}
export const NoCallback: Story = {
render: () => ({
components: { WidgetButton },
setup() {
const widget = createWidget({ name: 'Disabled Action' })
return { widget }
},
template: '<WidgetButton :widget="widget" />'
})
}

View File

@@ -0,0 +1,108 @@
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import type {
ControlOptions,
SimplifiedControlWidget
} from '@/types/simplifiedWidget'
import WidgetInputText from './WidgetInputText.vue'
import WidgetWithControl from './WidgetWithControl.vue'
function createControlWidget(
mode: ControlOptions = 'randomize'
): SimplifiedControlWidget<string> {
return {
name: 'seed',
type: 'STRING',
value: '',
controlWidget: {
value: mode,
update: () => {}
}
}
}
const meta = {
title: 'Widgets/WidgetWithControl',
tags: ['autodocs'],
parameters: { layout: 'centered' },
decorators: [
(story) => ({
components: { story },
template:
'<div class="grid grid-cols-[auto_1fr] gap-1 w-80"><story /></div>'
})
]
} satisfies Meta
export default meta
type Story = StoryObj<typeof meta>
export const Randomize: Story = {
render: () => ({
components: { WidgetWithControl, WidgetInputText },
setup() {
const value = ref('42')
const widget = createControlWidget('randomize')
return { value, widget, WidgetInputText }
},
template:
'<WidgetWithControl :widget="widget" :component="WidgetInputText" v-model="value" />'
})
}
export const Fixed: Story = {
render: () => ({
components: { WidgetWithControl, WidgetInputText },
setup() {
const value = ref('42')
const widget = createControlWidget('fixed')
return { value, widget, WidgetInputText }
},
template:
'<WidgetWithControl :widget="widget" :component="WidgetInputText" v-model="value" />'
})
}
export const Increment: Story = {
render: () => ({
components: { WidgetWithControl, WidgetInputText },
setup() {
const value = ref('42')
const widget = createControlWidget('increment')
return { value, widget, WidgetInputText }
},
template:
'<WidgetWithControl :widget="widget" :component="WidgetInputText" v-model="value" />'
})
}
export const Decrement: Story = {
render: () => ({
components: { WidgetWithControl, WidgetInputText },
setup() {
const value = ref('42')
const widget = createControlWidget('decrement')
return { value, widget, WidgetInputText }
},
template:
'<WidgetWithControl :widget="widget" :component="WidgetInputText" v-model="value" />'
})
}
export const WithLabel: Story = {
render: () => ({
components: { WidgetWithControl, WidgetInputText },
setup() {
const value = ref('12345')
const widget: SimplifiedControlWidget<string> = {
...createControlWidget('randomize'),
label: 'Random Seed'
}
return { value, widget, WidgetInputText }
},
template:
'<WidgetWithControl :widget="widget" :component="WidgetInputText" v-model="value" />'
})
}