|
1 | 1 | import React from 'react'; |
2 | 2 |
|
3 | | -import { ToasterService } from '@public-ui/components'; |
4 | | -import { KolSplitButton } from '@public-ui/react'; |
| 3 | +import { KolSplitButton, KolToolbar, KolHeading } from '@public-ui/react'; |
5 | 4 | import { SampleDescription } from '../SampleDescription'; |
| 5 | +import { useToasterService } from '../../hooks/useToasterService'; |
6 | 6 |
|
7 | 7 | import type { FC } from 'react'; |
8 | 8 |
|
9 | 9 | export const SplitButtonBasic: FC = () => { |
10 | | - const toaster = ToasterService.getInstance(document); |
11 | | - const handleButtonClick = () => { |
12 | | - void toaster.enqueue({ |
13 | | - description: 'The Button has been clicked.', |
14 | | - label: `Button Clicked`, |
15 | | - type: 'info', |
16 | | - }); |
| 10 | + const { buttonWithTextClickEventHandler } = useToasterService(); |
| 11 | + const dummyEventHandler = { |
| 12 | + onClick: buttonWithTextClickEventHandler, |
17 | 13 | }; |
| 14 | + const TOOLBAR_ITEMS = [ |
| 15 | + { |
| 16 | + _label: 'Save', |
| 17 | + _icons: 'codicon codicon-save', |
| 18 | + _on: dummyEventHandler, |
| 19 | + }, |
| 20 | + { |
| 21 | + _label: 'Move', |
| 22 | + _icons: 'codicon codicon-move', |
| 23 | + _on: dummyEventHandler, |
| 24 | + }, |
| 25 | + { |
| 26 | + _label: 'Delete', |
| 27 | + _icons: 'codicon codicon-trash', |
| 28 | + _on: dummyEventHandler, |
| 29 | + }, |
| 30 | + ]; |
18 | 31 |
|
19 | 32 | return ( |
20 | 33 | <> |
21 | 34 | <SampleDescription> |
22 | 35 | <p> |
23 | | - SplitButton renders a button with an additional context-menu, that can be opened by clicking the arrow icon. The first sample shows the button with an |
24 | | - assigned action. In the second sample no action is assigned and clicking the button opens the context menu instead. |
| 36 | + The <code>SplitButton</code> component combines a primary action button with a context menu. Clicking the main button triggers the |
| 37 | + <strong> Edit</strong> action. The context menu opens a vertical list of additional actions: |
| 38 | + <strong> Save</strong>, <strong>Move</strong>, and <strong>Delete</strong>. |
25 | 39 | </p> |
26 | 40 | </SampleDescription> |
27 | 41 |
|
28 | | - <div className="flex gap-4"> |
29 | | - <KolSplitButton _label="Only the arrow opens" _on={{ onClick: handleButtonClick }}> |
30 | | - Dropdown contents |
31 | | - </KolSplitButton> |
32 | | - <KolSplitButton _label="Button without visible label" _hideLabel _icons="codicon codicon-git-pull-request"> |
33 | | - Dropdown contents |
34 | | - </KolSplitButton> |
| 42 | + <div className="flex flex-col gap-4"> |
| 43 | + <KolHeading _label="SplitButton with vertical action list" _level={2} /> |
| 44 | + <div className="flex gap-4"> |
| 45 | + <KolSplitButton _label="Edit" _on={dummyEventHandler}> |
| 46 | + <KolToolbar _label="Action toolbar" _items={TOOLBAR_ITEMS} _orientation="vertical" /> |
| 47 | + </KolSplitButton> |
| 48 | + </div> |
35 | 49 | </div> |
36 | 50 | </> |
37 | 51 | ); |
|
0 commit comments