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

Expand css variables when setting blockly theme #104

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ykazakov
Copy link

@ykazakov ykazakov commented Oct 24, 2024

This PR should fix #92.

The issue was that the settings in the blockly theme were defined using css variables, which is not a documented way of defining a theme:

// Defining a Blockly Theme in accordance with the current JupyterLab Theme.
const jupyterlab_theme = Blockly.Theme.defineTheme('jupyterlab', {
name: 'JupyterLab Blockly',
base: Blockly.Themes.Classic,
componentStyles: {
workspaceBackgroundColour: 'var(--jp-layout-color0)',
toolboxBackgroundColour: 'var(--jp-layout-color2)',
toolboxForegroundColour: 'var(--jp-ui-font-color0)',
flyoutBackgroundColour: 'var(--jp-border-color2)',
flyoutForegroundColour: 'var(--jp-layout-color3)',
flyoutOpacity: 1,
scrollbarColour: 'var(--jp-border-color0)',
insertionMarkerOpacity: 0.3,
scrollbarOpacity: 0.4,
cursorColour: 'var(--jp-scrollbar-background-color)'
},
fontStyle: {
family: 'var(--jp-ui-font-family)'
}
});

Specifically, the var() function can be used in css styles, but not in css shorthand properties, which are used during application of the blockly theme to determine block sizes. Here is a short description of this process in a similar issue. See here for the relevant part of the code.

See here for a quick demo confirming that var() is not working when determining text width using css shorthand properties.

Issue #92 was, therefore, a result of incorrect calculation for the sizes of text fields.

I also made changes to make sure that the sources of the jupyterlab-blockly package are watched in the development installation.

The var() function can be used in css styles, but not in css shorthand properties which are used to calculate the sizes of blocks in blockly. Notice that all blockly examples set style values to fixed values. A solution is to retrieve the values of css variables when setting the theme to the workspace.

Since changes in jupyterlab settings, e.g., selecting a different theme, may result in changes of css styles, the blockly theme needs to be re-applied after each such change.
Copy link
Contributor

Binder 👈 Launch a Binder on branch ykazakov/jupyterlab-blockly/main

@DenisaCG DenisaCG added the bug Something isn't working label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initial text overlap on blocks
2 participants