Skip to content

Commit 40b87f9

Browse files
authored
feat: allow programmatically theming a component without the theme-toggle component (#2199)
* Export all theme-manager utils for custom element theming * Add a story for theming without toggle
1 parent 5831ad1 commit 40b87f9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/mgt-components/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77

88
export * from './components/components';
99
export * from './graph/types';
10+
export * from './styles/theme-manager';

stories/components/theme-toggle/themeToggle.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ body {
5757
</style>
5858
`;
5959

60+
export const themingWithoutToggle = () => html`
61+
<mgt-login id="login-one"></mgt-login>
62+
<mgt-login id="login-two"></mgt-login>
63+
<mgt-login id="login-three"></mgt-login>
64+
65+
<!-- The login components are in the default light theme on a light
66+
background. We are setting the component with id "login-two" to the dark
67+
theme colors using JavaScript. -->
68+
69+
<script>
70+
import { applyTheme } from '@microsoft/mgt';
71+
const loginTwo = document.querySelector("#login-two");
72+
73+
if(loginTwo){
74+
// apply the dark theme on the second login component only.
75+
applyTheme('dark', loginTwo)
76+
}
77+
</script>
78+
`;
79+
6080
export const localization = () => html`
6181
<mgt-theme-toggle></mgt-theme-toggle>
6282
<style>

0 commit comments

Comments
 (0)