Skip to content

Commit

Permalink
fix(ThemeProvider): Only inject theme properties if they are not pres…
Browse files Browse the repository at this point in the history
…ent (#55)
  • Loading branch information
MarcusNotheis authored Jul 11, 2019
1 parent d51ee0e commit 3ec61d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/main/src/components/ThemeProvider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createGenerateClassName, sap_fiori_3 } from '@ui5/webcomponents-react-base';
import boot from '@ui5/webcomponents-base/src/boot';
import { getCompactSize, getTheme } from '@ui5/webcomponents-base/src/Configuration';
import { injectThemeProperties } from '@ui5/webcomponents-base/src/theming/StyleInjection';
import { createGenerateClassName, sap_fiori_3 } from '@ui5/webcomponents-react-base';
import fiori3ThemeProperties from '@ui5/webcomponents/dist/themes/sap_fiori_3/parameters-bundle.css.json';
import React, { Fragment, PureComponent, ReactNode } from 'react';
import { JssProvider, ThemeProvider as ReactJssThemeProvider } from 'react-jss';
Expand All @@ -23,9 +23,11 @@ export class ThemeProvider extends PureComponent<ThemeProviderProps> {

constructor(props) {
super(props);
// inject default CSS custom parameters in head
boot().then((_) => {
injectThemeProperties(fiori3ThemeProperties._);
let existingThemingProperties = document.querySelector('head style[data-ui5-webcomponents-theme-properties]');
if (!existingThemingProperties || !existingThemingProperties.innerHTML) {
injectThemeProperties(fiori3ThemeProperties._);
}
});
}

Expand Down

0 comments on commit 3ec61d5

Please sign in to comment.