|
1 | 1 | import { isChromatic } from '@sb/utils.js'; |
2 | 2 | import type { Meta, StoryObj } from '@storybook/react'; |
| 3 | +import addDocumentIcon from '@ui5/webcomponents-icons/dist/add-document.js'; |
| 4 | +import boldTextIcon from '@ui5/webcomponents-icons/dist/bold-text.js'; |
| 5 | +import italicTextIcon from '@ui5/webcomponents-icons/dist/italic-text.js'; |
| 6 | +import lockedIcon from '@ui5/webcomponents-icons/dist/locked.js'; |
| 7 | +import textAlignCenterIcon from '@ui5/webcomponents-icons/dist/text-align-center.js'; |
| 8 | +import textAlignLeftIcon from '@ui5/webcomponents-icons/dist/text-align-left.js'; |
| 9 | +import textAlignRightIcon from '@ui5/webcomponents-icons/dist/text-align-right.js'; |
| 10 | +import underlineTextIcon from '@ui5/webcomponents-icons/dist/underline-text.js'; |
3 | 11 | import { useEffect, useRef, useState } from 'react'; |
4 | 12 | import { Button } from '../Button/index.js'; |
5 | 13 | import { MenuItem } from '../MenuItem/index.js'; |
| 14 | +import { MenuItemGroup } from '../MenuItemGroup/index.js'; |
6 | 15 | import { MenuSeparator } from '../MenuSeparator/index.js'; |
7 | 16 | import { Menu } from './index.js'; |
8 | 17 |
|
@@ -113,3 +122,55 @@ export const WithSubMenu: Story = { |
113 | 122 | ); |
114 | 123 | }, |
115 | 124 | }; |
| 125 | + |
| 126 | +export const WithMenuItemGroup: Story = { |
| 127 | + name: 'with MenuItemGroup', |
| 128 | + render(args) { |
| 129 | + const [open, setOpen] = useState(args.open); |
| 130 | + const btnRef = useRef(null); |
| 131 | + |
| 132 | + useEffect(() => { |
| 133 | + setOpen(args.open); |
| 134 | + }, [args.open]); |
| 135 | + return ( |
| 136 | + <> |
| 137 | + <Button |
| 138 | + ref={btnRef} |
| 139 | + onClick={() => { |
| 140 | + setOpen((prev) => !prev); |
| 141 | + }} |
| 142 | + > |
| 143 | + Show Menu |
| 144 | + </Button> |
| 145 | + <Menu |
| 146 | + {...args} |
| 147 | + open={open} |
| 148 | + opener={btnRef.current} |
| 149 | + onClose={(e) => { |
| 150 | + args.onClose(e); |
| 151 | + setOpen(false); |
| 152 | + }} |
| 153 | + > |
| 154 | + <MenuItem text="New Paragraph" icon={addDocumentIcon} /> |
| 155 | + <MenuItem text="New Text" /> |
| 156 | + <MenuSeparator /> |
| 157 | + <MenuItemGroup checkMode="Single"> |
| 158 | + <MenuItem text="Left Alignment" icon={textAlignLeftIcon} checked /> |
| 159 | + <MenuItem text="Center Alignment" icon={textAlignCenterIcon} checked /> |
| 160 | + <MenuItem text="Right Alignment" icon={textAlignRightIcon} checked /> |
| 161 | + </MenuItemGroup> |
| 162 | + <MenuSeparator /> |
| 163 | + <MenuItemGroup checkMode="Multiple"> |
| 164 | + <MenuItem text="Bold" icon={boldTextIcon} checked> |
| 165 | + <Button id="newLock2" slot="endContent" icon={lockedIcon} design="Transparent" /> |
| 166 | + </MenuItem> |
| 167 | + <MenuItem text="Italic" icon={italicTextIcon} additionalText="Cursive Text" checked /> |
| 168 | + <MenuItem text="Underline" icon={underlineTextIcon} checked /> |
| 169 | + </MenuItemGroup> |
| 170 | + <MenuSeparator /> |
| 171 | + <MenuItem text="Exit" /> |
| 172 | + </Menu> |
| 173 | + </> |
| 174 | + ); |
| 175 | + }, |
| 176 | +}; |
0 commit comments