31
loading...
This website collects cookies to deliver better user experience
<ThemeProvider />
which has to be wrapped over the app in order to provide theming context. Vendor lock-in is another disadvantage of using this. We will not be able to easily switch to a different approach in the future. As we got used to the traditional CSS approach, the learning curve is also steep.brandColor
, secondaryColor
and bodyBackgroundColor
for these sections.var()
.brandColorvariable
. The value for this variable will be set using javascript during run time.secondaryColor
variable is used for the apply coupon button.bodyBackgroundColor
is applied to the main container of the application.getMerchantConfigfunction
will return a promise which resolves the merchant configuration using the merchantId
argument.const root = document.querySelector(':root');
root.style.setProperty('--brandColor', merchant.brandColor);
root.style.setProperty('--secondaryColor', merchant.secondaryColor);
root.style.setProperty('--bodyBackgroundColor', merchant.bodyBackgroundColor);
getMerchantConfig
function by passing merchantId merchant1
.const setTheme = async () => {
const merchant = await getMerchantConfig('merchant1');
const root = document.querySelector(':root');
root.style.setProperty('--brandColor', merchant.brandColor);
root.style.setProperty('--secondaryColor', merchant.secondaryColor);
root.style.setProperty('--bodyBackgroundColor', merchant.bodyBackgroundColor);
};
setTheme();