-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathapplyTheme.ts
64 lines (59 loc) · 1.85 KB
/
applyTheme.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import type { PartialTheme, Theme, ThemeOptions } from '@fluentui-react-native/framework';
import { createOfficeTheme, getThemingModule } from '@fluentui-react-native/win32-theme';
export type ThemeNames = 'Default' | 'Office' | 'Caterpillar' | 'Apple';
export const themeChoices = [
{ label: 'Default', value: 'Default' },
{ label: 'Office', value: 'Office' },
{ label: 'Caterpillar', value: 'Caterpillar' },
];
function applyCaterpillarTheme(parent: Theme): PartialTheme {
return parent.host?.appearance === 'dark'
? {
colors: {
buttonBackground: '#111111',
buttonBackgroundHovered: '#ffcd11',
buttonBackgroundPressed: '#eeeeee',
buttonText: '#ffffff',
buttonTextPressed: '#111111',
buttonTextHovered: '#000000',
},
components: {
Button: {
borderWidth: 0,
tokens: {
borderWidth: 0,
},
},
},
}
: {
colors: {
buttonBackground: '#ffcd11',
buttonBackgroundHovered: '#111111',
buttonBackgroundPressed: '#eeeeee',
buttonText: '#000000',
buttonTextPressed: '#111111',
buttonTextHovered: '#ffffff',
},
components: {
Button: {
borderWidth: 0,
tokens: {
borderWidth: 0,
},
},
},
};
}
const themingModule = getThemingModule()[0];
/** apply the currently active theme layering */
export function applyTheme(parent: Theme, name: ThemeNames, appearance: ThemeOptions['appearance']): PartialTheme {
switch (name) {
case 'Office':
return themingModule ? createOfficeTheme({ appearance, paletteName: 'Dialogs_FluentSV' }).theme : {};
case 'Caterpillar':
return applyCaterpillarTheme(parent);
default:
return {};
}
}