Merge pull request #14776 from apapadopoulou/ap/custom-toolbar-items-labels

Addon-toolbars: Add optional label for toolbar items
This commit is contained in:
Michael Shilman 2021-05-03 18:48:20 +08:00 committed by GitHub
commit ee6bd46825
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 1 deletions

View File

@ -9,7 +9,7 @@ export const MenuToolbar: FC<MenuToolbarProps> = ({
id,
name,
description,
toolbar: { icon, items },
toolbar: { icon, items, showName },
}) => {
const [globals, updateGlobals] = useGlobals();
const selectedValue = globals[id];
@ -43,6 +43,7 @@ export const MenuToolbar: FC<MenuToolbarProps> = ({
{selectedIcon ? (
<IconButton key={name} active={active} title={description}>
<Icons icon={selectedIcon} />
{showName ? `\xa0${name}` : null}
</IconButton>
) : (
<TabButton active={active}>{name}</TabButton>

View File

@ -12,6 +12,7 @@ export interface ToolbarItem {
export interface NormalizedToolbarConfig {
icon?: IconsProps['icon'];
items: ToolbarItem[];
showName?: boolean;
}
export type NormalizedToolbarArgType = ArgType & {

View File

@ -10,6 +10,8 @@ export const globalTypes = {
icon: 'circlehollow',
// array of plain string values or MenuItem shape (see below)
items: ['light', 'dark'],
// property that specifies if the name of the item will be displayed
showName: True,
},
},
};

View File

@ -209,6 +209,7 @@ export const globalTypes = {
{ value: 'side-by-side', icon: 'sidebar', title: 'side by side' },
{ value: 'stacked', icon: 'bottombar', title: 'stacked' },
],
showName: true,
},
},
locale: {