So this is some interesting behavior I found...
I couldn't get the themes working with a defaultFlavour set (I think it was mocha or latte), so I investigated in the generated CSS and saw that my root styles were not on top of the document. CSS literally means Cascading Style Sheet, so this is a bug and shouldn't be happening.
The problem is the variants map, which has a fixed order and doesn't put the defaultFlavour dynamically on top of the other variants (in first place/index inside the map).
I edited the plugin myself and made a fix for this... I could enhance this and contribute later when I have some free time.
// generates the css variables, injected in the addBase() function
const generateColorCss = (defaultFlavour = "", prefix = false) => {
const result = {};
variants.map((variant) => {
// if a prefix is defined, use e.g. '.ctp-mocha' instead of '.mocha'
const className = prefix ? `.${prefix}-${variant}` : `.${variant}`;
// if the current variant is defaultFlavour, add to ':root'
const keyName = variant === defaultFlavour ? ":root" : className;
result[keyName] = {};
colours.map((colour) => {
result[keyName][`--ctp-${colour}`] = parseHexToRGB(
palette[variant][colour]
);
});
});
return result;
};
// generates the css variables, injected in the addBase() function
const generateColorCss = (defaultFlavour = "", prefix = false) => {
const result = {};
if (variants.includes(defaultFlavour)) {
const defaultIndex = variants.indexOf(defaultFlavour);
const rootElement = variants.splice(defaultIndex, 1)[0];
variants.unshift(rootElement);
}
variants.map((variant) => {
// if a prefix is defined, use e.g. '.ctp-mocha' instead of '.mocha'
const className = prefix ? `.${prefix}-${variant}` : `.${variant}`;
// if the current variant is defaultFlavour, add to ':root'
const keyName = variant === defaultFlavour ? ":root" : className;
result[keyName] = {};
colours.map((colour) => {
result[keyName][`--ctp-${colour}`] = parseHexToRGB(
palette[variant][colour]
);
});
});
return result;
};
If someone wants a more detailed description:
The variants map looks like this (if I can remember correctly):
- latte
- frappe
- macchiato
- mocha
The classes get added to the CSS in this order. If your defaultFlavour is mocha, it gets added as root element.
Now the Problem is this: When you want to apply the latte theme it gets overridden by the mocha root variants, which is not good.