Hi,
I need help with the themeColor property to use in the properties.json file. This property basically manages colors for both Light and Dark modes and then, based on the format, generates output with two classes.
Is it possible to set it to only work with a single color?
I would need to create separate classes for Light and Dark, so I’d like to have two separate themeColor properties, one to generate the Light class and one to generate the Dark class.
Is this feasible?
You set the defaults for dark and light mode in the json. Then inside elements if in light mode (sun toggled on) any colour change in that control will only affect light mode. And vice versa, if in dark mode (moon toggled on), any change to that control will only affect dark mode.
I think you may know this if so can you give an example of what you’re trying to do. I’m sure most anything is achievable via the hooks file.
const transformHook = (rw) => {
// Grab your colour prop, can be a single class or include a dark class.
const bg = rw.props.background?.trim() || "";
// split it into an array, may contain 1 or 2 items
const parts = bg.split(/\s+/);
// there will always be part zero for light or both light and dark
const lightBG = parts[0] || "";
// if there are two parts add part one as dark else just use part 0 as dark
const darkBG = parts[1] || parts[0] || "";
// return new macros
rw.setProps({
lightBG,
darkBG,
node: rw.node
});
}
exports.transformHook = transformHook;