I have a VueJS app. It implements a multiple themes functionality. For that I'm using something like this:
let theme = getTheme() // returns 'light' | dark
document.documentElement.setAttribute('data-theme', theme)
And color styles for the default(light) theme and for the dark theme
:root {
--primary-color: #6B59CC;
--primary-color-rgb: #{hexToRGB(#6B59CC)};
--secondary-green-color: #009a76;
--secondary-green-color-rgb: #{hexToRGB(#009a76)};
--secondary-orange-color: #F6933E;
--secondary-orange-color-rgb: #{hexToRGB(#F6933E)};
...
}
[data-theme="dark"] {
--primary-color: #6B59CC;
--primary-color-rgb: #{hexToRGB(#6B59CC)};
--secondary-green-color: #009a76;
--secondary-green-color-rgb: #{hexToRGB(#009a76)};
--secondary-orange-color: #F6933E;
--secondary-orange-color-rgb: #{hexToRGB(#F6933E)};
...
}
NOTE: please don't mind that styles are the same for the both light and dark theme. This just an example.
I need to use different icon color for each theme. For example: the light theme's base icon color is #a8a8a8, and for the dark theme's base icon color is #cfcfcf.
How to change icon's color dynamicly? Or there are multiple way to implement this in the world?
P.S. I use SVG icons with object tag. Like this:
<object :data="require('./assets/home.svg')" />