Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/fluent-tester/src/theme/CustomThemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class TesterThemeReference extends ThemeReference {
constructor() {
super(
baseTheme,
(parent) => applyTheme(parent, this._themeName, this.options.appearance),
() => applyTheme(this._themeName, this.options.appearance),
(parent) => applyBrand(parent, this._brand),
);
this.baseTheme = baseTheme;
Expand Down
49 changes: 3 additions & 46 deletions apps/fluent-tester/src/theme/applyTheme.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,20 @@
import type { PartialTheme, Theme, ThemeOptions } from '@fluentui-react-native/framework';
import type { PartialTheme, ThemeOptions } from '@fluentui-react-native/framework';
import { createOfficeTheme, getThemingModule } from '@fluentui-react-native/win32-theme';

export type ThemeNames = 'Default' | 'Office' | 'Caterpillar' | 'Apple';
export type ThemeNames = 'Default' | 'Office' | '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 {
export function applyTheme(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 {};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "remove caterpillar theme",
"packageName": "@fluentui-react-native/tester",
"email": "gulnazsayed@microsoft.com",
"dependentChangeType": "patch"
}
2 changes: 0 additions & 2 deletions docs/pages/Theming/CustomTheme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const theme = new ThemeReference(createDefaultTheme(),
</ThemeProvider>
```

A good example of a custom theme from our repo is [the Caterpillar theme in the Tester App](../../../apps/fluent-tester/src/theme/applyTheme.ts).

### `ThemeReference` from scratch

You can create your own `ThemeReference` and pass it into the `ThemeProvider`. To create a `ThemeReference` you'll need to create a new instance of `ThemeReference`. You can find the type definition [here](../../../packages/framework/theme/src/themeReference.ts).
Expand Down