Skip to content

Commit 78e0f67

Browse files
committed
Improves style and titles of toolbar items in notebooks.
Signed-off-by: Jan Bicker <[email protected]>
1 parent b15b639 commit 78e0f67

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

packages/core/src/common/command.ts

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export interface Command {
3737
*/
3838
label?: string;
3939
originalLabel?: string;
40+
/**
41+
* A optional tooltip in addition to the label
42+
*/
43+
tooltip?: string;
4044
/**
4145
* An icon class of this command.
4246
*/
@@ -60,6 +64,7 @@ export namespace Command {
6064
...command,
6165
label: command.label && nls.localize(nlsLabelKey, command.label),
6266
originalLabel: command.label,
67+
tooltip: command.tooltip,
6368
category: nlsCategoryKey && command.category && nls.localize(nlsCategoryKey, command.category) || command.category,
6469
originalCategory: command.category,
6570
};
@@ -70,6 +75,7 @@ export namespace Command {
7075
...command,
7176
label: command.label && nls.localizeByDefault(command.label),
7277
originalLabel: command.label,
78+
tooltip: command.tooltip,
7379
category: command.category && nls.localizeByDefault(command.category),
7480
originalCategory: command.category,
7581
};

packages/notebook/src/browser/contributions/notebook-actions-contribution.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ export namespace NotebookCommands {
3232

3333
export const ADD_NEW_MARKDOWN_CELL_COMMAND = Command.toDefaultLocalizedCommand({
3434
id: 'notebook.add-new-markdown-cell',
35-
iconClass: codicon('add')
35+
iconClass: codicon('add'),
36+
tooltip: nls.localizeByDefault('Add Markdown Cell')
3637
});
3738

3839
export const ADD_NEW_CODE_CELL_COMMAND = Command.toDefaultLocalizedCommand({
3940
id: 'notebook.add-new-code-cell',
40-
iconClass: codicon('add')
41+
iconClass: codicon('add'),
42+
tooltip: nls.localizeByDefault('Add Code Cell')
4143
});
4244

4345
export const SELECT_KERNEL_COMMAND = Command.toDefaultLocalizedCommand({

packages/notebook/src/browser/view/notebook-main-toolbar.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class NotebookMainToolbar extends React.Component<NotebookMainToolbarProp
8585
return <div className='theia-notebook-main-toolbar'>
8686
{this.getMenuItems().map(item => this.renderMenuItem(item))}
8787
<div style={{ flexGrow: 1 }}></div>
88-
<div className='theia-notebook-main-toolbar-item'
88+
<div className='theia-notebook-main-toolbar-item action-label'
8989
onClick={() => this.props.commandRegistry.executeCommand(NotebookCommands.SELECT_KERNEL_COMMAND.id, this.props.notebookModel)}>
9090
<span className={codicon('server-environment')} />
9191
<span className=' theia-notebook-main-toolbar-item-text'>
@@ -103,7 +103,8 @@ export class NotebookMainToolbar extends React.Component<NotebookMainToolbarProp
103103
{itemNodes && itemNodes.length > 0 && <span key={`${item.id}-separator`} className='theia-notebook-toolbar-separator'></span>}
104104
</React.Fragment>;
105105
} else if (!item.when || this.props.contextKeyService.match(item.when)) {
106-
return <div key={item.id} title={item.id} className='theia-notebook-main-toolbar-item'
106+
const title = this.props.commandRegistry.getCommand(item.command ?? '')?.tooltip ?? item.label;
107+
return <div key={item.id} title={title} className='theia-notebook-main-toolbar-item action-label'
107108
onClick={() => {
108109
if (item.command) {
109110
this.props.commandRegistry.executeCommand(item.command, this.props.notebookModel);

0 commit comments

Comments
 (0)