-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathAppProvider.tsx
More file actions
30 lines (27 loc) · 920 Bytes
/
AppProvider.tsx
File metadata and controls
30 lines (27 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { ThemeProvider, BaseStyles, Box } from "@primer/react";
import type { ReactNode } from "react";
import { useEffect } from "react";
import { FeedbackFooter } from "./FeedbackFooter";
interface AppProviderProps {
children: ReactNode;
}
export function AppProvider({ children }: AppProviderProps) {
useEffect(() => {
// Set up theme data attributes for proper Primer theming
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
const colorMode = prefersDark ? "dark" : "light";
document.body.setAttribute("data-color-mode", colorMode);
document.body.setAttribute("data-light-theme", "light");
document.body.setAttribute("data-dark-theme", "dark");
}, []);
return (
<ThemeProvider colorMode="auto">
<BaseStyles>
<Box p={3}>
{children}
<FeedbackFooter />
</Box>
</BaseStyles>
</ThemeProvider>
);
}