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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
import React from "react";
import ColorScheme from "../../shared/ColorScheme";
import { ThemeProvider } from "styled-components";
import baseStyled, { ThemedStyledInterface } from "styled-components";
type ThemeProperties = {
completionTitleBackground: string;
completionTitleForeground: string;
completionItemBackground: string;
completionItemForeground: string;
completionItemDescriptionForeground: string;
completionSelectedBackground: string;
completionSelectedForeground: string;
commandBackground: string;
commandForeground: string;
consoleErrorBackground: string;
consoleErrorForeground: string;
consoleInfoBackground: string;
consoleInfoForeground: string;
};
export const LightTheme: ThemeProperties = {
completionTitleBackground: "lightgray",
completionTitleForeground: "#000000",
completionItemBackground: "#ffffff",
completionItemForeground: "#000000",
completionItemDescriptionForeground: "#008000",
completionSelectedBackground: "#ffff00",
completionSelectedForeground: "#000000",
commandBackground: "#ffffff",
commandForeground: "#000000",
consoleErrorBackground: "#ff0000",
consoleErrorForeground: "#ffffff",
consoleInfoBackground: "#ffffff",
consoleInfoForeground: "#018786",
};
export const DarkTheme: ThemeProperties = {
completionTitleBackground: "#052027",
completionTitleForeground: "white",
completionItemBackground: "#2f474f",
completionItemForeground: "white",
completionItemDescriptionForeground: "#86fab0",
completionSelectedBackground: "#eeff41",
completionSelectedForeground: "#000000",
commandBackground: "#052027",
commandForeground: "white",
consoleErrorBackground: "red",
consoleErrorForeground: "white",
consoleInfoBackground: "#052027",
consoleInfoForeground: "#ffffff",
};
interface Props extends React.HTMLAttributes<HTMLElement> {
colorscheme: ColorScheme;
}
const ColorSchemeProvider: React.FC<Props> = ({ colorscheme, children }) => {
let theme = LightTheme;
if (colorscheme === ColorScheme.System) {
if (
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
) {
theme = DarkTheme;
}
} else if (colorscheme === ColorScheme.Dark) {
theme = DarkTheme;
}
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
};
export const styled = baseStyled as ThemedStyledInterface<ThemeProperties>;
export default ColorSchemeProvider;
|