Skip to content

Commit e53f9a4

Browse files
committed
Theme Provider
1 parent ea4c4b1 commit e53f9a4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/controls/variantThemeProvider/VariantThemeProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { useCallback } from "react";
55
import { generateThemeFromColors, generateThemeVariant, getDefaultTheme } from "./VariantThemeProviderHelpers";
66
import { VariantThemeProviderProps, VariantType } from "./VariantThemeProviderProps";
77

8-
export const VariantThemeProvider = (props: VariantThemeProviderProps) => {
8+
export const VariantThemeProvider = (props: VariantThemeProviderProps): JSX.Element => {
99
const themeToApply = useCallback(
1010
() => {
11-
let workingVariantType = (props.variantType) ? props.variantType : VariantType.None;
11+
const workingVariantType = (props.variantType) ? props.variantType : VariantType.None;
1212
let workingTheme: IPartialTheme | ITheme;
1313

1414
if (props.themeColors) {
@@ -21,7 +21,7 @@ export const VariantThemeProvider = (props: VariantThemeProviderProps) => {
2121
}
2222
}
2323

24-
let themeVariantToApply = (props.variantType === VariantType.None)
24+
const themeVariantToApply = (props.variantType === VariantType.None)
2525
? workingTheme
2626
: generateThemeVariant(workingTheme, workingVariantType);
2727

src/controls/variantThemeProvider/VariantThemeProviderHelpers.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const generateThemeVariant = (theme: IPartialTheme | ITheme, themeType: V
2525

2626
export const getDefaultTheme = (): ITheme => {
2727
let currentTheme;
28-
const themeColorsFromWindow: any = (window as any)?.__themeState__?.theme;
28+
const themeColorsFromWindow: any = (window as any)?.__themeState__?.theme; // eslint-disable-line @typescript-eslint/no-explicit-any
2929
if (themeColorsFromWindow) {
3030
currentTheme = createTheme({
3131
palette: themeColorsFromWindow
@@ -40,11 +40,11 @@ export const getDefaultTheme = (): ITheme => {
4040
export const generateThemeFromColors = (primaryColor: string, textColor: string, backgroundColor: string): ITheme => {
4141
const themeRules = themeRulesStandardCreator();
4242
const colors = {
43-
primaryColor: getColorFromString(primaryColor)!,
44-
textColor: getColorFromString(textColor)!,
45-
backgroundColor: getColorFromString(backgroundColor)!,
43+
primaryColor: getColorFromString(primaryColor),
44+
textColor: getColorFromString(textColor),
45+
backgroundColor: getColorFromString(backgroundColor),
4646
};
47-
const currentIsDark = isDark(themeRules[BaseSlots[BaseSlots.backgroundColor]].color!);
47+
const currentIsDark = isDark(themeRules[BaseSlots[BaseSlots.backgroundColor]].color);
4848

4949
ThemeGenerator.insureSlots(themeRules, currentIsDark);
5050
ThemeGenerator.setSlot(
@@ -76,4 +76,4 @@ export const generateThemeFromColors = (primaryColor: string, textColor: string,
7676
});
7777

7878
return generatedTheme;
79-
};
79+
};

0 commit comments

Comments
 (0)