Skip to content

Commit

Permalink
test(menu): add workshop story
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard committed Jun 13, 2024
1 parent dd7796f commit 657b83e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/core/components/menu/__workshop__/customSelectedState.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {ChevronDownIcon} from '@sanity/icons'
import {useSelect} from '@sanity/ui-workshop'
import {Box, Button} from '../../../primitives'
import {Menu} from '../menu'
import {MenuButton} from '../menuButton'
import {MenuItem} from '../menuItem'

const selectedOptions = {
undefined: 'undefined',
true: true,
false: false,
} as const

export default function CustomSelectedStateStory() {
const selected = useSelect('Selected', selectedOptions, false)

return (
<Box padding={4}>
<MenuButton
button={
<Button
icon={ChevronDownIcon}
mode="bleed"
selected={selected === 'undefined' ? undefined : selected}
text="Menu"
/>
}
id="test-menu"
menu={
<Menu>
<MenuItem text="Item 1" />
<MenuItem text="Item 2" />
</Menu>
}
/>
</Box>
)
}
5 changes: 5 additions & 0 deletions src/core/components/menu/__workshop__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@ export default defineScope({
title: 'Avatar menu',
component: lazy(() => import('./avatarMenu')),
},
{
name: 'custom-selected-state',
title: 'Custom selected state',
component: lazy(() => import('./customSelectedState')),
},
],
})

0 comments on commit 657b83e

Please sign in to comment.