File tree Expand file tree Collapse file tree 2 files changed +28
-14
lines changed Expand file tree Collapse file tree 2 files changed +28
-14
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { IIterator, ArrayIterator } from '@lumino/algorithm';
99import * as Blockly from 'blockly' ;
1010
1111import { BlocklyManager } from './manager' ;
12+ import { THEME } from './utils' ;
1213
1314/**
1415 * A blockly layout to host the Blockly editor.
@@ -113,13 +114,16 @@ export class BlocklyLayout extends PanelLayout {
113114 /**
114115 * Handle `after-attach` messages sent to the widget.
115116 */
116- protected onAfterAttach ( msg : Message ) : void {
117+ protected onAfterAttach ( msg : Message ) : void {
118+ //inject Blockly with appropiate JupyterLab theme.
117119 this . _workspace = Blockly . inject ( this . _host , {
118- toolbox : this . _manager . toolbox
120+ toolbox : this . _manager . toolbox ,
121+ theme : THEME
119122 } ) ;
120123 }
121124
122125 private _resizeWorkspace ( ) : void {
126+ //Resize logic.
123127 const rect = this . parent . node . getBoundingClientRect ( ) ;
124128 const { height } = this . _outputArea . node . getBoundingClientRect ( ) ;
125129 this . _host . style . width = rect . width + 'px' ;
Original file line number Diff line number Diff line change 1+ import * as Blockly from 'blockly' ;
2+
3+ // Creating a toolbox containing all the main (default) blocks.
14export const TOOLBOX = {
2- //kind: 'flyoutToolbox',
3- // contents: [
4- // {
5- // kind: 'block',
6- // type: 'controls_if'
7- // },
8- // {
9- // kind: 'block',
10- // type: 'controls_whileUntil'
11- // }
12- // ]
13- //{
145 kind : 'categoryToolbox' ,
156 contents : [
167 {
@@ -360,3 +351,22 @@ export const TOOLBOX = {
360351 }
361352 ]
362353} ;
354+
355+ // Defining a Blockly Theme in accordance with the current JupyterLab Theme.
356+ const jupyterlab_theme = Blockly . Theme . defineTheme ( 'jupyterlab' , {
357+ 'base' : Blockly . Themes . Classic ,
358+ 'componentStyles' : {
359+ 'workspaceBackgroundColour' : 'var(--jp-layout-color0)' ,
360+ 'toolboxBackgroundColour' : 'var(--jp-layout-color2)' ,
361+ 'toolboxForegroundColour' : 'var(--jp-ui-font-color0)' ,
362+ 'flyoutBackgroundColour' : 'var(--jp-border-color2)' ,
363+ 'flyoutForegroundColour' : 'var(--jp-layout-color3)' ,
364+ 'flyoutOpacity' : 1 ,
365+ 'scrollbarColour' : 'var(--jp-border-color0)' ,
366+ 'insertionMarkerOpacity' : 0.3 ,
367+ 'scrollbarOpacity' : 0.4 ,
368+ 'cursorColour' : 'var(--jp-scrollbar-background-color)' ,
369+ }
370+ } ) ;
371+
372+ export const THEME : Blockly . Theme = jupyterlab_theme ;
You can’t perform that action at this time.
0 commit comments