File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 1
1
import { React , useEffect , useState } from "react" ;
2
- import { useColorMode } from ' @docusaurus/theme-common' ;
2
+ import { useColorMode } from " @docusaurus/theme-common" ;
3
3
4
4
export default function Calendar ( ) {
5
5
const [ firstDay , setFirstDay ] = useState ( 1 ) ;
6
6
const [ timezone , setTimezone ] = useState ( "UTC" ) ;
7
- if ( Intl ) {
8
- useEffect ( ( ) => {
7
+ const [ themeMode , setThemeMode ] = useState ( "light" ) ;
8
+ const { colorMode } = useColorMode ( ) ;
9
+ useEffect ( ( ) => {
10
+ if ( Intl ) {
9
11
const locale = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . locale ;
10
12
setFirstDay ( ( new Intl . Locale ( locale ) ?. weekInfo ?. firstDay ?? 0 ) + 1 ) ;
11
13
setTimezone ( Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ) ;
12
- } ) ;
13
- }
14
- const { colorMode } = useColorMode ( ) ;
14
+ }
15
+ setThemeMode ( colorMode ) ;
16
+ } ) ;
15
17
return (
16
18
< iframe
17
19
src = { `https://calendar.google.com/calendar/embed?height=500&wkst=${ firstDay } &ctz=${ timezone } &showTitle=0&showTz=1&showPrint=0&src=ODgwNTU3MGE0ZTFjYTIzMTk4NDI5NzFkYjQzODBlZDUxOGM0OTA1NzdjMDY0NTRhZGYyMzAzNzM0NTA2ZjM5N0Bncm91cC5jYWxlbmRhci5nb29nbGUuY29t&color=%2333b679` }
18
20
width = "100%"
19
21
height = "500"
20
- style = { colorMode === "dark" ? { filter : "invert(95%) brightness(95%) hue-rotate(180deg)" } : { } }
22
+ style = {
23
+ themeMode === "dark"
24
+ ? { filter : "invert(95%) brightness(95%) hue-rotate(180deg)" }
25
+ : { }
26
+ }
21
27
> </ iframe >
22
28
) ;
23
29
}
You can’t perform that action at this time.
0 commit comments