Replies: 3 comments 1 reply
-
|
The proposed features look awesome! |
Beta Was this translation helpful? Give feedback.
-
|
It looks really good! I agree, we should make sure that the brand is still there somewhere, but it shouldn't be too big or obnoxious. I'm really excited for the themes. I like that color scheme in the last video. Funny enough, I've kind of gone the opposite direction and applied openHAB orange to my other stuff. Even my Framework 16 laptop has the orange beszel and modules. :-D |
Beta Was this translation helpful? Give feedback.
-
|
Nice work. This has the chance to be a really popular feature. For the themes, in particular, it's worth considering not limiting those to just an administrator. I would advocate, letting the administrator select an array of available themes (with one set as default) which can then be configured by any user on a per browser basis. Not only does that give family members the option to customize the OH colors on their own device, but I can see situations where wall tablets in different rooms would benefit from themes that match that room decor. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@florian-h05, @rkoshak, @ghys
One of the requested features I've seen quite a bit (#551, #2902) is to have the ability for adding a custom theme css and logo. I've been working on an implementation for this that would be well integrated into the ui framework. I put together a document here explaining the architecture / implementation. Give this would be a fairly big feature - I thought it would be good for a more formal review to get any suggestions / feedback before I spend more time.
Here's a few videos to show the implementation as it stands today:
Custom logo:
https://drive.google.com/file/d/1G9lJ1jg-ptutp7cX9M3Ufm2_8igoIomA/view?usp=sharing
Override colors:
https://drive.google.com/file/d/1rE7ZA6zGaRryMBbGMrTaIxDgCtKSfKAu/view?usp=sharing
Built-in themes:
https://drive.google.com/file/d/1FBUK3pWSQ1KUQby3Vb-dsmAtqswryYk1/view?usp=sharing
Here's the architecture/implementation details:
Proposal for openHAB UI theme support
Features
How it works
New CSS variables for theme definition
A set of openHAB specific variables are defined that then propagate and redefined the hard-coded f7 color variables and are utilized for echarts, etc.
In addition to these variables, there are also color tone varients for each of these colors automatically created (see Further Work below on limitations). Note, colors designated with ** do not have these varients.
--oh-background-tint-2
Notes
Key Theme Parameters
Primitive Colors
Palette Colors
Framework7 Variables
For instance, is one uses --f7-color-red, the --oh-red-color value will be returned. To reduce the dependency on f7, it is recommended that the --oh-*-color variable be utilized directly in the future.
This allows all f7 components to adapt to the theme. For instance, to apply a color to an element, one simply needs to apply the specific color class. Further, if f7 components offer a "color" prop the appropriate palette color will be used.
Additional Color Classes
Several additional color classes are available to be used to align with theme. These can also be used as "color" props for f7 components (i.e. color: 'theme-alt').
UI configuration settings
Several of the key parameters are available for the admin to override via the configuration settings for the bundle.
These values are then included to the file served from the server endpoint /theme.
One special css value is --oh-logo parameter which can be used to specfy a custom image to use for the upper-left branding left-panel of the ui.
Theme CSS file insertion
The theme file is imported via a special endpoint from the server (/theme).
The server will look at the ui configuration settings to determine what to serve.
Note, the acceptable fields will either be /css/theme-.css for built-in themes, or /static/ for custom themes installed in the conf/html directory on the server.
Note, any color override based on these settings will override any other parameter.
Given that CSS settings are determined by the "last" specified setting, it is important that the /theme css files are loaded in the correct place.
This is accomplished via a special plugin in the vite.config.ts.
Also, to support updates to settings without having to refresh the client app, the client will append a random id to the endpoint (/__theme--123456) which will bust the cache and force a reload.
Also, because this involves new capabilities in the server bundle, the only way to test these features is by installing the new bundle onto the server.
useThemeStore
The primary ways to use color in componets/widgets/elements are:
However, there are times, you might need to get the raw hex value of a color.
To get these values, they can be pulled from the reactive useThemeStore.ohVariables store.
Whenever a new theme is applied (or dark/light mode changes), the css variables are reloaded into the store.
The store is used to set the palette for echarts and also for extracting the --oh-logo variable if one exists to show a custom logo.
Further Work
I tried implementing a @Modified handler, but this was causing stack reset issues in the bundle. (may need help on this one)
Even with the default theme applied, there are still a few areas where things aren't right yet.
Beta Was this translation helpful? Give feedback.
All reactions