pharo-graphics / Toplo

A widget framework on top of Bloc
MIT License
17 stars 8 forks source link

Should Themes be concatenable ? #140

Open Nyan11 opened 2 months ago

Nyan11 commented 2 months ago

Hello,

I have a suggestion of enhancement of ToStyleSheetTheme: concatenation of themes

Example

I have a Theme specialize in Buttons and i have a Theme specialize in Lists. I want a Theme specialized in Buttons and Lists.

Currently i should create a new theme class and add manually the style rules and the tokens for the Buttons and the style rules and the tokens for the Lists.

With concatenation: I concatenate the theme Buttons and the theme Lists in a variable.

buttonsTheme := MyButtonsTheme new.
listsTheme := MyListsTheme new.

buttonsAndListsTheme := buttonsTheme , listsTheme.

Use cases

multiple applications with small modifications.

I create application A with my main theme and a specialized theme for application A. I create application B with my main theme and a specialized theme for application B.

If i update my main theme, the applicaiton A and application B will be updated since they have a the same main theme.

managing simplier theme classes

We could imagine having a theme composed of the theme Buttons, the theme Lists, the theme Panel, the theme Header, ... We have multiple small themes inside the main theme. I personnaly think smaller classes will be easier to understand and modify.

common tokens between multiple theme.

The concatenation will combine the styleRules collection but also the theme tokens. The last Theme in the concatenation will have the priority to modify the value of a token. We could use this property to update the default value of a concatenated theme. The last theme we concatenate contains the default tokens values, like for example the primary color.

lightTheme := MyButtonsTheme new , MyListsTheme new , MyLightColorTheme new.
darkTheme := MyButtonsTheme new , MyListsTheme new , MyDarkColorTheme new.

What do you think of this idea ?

plantec commented 2 months ago

this could be done at stylesheet level I think