google / blockly

The web-based visual programming editor.
https://developers.google.com/blockly/
Apache License 2.0
12.5k stars 3.72k forks source link

Add a Generic CSS Class Config Option to Fields #2884

Closed BeksOmega closed 4 days ago

BeksOmega commented 5 years ago

Is your feature request related to a problem? Please describe.

It would be nice for outside developers to have more control over the on-block display of different fields, especially if they are trying to customize the look-and-feel of Blockly for different audiences.

Describe the solution you'd like

The ability to pass a class string to the JS Constructor's optconfig property or the JSON Definition of a field would be one way to accomplish this. The string would then be appended to the field's fieldGroup during initialization.

Describe alternatives you've considered

Open Problems

CSS API Currently I don't believe the CSS or DOM structure are considered to be part of Blockly's public API. Adding the ability to apply classes to fields would, in a way, make them part of the public API because fields' structures and css would have to become stable, so as not to break people.

The CSS should probably be reorganized before trying to complete this issue.

Relation to Themes Themes make the colours of blockly dynamic, which is rad, but there's no way to access those colours from CSS (as far as I know). This could complicate things.

Field Sizing Currently field sizing is handled programatically. This makes it less flexible when trying to impliment CSS. For example if an outside developer added a class to a colour field that made it taller or wider than default, it would not be handled correctly by the renderer.

Editors It may also be useful for outside developers to style the editor of a field (angle fields come to mind as a good example).

samelhusseini commented 5 years ago

I agree, I think it makes sense to have class be dealt with in the Field's base class configuration.