Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
439d014
:sparkles: feat(block): Scratch-styled zoom controls
SimonShiki Nov 27, 2025
1751738
:recycle: chore(block): copied zoom controls implementation
SimonShiki Nov 28, 2025
ac600bd
:construction: merge(block): update branch with feat/modern-blockly/main
SimonShiki Nov 29, 2025
be0a62f
:lipstick: style(block): make comment rounded
alexcui03 Nov 29, 2025
c20e2af
:wrench: chore(block): use css vars to manage styles
SimonShiki Nov 29, 2025
509cd52
:wrench: chore(block): apply some styles
SimonShiki Nov 29, 2025
3778911
:wrench: chore(block): show boolean connection highlight correctly
SimonShiki Nov 29, 2025
dadf95b
:wrench: chore(block): add drop shadow for block/workspace comment
SimonShiki Nov 29, 2025
85be289
:lipstick: style(block): add various styles
SimonShiki Nov 30, 2025
6efe54d
:lipstick: chore(block): css-variable controlled styles
SimonShiki Nov 30, 2025
2b2757e
:wrench: chore(block): make zoom control more recognizable
SimonShiki Nov 30, 2025
d60eb96
:sparkles: feat(block): configurable theme
SimonShiki Dec 3, 2025
03b23ec
:wrench: chore(block): use monkey-patch to apply Scratch-styled zoom …
SimonShiki Dec 3, 2025
6c35b89
:lipstick: chore(block): add flyout&toolbox border
SimonShiki Dec 3, 2025
f6177aa
:wrench: chore(block): correct css var usage
SimonShiki Dec 3, 2025
2c9106b
:construction: merge: update branch with feat/modern-blockly/main
SimonShiki Dec 3, 2025
9bd9c47
:wrench: chore(block): typo & rebundant codes
SimonShiki Dec 3, 2025
699c0f0
:wrench: chore(block): simplify css
SimonShiki Dec 4, 2025
347acfc
:wrench: chore(block): build category styles from block styles
SimonShiki Dec 15, 2025
bd0f264
:bug: fix(block): keep bowler hat
SimonShiki Dec 15, 2025
aaabafb
:construction: merge: update branch with feat/modern-blockly/main
SimonShiki Dec 15, 2025
05a6f92
:wrench: chore(block): use lower camel case
SimonShiki Dec 15, 2025
a425235
:wrench: chore(block): refine theme exports
SimonShiki Dec 20, 2025
c4580e1
:wrench: chore(block): abstract IZoomControls
SimonShiki Dec 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/block/src/blocks/procedures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,12 @@ Blockly.Blocks['procedures_definition'] = {
});
this.hat = Constants.SHAPE_BOWLER_HAT;
},
setStyle: function(blockStyleName: string) {
Comment thread
SimonShiki marked this conversation as resolved.
// equivalent to super.setStyle()
const proto: Blockly.Block = Object.getPrototypeOf(this);
proto.setStyle.call(this, blockStyleName);
this.hat = Constants.SHAPE_BOWLER_HAT;
},
/**
* The method called during disposal.
*/
Expand Down
263 changes: 0 additions & 263 deletions packages/block/src/colours.ts

This file was deleted.

27 changes: 19 additions & 8 deletions packages/block/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import * as Blockly from 'blockly/core';

import * as Constants from './constants';
import {createTheme} from './colours';
import {injectCssVariables, Scratch} from './theme';
import {registerScratchContextMenu} from './contextmenu_items';
import {registerFieldAngle} from './fields/angle';
import {registerFieldButton} from './fields/button';
Expand All @@ -20,6 +20,7 @@ import {registerFieldVerticalSeparator} from './fields/vertical_separator';
import {flyoutCategory as variableCategory} from './data_category';
import {flyoutCategory as procedureCategory} from './procedures_category';
import {isProcedureCallBlock, isProcedurePrototypeBlock} from './blocks/procedures';
import {ZoomControls} from './zoom_controls';
import styles from './styles/blockly.css';
import commentStyles from './styles/comment.css';

