Skip to content

Commit

Permalink
Make status bar accessible at 400% zoom by hiding items with priority…
Browse files Browse the repository at this point in the history
… of zero (default) (jupyterlab#14854)

* added @media query with max-width of 320px and added className.

* implementing feedback

* uncommented css file

* Update Playwright Snapshots

* changes max-width to width<= n to fix lint test error

* Update Playwright Snapshots

* took out unneeded line

* Update Playwright Snapshots

* Update Playwright Snapshots

* Update Playwright Snapshots

* Update Playwright Snapshots

* Update Playwright Snapshots

* implementation of feeback

* fixed file conflict

* Update packages/statusbar/src/statusbar.ts

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>

* Update packages/statusbar/src/statusbar.ts

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>

* Update packages/statusbar/src/tokens.ts

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>

* Update packages/statusbar/src/statusbar.ts

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>

* moved items to where they are defined.

* fixed device pixel ratio issue.

* Update packages/statusbar/src/statusbar.ts

Co-authored-by: gabalafou <gabriel@fouasnon.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update packages/statusbar/src/statusbar.ts

Co-authored-by: gabalafou <gabriel@fouasnon.com>

* Update packages/statusbar/src/statusbar.ts

Co-authored-by: gabalafou <gabriel@fouasnon.com>

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
Co-authored-by: gabalafou <gabriel@fouasnon.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
  • Loading branch information
6 people authored Dec 20, 2023
1 parent 6a86d8f commit 9956d5c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/application-extension/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ const modeSwitchPlugin: JupyterFrontEndPlugin<void> = {
modeSwitch.label = trans.__('Simple');

statusBar.registerStatusItem(modeSwitchPlugin.id, {
priority: 1,
item: modeSwitch,
align: 'left',
rank: -1
Expand Down
1 change: 1 addition & 0 deletions packages/apputils-extension/src/statusbarplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const kernelStatus: JupyterFrontEndPlugin<IKernelStatusModel> = {
}

statusBar.registerStatusItem(kernelStatus.id, {
priority: 1,
item,
align: 'left',
rank: 1,
Expand Down
1 change: 1 addition & 0 deletions packages/codemirror-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const lineColItem: JupyterFrontEndPlugin<IPositionModel> = {
if (statusBar) {
// Add the status item to the status bar.
statusBar.registerStatusItem(lineColItem.id, {
priority: 1,
item,
align: 'right',
rank: 2,
Expand Down
1 change: 1 addition & 0 deletions packages/notebook-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ export const commandEditItem: JupyterFrontEndPlugin<void> = {
});

statusBar.registerStatusItem('@jupyterlab/notebook-extension:mode-status', {
priority: 1,
item,
align: 'right',
rank: 4,
Expand Down
21 changes: 17 additions & 4 deletions packages/statusbar/src/statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class StatusBar extends Widget implements IStatusBar {
...Private.statusItemDefaults,
...statusItem
} as Private.IFullItem;
const { align, item, rank } = fullStatusItem;
const { align, item, rank, priority } = fullStatusItem;

// Connect the activeStateChanged signal to refreshing the status item,
// if the signal was provided.
Expand All @@ -62,7 +62,7 @@ export class StatusBar extends Widget implements IStatusBar {
fullStatusItem.activeStateChanged.connect(onActiveStateChanged);
}

const rankItem = { id, rank };
const rankItem = { id, rank, priority };

fullStatusItem.item.addClass('jp-StatusBar-Item');
this._statusItems[id] = fullStatusItem;
Expand Down Expand Up @@ -112,6 +112,14 @@ export class StatusBar extends Widget implements IStatusBar {
super.dispose();
}

private _isWindowNarrow = () => {
// The value for 630px was chosen by trial and error.
// When the screen width drops below 630px, there is no
// longer enough space for all the items in the status bar
// (with notebook open), and items become clipped.
return window.innerWidth <= 630;
};

/**
* Handle an 'update-request' message to the status bar.
*/
Expand All @@ -129,7 +137,10 @@ export class StatusBar extends Widget implements IStatusBar {

private _refreshItem(id: string) {
const statusItem = this._statusItems[id];
if (statusItem.isActive()) {
if (
statusItem.isActive() &&
!(statusItem.priority === 0 && this._isWindowNarrow())
) {
statusItem.item.show();
statusItem.item.update();
} else {
Expand Down Expand Up @@ -163,6 +174,7 @@ namespace Private {
export const statusItemDefaults: Omit<IStatusBar.IItem, 'item'> = {
align: 'left',
rank: 0,
priority: 0,
isActive: () => true,
activeStateChanged: undefined
};
Expand All @@ -173,9 +185,10 @@ namespace Private {
export interface IRankItem {
id: string;
rank: number;
priority?: number;
}

export type DefaultKeys = 'align' | 'rank' | 'isActive';
export type DefaultKeys = 'align' | 'rank' | 'isActive' | 'priority';

/**
* Type of statusbar item with defaults filled in.
Expand Down
5 changes: 5 additions & 0 deletions packages/statusbar/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export namespace IStatusBar {
*/
rank?: number;

/**
* Displaying Items based on zoom priority -- higher zoom priority gets prioritised when zoom levels increase
*/
priority?: number;

/**
* Whether the item is shown or hidden.
*/
Expand Down

0 comments on commit 9956d5c

Please sign in to comment.