Skip to content

Commit 9aead82

Browse files
committed
fix first access to dark calendar
1 parent cb16b67 commit 9aead82

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/components/Calendar/index.jsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
import { React, useEffect, useState } from "react";
2-
import { useColorMode } from '@docusaurus/theme-common';
2+
import { useColorMode } from "@docusaurus/theme-common";
33

44
export default function Calendar() {
55
const [firstDay, setFirstDay] = useState(1);
66
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) {
911
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
1012
setFirstDay((new Intl.Locale(locale)?.weekInfo?.firstDay ?? 0) + 1);
1113
setTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone);
12-
});
13-
}
14-
const { colorMode } = useColorMode();
14+
}
15+
setThemeMode(colorMode);
16+
});
1517
return (
1618
<iframe
1719
src={`https://calendar.google.com/calendar/embed?height=500&wkst=${firstDay}&ctz=${timezone}&showTitle=0&showTz=1&showPrint=0&src=ODgwNTU3MGE0ZTFjYTIzMTk4NDI5NzFkYjQzODBlZDUxOGM0OTA1NzdjMDY0NTRhZGYyMzAzNzM0NTA2ZjM5N0Bncm91cC5jYWxlbmRhci5nb29nbGUuY29t&color=%2333b679`}
1820
width="100%"
1921
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+
}
2127
></iframe>
2228
);
2329
}

0 commit comments

Comments
 (0)