Expand Down Expand Up @@ -85,7 +86,7 @@ export function inject(container: Element | string, options?: Blockly.BlocklyOpt
registerScratchContextMenu();

// Register styles.

injectCssVariables();
Blockly.Css.register(styles);
Blockly.Css.register(commentStyles);

Expand Down Expand Up @@ -146,10 +147,12 @@ export function inject(container: Element | string, options?: Blockly.BlocklyOpt
export function injectWorkspace(container: Element | string, options?: Blockly.BlocklyOptions) {
const defaultOptions: Blockly.BlocklyOptions = {
renderer: 'scratch',
theme: createTheme()
theme: Scratch
};
options = Object.assign(defaultOptions, options);
return Blockly.inject(container, options);
const workspace = Blockly.inject(container, options);

return workspace;
}

/**
Expand All @@ -176,13 +179,21 @@ export function loadWorkspace(
Blockly.serialization.workspaces.load(state, workspace, {recordUndo});
}

export {reportValue} from './report_value';
export const setLocale = Blockly.setLocale;
export * as callbackRegistry from './callback_registry';

// Monkey-patches
Blockly.Scrollbar.scrollbarThickness = Blockly.Touch.TOUCH_ENABLED ? 14 : 11;
Blockly.FlyoutButton.TEXT_MARGIN_X = 40;
Blockly.FlyoutButton.TEXT_MARGIN_Y = 10;
Blockly.comments.CommentView.defaultCommentSize = new Blockly.utils.Size(200, 200);
Blockly.ToolboxCategory.nestedPadding = 6;

Blockly.WorkspaceSvg.prototype.addZoomControls = function() {
this.zoomControls_ = new ZoomControls(this) as unknown as Blockly.ZoomControls;
Comment thread
SimonShiki marked this conversation as resolved.
const svgZoomControls = this.zoomControls_.createDom();
this.svgGroup_.appendChild(svgZoomControls);
Comment thread
SimonShiki marked this conversation as resolved.
};

export {reportValue} from './report_value';
export const setLocale = Blockly.setLocale;
export * as callbackRegistry from './callback_registry';
export * as Theme from './theme';

22 changes: 19 additions & 3 deletions packages/block/src/renderer/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import * as Blockly from 'blockly/core';
import {Colours} from '../theme';

/**
* An object that provides constants for rendering blocks in Scratch mode.
Expand Down Expand Up @@ -54,7 +55,7 @@ export class ConstantProvider extends Blockly.zelos.ConstantProvider {
`}`,
``,
`${selector} .blocklyFlyoutButtonBackground {`,
`stroke: #c6c6c6;`,
`stroke: var(--clipcc-block-flyoutBorder);`,
`}`,
``,
`${selector} .blocklyFlyoutButtonShadow {`,
Expand All @@ -67,13 +68,28 @@ export class ConstantProvider extends Blockly.zelos.ConstantProvider {
`}`,
``,
`${selector} .blocklyFlyoutButton .blocklyText {`,
`fill: #575E75;`,
`fill: var(--clipcc-block-toolboxText, ${Colours.textFieldText});`,
`font-weight: 500;`,
`}`,
``,
`${selector} .blocklyCommentText.blocklyText {`,
`font-weight: 400;`,
`color: #575e75;`, // @TODO: Use CSS variable. (same as --clipcc-text-primary)
`color: var(--clipcc-block-textFieldText, ${Colours.textFieldText});`,
`}`,
``,
`${selector} .blocklyHighlightedConnectionPath {`,
`stroke: transparent;`,
`}`,
``,
// Boolean connection highlight override
`${selector} .blocklyOutlinePath ~ .blocklyHighlightedConnectionPath,`,
`${selector} .blocklyHighlightedConnectionPath:has(~ .blocklyOutlinePath) {`,
`stroke: var(--clipcc-block-replacementGlow, ${Colours.replacementGlow});`,
`}`,
`${selector} .blocklyFlyoutLabelText {`,
`font-family: "Helvetica Neue", Helvetica, sans-serif;`,
`font-size: 14pt;`,
`font-weight: bold;`,
`}`
];
return css.concat(flyoutButtonStyle);
Expand Down
Loading