Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable themed scrollbars by default? #15608

Open
jtpio opened this issue Jan 5, 2024 · 7 comments
Open

Enable themed scrollbars by default? #15608

jtpio opened this issue Jan 5, 2024 · 7 comments

Comments

@jtpio
Copy link
Member

jtpio commented Jan 5, 2024

Problem

By default scrollbars are not themed (the setting is turned off).

This makes them somehow stand out when using dark themes, for example:

image

When enabled, one can argue they look nicer:

image

Proposed Solution

Enable "Theme Scrollbars" by default.

The setting is currently defined here:

"theme-scrollbars": {
"type": "boolean",
"title": "Scrollbar Theming",
"description": "Enable/disable styling of the application scrollbars",
"default": false
},

The idea would be to make it true by default.

Additional context

While this looks like a simple change to make, there might be some implications (accessibility?) for having the setting enabled by default?

@jtpio jtpio added enhancement status:Needs Triage Applied to new issues that need triage labels Jan 5, 2024
@JasonWeill JasonWeill removed the status:Needs Triage Applied to new issues that need triage label Jan 9, 2024
@jtpio
Copy link
Member Author

jtpio commented Jan 9, 2024

For reference the screenshots above were taken on Ubuntu 23.10 with Chromium 120.

@krassowski
Copy link
Member

So there are two things to consider:

  • performance implications on Chromium - this was mostly addressed in Load ::-webkit-scrollbar styles on-demand #14275 so I think we are fine here (but there is still a small penalty)
  • the support for standard CSS styling (e.g. scollbar-color, -width and -gutter) being nearly there (we are waiting for Chromium, currently in preview): - once it is supported widely we could adjust the dark theme which would possibly give even better UX as it would retain OS-specific scrollbar look and feel
    • still would benefit from performance testing, but from my reading of MRs it should be as fast or faster than the existing prefixed methods.

@pplonski
Copy link

Is it possible to have extension that enable themed scrollbars?

I have schema/plugin.json file and tried below code but it is not working:

{
  "jupyter.lab.shortcuts": [],
  "title": "pieceofcode",
  "description": "pieceofcode settings.",
  "type": "object",
  "properties": {
    "alwaysOpenPieceOfCode": {
      "type": "boolean",
      "title": "alwaysOpenPieceOfCode",
      "description": "Always Open Piece of Code",
      "default": true
    },
    "theme-scrollbars": { 
      "type": "boolean", 
      "title": "Scrollbar Theming", 
      "description": "Enable/disable styling of the application scrollbars", 
      "default": true
    }
  },
  "additionalProperties": false,
  "jupyter.lab.toolbars": {
    "Cell": [
      {
        "name": "open-piece-of-code",
        "command": "@mljar/pieceofcode:open"
      },
      {
        "name": "hide-piece-of-code",
        "command": "@mljar/pieceofcode:hide"
      }
    ]
  }
}

@krassowski
Copy link
Member

JupyterLab 4.3 will advertise the color theme allowing the scrollbars to automatically adjust to the application color, see:

without forcing custom styling of scrollbars.

So with "Theme Scrollbars" option disabled (default):

Before After
Screenshot from 2024-05-07 14-45-26 Screenshot from 2024-05-07 14-45-00

@krassowski
Copy link
Member

@pplonski in previous versions you can require IThemeManager token and invoke toggleThemeScrollbars() method conditionally on isToggledThemeScrollbars(). You will would need to cast manager: IThemeManager to ThemeManager for typechecking purposes as these methods are not formally part of IThemeManager interface and may not work if another plugin provides a custom implementation of the theme manager.

@pplonski
Copy link

Thank you @krassowski! You respond with speed of 🚀 I will try with IThemeManager :)

@pplonski
Copy link

It is working as expected 👍

Here is my code:

import {
  IThemeManager,
  ThemeManager
} from '@jupyterlab/apputils';

const plugin: JupyterFrontEndPlugin<void> = {
  id: 'pieceofcode:plugin',
  description: 'Write code with UI.',
  autoStart: true,
  optional: [ISettingRegistry, IThemeManager],
  activate: async (
    app: JupyterFrontEnd,
    settingRegistry: ISettingRegistry | null,
    themeManager: IThemeManager
  ) => {
    console.log('Piece of Code extension is activated!');
    const tm = themeManager as ThemeManager;
    if(tm) {
      if(!tm.isToggledThemeScrollbars())
      tm.toggleThemeScrollbars();
    }
    // rest of code

Thank you @krassowski, you are Jupyter legend 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants