Skip to content

Commit 5a1a164

Browse files
krassowskiagriyakhetarpalgithub-actions[bot]
authored
Align menu styling with Figma (#281)
* Implement caret collapse icon inside menus * Fix a typo Co-authored-by: Agriya Khetarpal <[email protected]> * Drop icon for now, add aria placeholders * Update Playwright Snapshots --------- Co-authored-by: Agriya Khetarpal <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent fc12f02 commit 5a1a164

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

src/ui-components/DownloadDropdownButton.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ReactWidget, ToolbarButtonComponent } from '@jupyterlab/ui-components';
22
import { CommandRegistry } from '@lumino/commands';
3+
import { UUID } from '@lumino/coreutils';
34
import { Menu } from '@lumino/widgets';
45
import React from 'react';
56
import { EverywhereIcons } from '../icons';
@@ -12,8 +13,10 @@ export class DownloadDropdownButton extends ReactWidget {
1213

1314
this._menu = new Menu({ commands });
1415
this._menu.addClass('je-DownloadDropdownButton-menu');
16+
this._menu.addClass('je-DropdownMenu');
1517
this._menu.addItem({ command: 'jupytereverywhere:download-pdf' });
1618
this._menu.addItem({ command: 'jupytereverywhere:download-notebook' });
19+
this._menu.id = UUID.uuid4();
1720
}
1821

1922
render(): React.ReactElement {
@@ -24,13 +27,18 @@ export class DownloadDropdownButton extends ReactWidget {
2427
label="Download"
2528
tooltip="Download notebook"
2629
onClick={this._showMenu.bind(this)}
30+
// Aria attributes will only work once https://github.com/jupyterlab/jupyterlab/issues/18037 is solved and dependencies are updated
31+
aria-expanded={this._menu.isVisible}
32+
aria-controls={this._menu.id}
33+
aria-haspopup={true}
2734
/>
2835
);
2936
}
3037

3138
private _showMenu(): void {
32-
const rect = this.node.getBoundingClientRect();
33-
this._menu.open(rect.left, rect.top);
39+
const node = this.node.querySelector('jp-button') ?? this.node;
40+
const rect = node.getBoundingClientRect();
41+
this._menu.open(rect.left, rect.top - 4);
3442
}
3543

3644
private _menu: Menu;

src/ui-components/KernelSwitcherDropdownButton.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from 'react';
2+
import { CommandRegistry } from '@lumino/commands';
3+
import { UUID } from '@lumino/coreutils';
24
import { Menu } from '@lumino/widgets';
35
import { Message } from '@lumino/messaging';
46
import { ToolbarButtonComponent, ReactWidget } from '@jupyterlab/ui-components';
57
import { EverywhereIcons } from '../icons';
6-
import { CommandRegistry } from '@lumino/commands';
78
import { ACTIVE_KERNELS, KERNEL_DISPLAY_NAMES } from '../kernels';
89
import { INotebookTracker } from '@jupyterlab/notebook';
910

@@ -20,6 +21,8 @@ export class KernelSwitcherDropdownButton extends ReactWidget {
2021
this._tracker = tracker;
2122
this._menu = new Menu({ commands });
2223
this._menu.addClass('je-KernelSwitcherDropdownButton-menu');
24+
this._menu.addClass('je-DropdownMenu');
25+
this._menu.id = UUID.uuid4();
2326
}
2427

2528
onAfterAttach(msg: Message): void {
@@ -66,6 +69,10 @@ export class KernelSwitcherDropdownButton extends ReactWidget {
6669
label={label}
6770
tooltip="Switch coding language"
6871
onClick={() => this._showMenu()}
72+
// Aria attributes will only work once https://github.com/jupyterlab/jupyterlab/issues/18037 is solved and dependencies are updated
73+
aria-expanded={this._menu.isVisible}
74+
aria-controls={this._menu.id}
75+
aria-haspopup={true}
6976
/>
7077
);
7178
}
@@ -92,7 +99,8 @@ export class KernelSwitcherDropdownButton extends ReactWidget {
9299
});
93100
}
94101

95-
const rect = this.node.getBoundingClientRect();
96-
this._menu.open(rect.left, rect.top);
102+
const node = this.node.querySelector('jp-button') ?? this.node;
103+
const rect = node.getBoundingClientRect();
104+
this._menu.open(rect.left, rect.top - 4);
97105
}
98106
}

style/base.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@
5555
border: 0;
5656
}
5757

58+
.je-DropdownMenu {
59+
font-size: calc(var(--je-scale) * 24px);
60+
font-weight: 600;
61+
}
62+
63+
.je-DropdownMenu .lm-Menu-itemLabel {
64+
padding: 7px 10px;
65+
}
66+
67+
.je-DropdownMenu .lm-Menu-itemSubmenuIcon,
68+
.je-DropdownMenu .lm-Menu-itemIcon {
69+
display: none;
70+
}
71+
5872
.jp-Dialog-content {
5973
border: 3px solid var(--je-slate-blue);
6074
border-radius: var(--je-dialog-round-corners);
1.22 KB
Loading
958 Bytes
Loading

0 commit comments

Comments
 (0)