Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions packages/samples/react/src/components/split-button/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
import React from 'react';

import { ToasterService } from '@public-ui/components';
import { KolSplitButton } from '@public-ui/react';
import { KolSplitButton, KolToolbar, KolHeading } from '@public-ui/react';
import { SampleDescription } from '../SampleDescription';
import { useToasterService } from '../../hooks/useToasterService';

import type { FC } from 'react';

export const SplitButtonBasic: FC = () => {
const toaster = ToasterService.getInstance(document);
const handleButtonClick = () => {
void toaster.enqueue({
description: 'The Button has been clicked.',
label: `Button Clicked`,
type: 'info',
});
const { buttonWithTextClickEventHandler } = useToasterService();
const dummyEventHandler = {
onClick: buttonWithTextClickEventHandler,
};
const TOOLBAR_ITEMS = [
{
_label: 'Save',
_icons: 'codicon codicon-save',
_on: dummyEventHandler,
},
{
_label: 'Move',
_icons: 'codicon codicon-move',
_on: dummyEventHandler,
},
{
_label: 'Delete',
_icons: 'codicon codicon-trash',
_on: dummyEventHandler,
},
];

return (
<>
<SampleDescription>
<p>
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
assigned action. In the second sample no action is assigned and clicking the button opens the context menu instead.
The <code>SplitButton</code> component combines a primary action button with a context menu. Clicking the main button triggers the
<strong> Edit</strong> action. The context menu opens a vertical list of additional actions:
<strong> Save</strong>, <strong>Move</strong>, and <strong>Delete</strong>.
</p>
</SampleDescription>

<div className="flex gap-4">
<KolSplitButton _label="Only the arrow opens" _on={{ onClick: handleButtonClick }}>
Dropdown contents
</KolSplitButton>
<KolSplitButton _label="Button without visible label" _hideLabel _icons="codicon codicon-git-pull-request">
Dropdown contents
</KolSplitButton>
<div className="flex flex-col gap-4">
<KolHeading _label="SplitButton with vertical action list" _level={2} />
<div className="flex gap-4">
<KolSplitButton _label="Edit" _on={dummyEventHandler}>
<KolToolbar _label="Action toolbar" _items={TOOLBAR_ITEMS} _orientation="vertical" />
</KolSplitButton>
</div>
</div>
</>
);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading