feat: adjust theme
This commit is contained in:
parent
798999d490
commit
5e2271b237
@ -11,6 +11,7 @@ body {
|
|||||||
--primary-main: #5b5c9d;
|
--primary-main: #5b5c9d;
|
||||||
--text-primary: #637381;
|
--text-primary: #637381;
|
||||||
--selection-color: #f5f5f5;
|
--selection-color: #f5f5f5;
|
||||||
|
--scroller-color: #90939980;
|
||||||
}
|
}
|
||||||
|
|
||||||
::selection {
|
::selection {
|
||||||
@ -25,7 +26,7 @@ body {
|
|||||||
}
|
}
|
||||||
*::-webkit-scrollbar-thumb {
|
*::-webkit-scrollbar-thumb {
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background-color: rgba(#909399, 0.5);
|
background-color: var(--scroller-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@import "./layout.scss";
|
@import "./layout.scss";
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
max-width: 225px;
|
max-width: 225px;
|
||||||
min-width: 125px;
|
min-width: 125px;
|
||||||
padding: 8px 0;
|
padding: 16px 0 8px;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
@ -23,14 +23,14 @@
|
|||||||
max-width: 168px;
|
max-width: 168px;
|
||||||
max-height: 168px;
|
max-height: 168px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0 8px;
|
padding: 0 16px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
img,
|
img,
|
||||||
svg {
|
svg {
|
||||||
width: 100%;
|
width: 96%;
|
||||||
height: 100%;
|
height: 96%;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.the-menu {
|
.the-menu {
|
||||||
flex: 1 1 75%;
|
flex: 1 1 80%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import useSWR from "swr";
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { createTheme } from "@mui/material";
|
import { createTheme } from "@mui/material";
|
||||||
import { getVergeConfig } from "../../services/cmds";
|
import { getVergeConfig } from "../../services/cmds";
|
||||||
import { defaultTheme as dt } from "../../pages/_theme";
|
import { defaultTheme, defaultDarkTheme } from "../../pages/_theme";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* custome theme
|
* custome theme
|
||||||
@ -13,14 +13,9 @@ export default function useCustomTheme() {
|
|||||||
|
|
||||||
const theme = useMemo(() => {
|
const theme = useMemo(() => {
|
||||||
const mode = theme_mode ?? "light";
|
const mode = theme_mode ?? "light";
|
||||||
// const background = mode === "light" ? "#f5f5f5" : "#000";
|
|
||||||
const selectColor = mode === "light" ? "#f5f5f5" : "#d5d5d5";
|
|
||||||
|
|
||||||
const rootEle = document.documentElement;
|
|
||||||
rootEle.style.background = "transparent";
|
|
||||||
rootEle.style.setProperty("--selection-color", selectColor);
|
|
||||||
|
|
||||||
const setting = theme_setting || {};
|
const setting = theme_setting || {};
|
||||||
|
const dt = mode === "light" ? defaultTheme : defaultDarkTheme;
|
||||||
|
|
||||||
const theme = createTheme({
|
const theme = createTheme({
|
||||||
breakpoints: {
|
breakpoints: {
|
||||||
@ -47,6 +42,16 @@ export default function useCustomTheme() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// css
|
||||||
|
const selectColor = mode === "light" ? "#f5f5f5" : "#d5d5d5";
|
||||||
|
const scrollColor = mode === "light" ? "#90939980" : "#54545480";
|
||||||
|
|
||||||
|
const rootEle = document.documentElement;
|
||||||
|
rootEle.style.background = "transparent";
|
||||||
|
rootEle.style.setProperty("--selection-color", selectColor);
|
||||||
|
rootEle.style.setProperty("--scroller-color", scrollColor);
|
||||||
|
rootEle.style.setProperty("--primary-main", theme.palette.primary.main);
|
||||||
|
|
||||||
// inject css
|
// inject css
|
||||||
let style = document.querySelector("style#verge-theme");
|
let style = document.querySelector("style#verge-theme");
|
||||||
if (!style) {
|
if (!style) {
|
||||||
|
@ -165,8 +165,8 @@ const ProfileItem = (props: Props) => {
|
|||||||
const color = {
|
const color = {
|
||||||
"light-true": text.secondary,
|
"light-true": text.secondary,
|
||||||
"light-false": text.secondary,
|
"light-false": text.secondary,
|
||||||
"dark-true": alpha(text.secondary, 0.6),
|
"dark-true": alpha(text.secondary, 0.75),
|
||||||
"dark-false": alpha(text.secondary, 0.6),
|
"dark-false": alpha(text.secondary, 0.75),
|
||||||
}[key]!;
|
}[key]!;
|
||||||
|
|
||||||
const h2color = {
|
const h2color = {
|
||||||
|
@ -13,9 +13,10 @@ import {
|
|||||||
ListItemText,
|
ListItemText,
|
||||||
styled,
|
styled,
|
||||||
TextField,
|
TextField,
|
||||||
|
useTheme,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
|
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
|
||||||
import { defaultTheme } from "../../pages/_theme";
|
import { defaultTheme, defaultDarkTheme } from "../../pages/_theme";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -71,15 +72,22 @@ const SettingTheme = (props: Props) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const renderItem = (label: string, key: keyof typeof defaultTheme) => {
|
// default theme
|
||||||
|
const { palette } = useTheme();
|
||||||
|
|
||||||
|
const dt = palette.mode === "light" ? defaultTheme : defaultDarkTheme;
|
||||||
|
|
||||||
|
type ThemeKey = keyof typeof theme & keyof typeof defaultTheme;
|
||||||
|
|
||||||
|
const renderItem = (label: string, key: ThemeKey) => {
|
||||||
return (
|
return (
|
||||||
<Item>
|
<Item>
|
||||||
<ListItemText primary={label} />
|
<ListItemText primary={label} />
|
||||||
<Round sx={{ background: theme[key] || defaultTheme[key] }} />
|
<Round sx={{ background: theme[key] || dt[key] }} />
|
||||||
<TextField
|
<TextField
|
||||||
{...textProps}
|
{...textProps}
|
||||||
value={theme[key] ?? ""}
|
value={theme[key] ?? ""}
|
||||||
placeholder={defaultTheme[key]}
|
placeholder={dt[key]}
|
||||||
onChange={handleChange(key)}
|
onChange={handleChange(key)}
|
||||||
onKeyDown={(e) => e.key === "Enter" && onSave()}
|
onKeyDown={(e) => e.key === "Enter" && onSave()}
|
||||||
/>
|
/>
|
||||||
|
@ -72,7 +72,7 @@ const Layout = () => {
|
|||||||
}}
|
}}
|
||||||
sx={[
|
sx={[
|
||||||
({ palette }) => ({
|
({ palette }) => ({
|
||||||
bgcolor: alpha(palette.background.paper, theme_blur ? 0.85 : 1),
|
bgcolor: alpha(palette.background.paper, theme_blur ? 0.8 : 1),
|
||||||
}),
|
}),
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
@ -83,7 +83,7 @@ const Layout = () => {
|
|||||||
<UpdateButton className="the-newbtn" />
|
<UpdateButton className="the-newbtn" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<List className="the-menu" data-windrag>
|
<List className="the-menu">
|
||||||
{routers.map((router) => (
|
{routers.map((router) => (
|
||||||
<LayoutItem key={router.label} to={router.link}>
|
<LayoutItem key={router.label} to={router.link}>
|
||||||
{t(router.label)}
|
{t(router.label)}
|
||||||
|
@ -10,3 +10,10 @@ export const defaultTheme = {
|
|||||||
success_color: "#2e7d32",
|
success_color: "#2e7d32",
|
||||||
font_family: `"Roboto", "Helvetica", "Arial", sans-serif`,
|
font_family: `"Roboto", "Helvetica", "Arial", sans-serif`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// dark mode
|
||||||
|
export const defaultDarkTheme = {
|
||||||
|
...defaultTheme,
|
||||||
|
primary_text: "#757575",
|
||||||
|
secondary_text: "#637381",
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user