Skip to content

Commit bc32112

Browse files
committed
fix: story tweaks
1 parent 32b3513 commit bc32112

File tree

2 files changed

+44
-48
lines changed

2 files changed

+44
-48
lines changed

packages/ui/src/components/va-menu-list/VaMenuList.stories.ts

+37-40
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { VaDivider, VaButton, VaDropdown, VaDropdownContent, VaIcon, VaAvatar } from '../../components'
1+
import { VaDivider, VaButton, VaDropdown, VaIcon, VaAvatar } from '../../components'
22
import VaMenuList from './VaMenuList.vue'
33
import VaMenuItem from './components/VaMenuItem.vue'
44
import VaMenuGroup from './components/VaMenuGroup.vue'
5+
import { addText } from '../../../.storybook/interaction-utils/addText'
56

67
export default {
78
title: 'VaMenuList',
89
component: VaMenuList,
10+
tags: ['autodocs'],
911
}
1012

1113
export const Default = () => ({
@@ -19,23 +21,24 @@ export const Default = () => ({
1921
export const IconSlot = () => ({
2022
components: { VaMenuList, VaAvatar },
2123
data: () => ({
22-
options: [
23-
{ id: '0', text: 'one', value: 'one', icon: 'accessible_forward', rightIcon: '' },
24-
{ id: '1', text: 'two', value: 'two', icon: '', rightIcon: 'home' },
25-
{ id: '2', text: 'three', value: 'three', icon: 'accessible_forward', rightIcon: '' },
26-
{ id: '3', text: 'four', value: 'four', icon: '', rightIcon: 'accessible_forward' },
27-
{ id: '4', text: 'five', value: 'five', icon: 'search' },
28-
],
29-
value: false,
24+
options: ['Option 1', 'Option 2', 'Option 3'],
3025
}),
3126
template: `
32-
<VaMenuList :options="options" v-model="value">
27+
<VaMenuList :options="options">
3328
<template #left-icon>
34-
<va-avatar src="https://randomuser.me/api/portraits/men/2.jpg" />
29+
[left-icon]
30+
</template>
31+
<template #icon>
32+
[icon]
3533
</template>
3634
</VaMenuList>
3735
`,
3836
})
37+
addText(
38+
IconSlot,
39+
'There is no slot for right icon, only for left one.',
40+
'broken',
41+
)
3942

4043
const longGroupName = 'This is a very long group name that should be truncated'.repeat(10)
4144
export const Groups = () => ({
@@ -51,14 +54,18 @@ export const Groups = () => ({
5154
value: false,
5255
}),
5356
template: `
54-
<VaMenuList :options="options" v-model="value">
57+
<VaMenuList :options="options">
5558
</VaMenuList>
5659
`,
5760
})
61+
addText(
62+
Groups,
63+
'Long group name is not truncated in story. We also have too much options - should be minimal amount.',
64+
'broken',
65+
)
5866

5967
export const SlotUsage = () => ({
6068
components: { VaMenuList, VaMenuItem, VaMenuGroup },
61-
6269
template: `
6370
<VaMenuList>
6471
<VaMenuGroup group-name="Group 1" />
@@ -78,26 +85,21 @@ export const SlotUsage = () => ({
7885

7986
export const Color = () => ({
8087
components: { VaMenuList, VaMenuItem, VaMenuGroup },
81-
8288
data: () => ({
83-
options: [
84-
{ id: '0', text: 'one', value: 'one', icon: 'accessible_forward' },
85-
{ id: '1', text: 'two', value: 'two', icon: '', rightIcon: 'home' },
86-
{ id: '2', text: 'three', value: 'three', icon: 'accessible_forward', rightIcon: '' },
87-
{ id: '3', text: 'four', value: 'four', icon: '', rightIcon: 'accessible_forward' },
88-
{ id: '4', text: 'five', value: 'five', icon: 'search', rightIcon: '' },
89-
],
90-
value: false,
89+
options: ['Option 1', 'Option 2', 'Option 3'],
9190
}),
92-
9391
template: `
9492
<VaMenuList color="warning" :options="options" />
9593
`,
9694
})
95+
addText(
96+
Groups,
97+
`I don't think we have any other component where 'color' means 'hover-color', let's make it explicit.` ,
98+
'broken',
99+
)
97100

98101
export const WithDivider = () => ({
99102
components: { VaMenuList, VaMenuItem, VaMenuGroup, VaDivider, VaButton },
100-
101103
template: `
102104
<VaMenuList>
103105
<VaMenuItem>
@@ -120,22 +122,8 @@ export const WithDivider = () => ({
120122
`,
121123
})
122124

123-
const subMenu = `
124-
<VaDropdownContent style="margin-top: calc(var(--va-menu-padding-y) * -1)">
125-
<VaMenuList>
126-
<VaMenuItem>
127-
Group 1
128-
</VaMenuItem>
129-
<VaMenuItem>
130-
Group 2
131-
</VaMenuItem>
132-
</VaMenuList>
133-
</VaDropdownContent>
134-
`
135-
136125
export const WithDropdown = () => ({
137-
components: { VaMenuList, VaMenuItem, VaMenuGroup, VaDivider, VaButton, VaDropdown, VaDropdownContent, VaIcon },
138-
126+
components: { VaMenuList, VaMenuItem, VaMenuGroup, VaDivider, VaButton, VaDropdown, VaIcon },
139127
template: `
140128
<VaMenuList>
141129
<VaMenuItem>
@@ -154,7 +142,16 @@ export const WithDropdown = () => ({
154142
</VaMenuItem>
155143
</template>
156144
157-
${subMenu}
145+
<VaDropdownContent style="margin-top: calc(var(--va-menu-padding-y) * -1)">
146+
<VaMenuList>
147+
<VaMenuItem>
148+
Group 1
149+
</VaMenuItem>
150+
<VaMenuItem>
151+
Group 2
152+
</VaMenuItem>
153+
</VaMenuList>
154+
</VaDropdownContent>
158155
</VaDropdown>
159156
160157
<VaMenuItem icon="home">
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
import VaMenu from './VaMenu.vue'
2+
import { VaButton } from '../va-button'
23

34
export default {
45
title: 'VaMenu',
56
component: VaMenu,
7+
tags: ['autodocs'],
68
}
79

810
export const Default = () => ({
9-
components: { VaMenu },
11+
components: { VaMenu, VaButton },
1012
data: () => ({
11-
options: ['Option 1', 'Option 2', 'Option 3'],
12-
value: false,
1313
}),
1414
template: `
1515
<VaMenu :options="options">
1616
<template #anchor>
17-
<button>Open menu</button>
17+
<VaButton>Open</VaButton>
1818
</template>
1919
</VaMenu>
2020
`,
2121
})
2222

2323
export const OptionSelected = () => ({
24-
components: { VaMenu },
24+
components: { VaMenu, VaButton },
2525
data: () => ({
2626
options: ['Option 1', 'Option 2', 'Option 3'],
2727
value: false,
2828
}),
2929
template: `
30-
[value]: {{ value }}
31-
<br/>
3230
<VaMenu :options="options" @selected="(v) => value = v ">
3331
<template #anchor>
34-
<button>Open menu</button>
32+
<VaButton>Open</VaButton>
3533
</template>
3634
</VaMenu>
35+
<p class="mt-32">value: {{ value }}</p>
3736
`,
3837
})

0 commit comments

Comments
 (0)