-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(web-components): use adopted style sheets to set theme tokens (
#31713) Co-authored-by: Chris Holt <[email protected]>
- Loading branch information
1 parent
272dafa
commit 896c9d3
Showing
8 changed files
with
105 additions
and
24 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-web-components-22e3e36e-c30c-4866-85ad-9e28421977d6.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "refactor setTheme() to use adoptedStyleSheets", | ||
"packageName": "@fluentui/web-components", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { measurePerformance, type TestRenderFunction } from '@tensile-perf/web-components'; | ||
import { teamsDarkTheme, teamsLightTheme, webDarkTheme, webLightTheme } from '@fluentui/tokens'; | ||
|
||
import { setTheme } from './set-theme.js'; | ||
|
||
const tests: Record<string, TestRenderFunction> = { | ||
mount: ({ onComplete }) => { | ||
const { startMeasure, endMeasure } = measurePerformance(); | ||
|
||
startMeasure(); | ||
|
||
// Newly set themes | ||
setTheme(webLightTheme); | ||
setTheme(webDarkTheme); | ||
setTheme(teamsDarkTheme); | ||
setTheme(teamsLightTheme); | ||
|
||
// Cached themes | ||
setTheme(webLightTheme); | ||
setTheme(webDarkTheme); | ||
setTheme(teamsDarkTheme); | ||
setTheme(teamsLightTheme); | ||
|
||
endMeasure(); | ||
|
||
onComplete(); | ||
}, | ||
}; | ||
|
||
export { tests }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { html } from '@microsoft/fast-element'; | ||
import { teamsDarkTheme, teamsLightTheme, webDarkTheme, webLightTheme } from '@fluentui/tokens'; | ||
|
||
import { renderComponent } from '../helpers.stories.js'; | ||
import { setTheme } from './set-theme.js'; | ||
|
||
export default { | ||
title: 'Theme/SetTheme', | ||
}; | ||
|
||
export const SetTheme = renderComponent(html` | ||
<fluent-button @click="${() => setTheme(webLightTheme)}">webLightTheme</fluent-button> | ||
<fluent-button @click="${() => setTheme(webDarkTheme)}">webDarkTheme</fluent-button> | ||
<fluent-button @click="${() => setTheme(teamsLightTheme)}">teamsLightTheme</fluent-button> | ||
<fluent-button @click="${() => setTheme(teamsDarkTheme)}">teamsDarkTheme</fluent-button> | ||
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters