-
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.
feat(web-components): enabling setting theme on an individual element…
… and unsetting themes (#31973) Co-authored-by: Martin Hochel <[email protected]>
- Loading branch information
Showing
11 changed files
with
726 additions
and
97 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-web-components-d74234e0-b903-4c51-af61-599648aee92d.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": "feat: enabling setting theme on an individual element and unsetting themes", | ||
"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 was deleted.
Oops, something went wrong.
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
36 changes: 36 additions & 0 deletions
36
packages/web-components/src/theme/set-theme.local.bench.ts
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,36 @@ | ||
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(); | ||
|
||
const el = document.createElement('div'); | ||
document.body.append(el); | ||
|
||
startMeasure(); | ||
|
||
// Newly set themes | ||
setTheme(webLightTheme, el); | ||
setTheme(webDarkTheme, el); | ||
setTheme(teamsDarkTheme, el); | ||
setTheme(teamsLightTheme, el); | ||
|
||
// Cached themes | ||
setTheme(webLightTheme, el); | ||
setTheme(webDarkTheme, el); | ||
setTheme(teamsDarkTheme, el); | ||
setTheme(teamsLightTheme, el); | ||
|
||
// Unset themes | ||
setTheme(null, el); | ||
|
||
endMeasure(); | ||
|
||
onComplete(); | ||
}, | ||
}; | ||
|
||
export { tests }; |
38 changes: 38 additions & 0 deletions
38
packages/web-components/src/theme/set-theme.shadow.bench.ts
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,38 @@ | ||
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(); | ||
|
||
const el = document.createElement('div'); | ||
el.attachShadow({ mode: 'open' }); | ||
el.shadowRoot!.append(document.createElement('span')); | ||
document.body.append(el); | ||
|
||
startMeasure(); | ||
|
||
// Newly set themes | ||
setTheme(webLightTheme, el); | ||
setTheme(webDarkTheme, el); | ||
setTheme(teamsDarkTheme, el); | ||
setTheme(teamsLightTheme, el); | ||
|
||
// Cached themes | ||
setTheme(webLightTheme, el); | ||
setTheme(webDarkTheme, el); | ||
setTheme(teamsDarkTheme, el); | ||
setTheme(teamsLightTheme, el); | ||
|
||
// Unset themes | ||
setTheme(null, el); | ||
|
||
endMeasure(); | ||
|
||
onComplete(); | ||
}, | ||
}; | ||
|
||
export { tests }; |
Oops, something went wrong.