Skip to content

Commit ba9c803

Browse files
authored
feat: toolbar title support (#6740) (#6869)
1 parent 6604c2d commit ba9c803

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

packages/g6/__tests__/demos/plugin-toolbar-build-in.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ export const pluginToolbarBuildIn: TestCase = async (context) => {
1616
},
1717
getItems: () => {
1818
return [
19-
{ id: 'zoom-in', value: 'zoom-in' },
20-
{ id: 'zoom-out', value: 'zoom-out' },
21-
{ id: 'redo', value: 'redo' },
22-
{ id: 'undo', value: 'undo' },
23-
{ id: 'edit', value: 'edit' },
24-
{ id: 'delete', value: 'delete' },
25-
{ id: 'auto-fit', value: 'auto-fit' },
26-
{ id: 'export', value: 'export' },
27-
{ id: 'reset', value: 'reset' },
19+
{ id: 'zoom-in', value: 'zoom-in', title: 'Zoom in' },
20+
{ id: 'zoom-out', value: 'zoom-out', title: 'Zoom out' },
21+
{ id: 'redo', value: 'redo', title: 'Redo' },
22+
{ id: 'undo', value: 'undo', title: 'Undo' },
23+
{ id: 'edit', value: 'edit', title: 'Edit' },
24+
{ id: 'delete', value: 'delete', title: 'Delete' },
25+
{ id: 'auto-fit', value: 'auto-fit', title: 'Auto fit' },
26+
{ id: 'export', value: 'export', title: 'Export' },
27+
{ id: 'reset', value: 'reset', title: 'Reset' },
2828
];
2929
},
3030
},

packages/g6/src/plugins/toolbar/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class Toolbar extends BasePlugin<ToolbarOptions> {
111111
return items
112112
.map(
113113
(item) => `
114-
<div class="g6-toolbar-item" value="${item.value}">
114+
<div class="g6-toolbar-item" value="${item.value}" title="${item.title ?? ''}">
115115
<svg aria-hidden="true" focusable="false">
116116
<use xlink:href="#${item.id}"></use>
117117
</svg>

packages/g6/src/plugins/toolbar/util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export interface ToolbarItem {
1818
* <en/> The value corresponding to the toolbar item, used as a callback parameter in `onClick`.
1919
*/
2020
readonly value: string;
21+
/**
22+
* <en/> The title of the toolbar item. The title will be displayed as a tooltip when the mouse hovers over the item.
23+
*/
24+
readonly title?: string;
2125
}
2226

2327
/**

0 commit comments

Comments
 (0)