File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
stories/components/theme-toggle Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -130,3 +130,21 @@ body {
130130 }
131131 </ script >
132132` ;
133+
134+ export const events = ( ) => html `
135+ < mgt-theme-toggle > </ mgt-theme-toggle >
136+ < style >
137+ body {
138+ background-color : var (--fill-color );
139+ }
140+ </ style >
141+ < script >
142+ const themeToggle = document . querySelector ( 'mgt-theme-toggle' ) ;
143+ themeToggle . addEventListener ( 'updated' , ( e ) => {
144+ console . log ( 'updated' , e ) ;
145+ } ) ;
146+ themeToggle . addEventListener ( 'darkmodechanged' , ( e ) => {
147+ console . log ( 'darkmodechanged' , e ) ;
148+ } ) ;
149+ </ script >
150+ ` ;
Original file line number Diff line number Diff line change @@ -51,3 +51,43 @@ export const SetMode = () => html`
5151 }
5252 </ style >
5353` ;
54+
55+ export const Events = ( ) => html `
56+ < mgt-theme-toggle > </ mgt-theme-toggle >
57+ < react >
58+ // Check the console tab for the event to fire
59+ import { useCallback } from 'react';
60+ import { ThemeToggle } from '@microsoft/mgt-react';
61+
62+ export default () => {
63+ const onUpdated = useCallback((e) => {
64+ console.log('updated', e);
65+ });
66+
67+ const onDarkModeChanged = useCallback((e: CustomEvent< boolean > ) => {
68+ console.log('darkModeChanged', e);
69+ }
70+
71+ return (
72+ < ThemeToggle
73+ updated ={onUpdated}
74+ darkmodechanged ={onDarkModeChanged} >
75+ </ ThemeToggle >
76+ );
77+ };
78+ </ react >
79+ < style >
80+ body {
81+ background-color : var (--fill-color );
82+ }
83+ </ style >
84+ < script >
85+ const themeToggle = document . querySelector ( 'mgt-theme-toggle' ) ;
86+ themeToggle . addEventListener ( 'updated' , ( e ) => {
87+ console . log ( 'updated' , e ) ;
88+ } ) ;
89+ themeToggle . addEventListener ( 'darkmodechanged' , ( e ) => {
90+ console . log ( 'darkModeChanged' , e ) ;
91+ } ) ;
92+ </ script >
93+ ` ;
You can’t perform that action at this time.
0 commit comments