Skip to content

feat: Make zoom controls and trash can native SVG #9128

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

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

Conversation

ewpatton
Copy link
Contributor

@ewpatton ewpatton commented Jun 4, 2025

Change-Id: Ied0a26ebfff7a02183a00ddd7d2ed08c4346f65b

The basics

The details

Resolves

Fixes #4821

Proposed Changes

This change inlines the SVG from sprites.svg into the trashcan and zoom control classes, allowing for them to be styled with CSS.

Reason for Changes

Currently, the controls are rendered as PNGs, which makes creating high contrast versions in both regular theme and dark mode both

Test Coverage

Documentation

It may be worth noting in the documentation that product builds on Blockly can override the colors using the .blocklyZoom and .blocklyTrash classes.

Additional Information

Note that to make the controls interactive in Firefox I had to create a non-zero fill opacity, otherwise the mouse events are only captured by the control outlines. We may also want to consider building the SVG based on the other constants rather than the hard coded values taken from sprites.svg.

Change-Id: Ied0a26ebfff7a02183a00ddd7d2ed08c4346f65b
@ewpatton ewpatton requested a review from a team as a code owner June 4, 2025 01:24
@ewpatton ewpatton requested a review from rachel-fenichel June 4, 2025 01:24
@github-actions github-actions bot added the PR: feature Adds a feature label Jun 4, 2025
Change-Id: Iae2ee10ebf7ecb5b99414661271c51c818d69915
@rachel-fenichel rachel-fenichel requested review from gonfunko and removed request for rachel-fenichel June 10, 2025 18:38
@gonfunko
Copy link
Contributor

Thanks for sending this over! In general this looks good, but I'm concerned that there's not a route for developers to fully replace (not just style) the SVGs. Could the SVGs perhaps be stored in the media directory where the PNGs were and loaded from the injected media path? Then we'd have the best of both worlds such that they'd be styleable to address contrast concerns, but also still entirely replaceable to allow for deeper customization.

@ewpatton
Copy link
Contributor Author

@gonfunko We could make the functions protected and allow developers to override them with their own implementations (which could be SVG or PNG).

@gonfunko
Copy link
Contributor

The issue there is that there's not a supported way to replace the Trashcan and ZoomControls classes with subclasses unfortunately. We'd need to make them registerable, which we could do but is a bit more involved.

@ewpatton
Copy link
Contributor Author

@gonfunko If that's a potentially acceptable solution I could go ahead and take a stab at it.

@rachel-fenichel
Copy link
Collaborator

@gonfunko If that's a potentially acceptable solution I could go ahead and take a stab at it.

Yes, that is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feature Adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the trashcan and zoom controls svg(s) instead of a png
3 participants