Adjust styles

This commit is contained in:
MystiPanda 2024-03-10 11:12:54 +08:00
parent ed6e966b2f
commit b3e5288bde
11 changed files with 73 additions and 36 deletions

View File

@ -21,23 +21,23 @@
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
overflow: hidden; overflow: hidden;
// border-right: 1px solid var(--divider-color); border-right: 1px solid var(--divider-color);
// background-color: var(--background-color-alpha); // background-color: var(--background-color-alpha);
// $maxLogo: 100px; // $maxLogo: 100px;
.the-logo { .the-logo {
position: relative; position: relative;
flex: 1 0 47px; flex: 1 0 58px;
// width: 100%; // width: 100%;
display: flex; display: flex;
height: 100%; height: 100%;
padding: 0px 15px; padding: 0px 20px;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: flex-start; align-items: flex-start;
align-self: stretch; align-self: stretch;
// border-bottom: 1px solid var(--divider-color); border-bottom: 1px solid var(--divider-color);
// max-width: $maxLogo + 32px; // max-width: $maxLogo + 32px;
// max-height: $maxLogo; // max-height: $maxLogo;
// margin: 0 auto; // margin: 0 auto;
@ -71,6 +71,7 @@
flex: 1 1 80%; flex: 1 1 80%;
overflow-y: auto; overflow-y: auto;
margin-bottom: 0px; margin-bottom: 0px;
padding-top: 4px;
} }
.the-traffic { .the-traffic {
@ -78,7 +79,7 @@
> div { > div {
margin: 0 auto; margin: 0 auto;
// padding: 0 20px; padding: 0px 10px;
} }
} }
} }
@ -119,7 +120,7 @@
} }
.layout__left .the-logo { .layout__left .the-logo {
flex: 1 0 47px; flex: 1 0 58px;
} }
.layout__right .the-content { .layout__right .the-content {

View File

@ -13,13 +13,13 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
// border-bottom: 1px solid var(--divider-color); border-bottom: 1px solid var(--divider-color);
} }
.base-container { .base-container {
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
border-radius: 10px; // border-radius: 10px;
// border-top-left-radius: var(--border-radius); // border-top-left-radius: var(--border-radius);
> section { > section {

View File

@ -1,19 +1,23 @@
import { createRoot } from "react-dom/client"; import { createRoot } from "react-dom/client";
import { ReactNode, useState } from "react"; import { ReactNode, useState, useEffect } from "react";
import { Box, IconButton, Slide, Snackbar, Typography } from "@mui/material"; import { Box, IconButton, Slide, Snackbar, Typography } from "@mui/material";
import { Close, CheckCircleRounded, ErrorRounded } from "@mui/icons-material"; import { Close, CheckCircleRounded, ErrorRounded } from "@mui/icons-material";
import { useVerge } from "@/hooks/use-verge";
import { appWindow } from "@tauri-apps/api/window";
interface InnerProps { interface InnerProps {
type: string; type: string;
duration?: number; duration?: number;
message: ReactNode; message: ReactNode;
isDark?: boolean;
onClose: () => void; onClose: () => void;
} }
const NoticeInner = (props: InnerProps) => { const NoticeInner = (props: InnerProps) => {
const { type, message, duration = 1500, onClose } = props; const { type, message, duration = 1500, onClose } = props;
const [visible, setVisible] = useState(true); const [visible, setVisible] = useState(true);
const [isDark, setIsDark] = useState(false);
const { verge } = useVerge();
const { theme_mode } = verge ?? {};
const onBtnClose = () => { const onBtnClose = () => {
setVisible(false); setVisible(false);
onClose(); onClose();
@ -22,6 +26,26 @@ const NoticeInner = (props: InnerProps) => {
if (reason !== "clickaway") onBtnClose(); if (reason !== "clickaway") onBtnClose();
}; };
useEffect(() => {
const themeMode = ["light", "dark", "system"].includes(theme_mode!)
? theme_mode!
: "light";
if (themeMode !== "system") {
setIsDark(themeMode === "dark");
return;
}
appWindow.theme().then((m) => m && setIsDark(m === "dark"));
const unlisten = appWindow.onThemeChanged((e) =>
setIsDark(e.payload === "dark")
);
return () => {
unlisten.then((fn) => fn());
};
}, [theme_mode]);
const msgElement = const msgElement =
type === "info" ? ( type === "info" ? (
message message
@ -46,7 +70,13 @@ const NoticeInner = (props: InnerProps) => {
autoHideDuration={duration} autoHideDuration={duration}
onClose={onAutoClose} onClose={onAutoClose}
message={msgElement} message={msgElement}
sx={{ maxWidth: 360 }} sx={{
maxWidth: 360,
".MuiSnackbarContent-root": {
bgcolor: isDark ? "#50515C" : "#ffffff",
color: isDark ? "#ffffff" : "#000000",
},
}}
TransitionComponent={(p) => <Slide {...p} direction="left" />} TransitionComponent={(p) => <Slide {...p} direction="left" />}
transitionDuration={200} transitionDuration={200}
action={ action={
@ -61,9 +91,9 @@ const NoticeInner = (props: InnerProps) => {
interface NoticeInstance { interface NoticeInstance {
(props: Omit<InnerProps, "onClose">): void; (props: Omit<InnerProps, "onClose">): void;
info(message: ReactNode, duration?: number): void; info(message: ReactNode, duration?: number, isDark?: boolean): void;
error(message: ReactNode, duration?: number): void; error(message: ReactNode, duration?: number, isDark?: boolean): void;
success(message: ReactNode, duration?: number): void; success(message: ReactNode, duration?: number, isDark?: boolean): void;
} }
let parent: HTMLDivElement = null!; let parent: HTMLDivElement = null!;

View File

@ -30,7 +30,6 @@ export const LayoutItem = (props: Props) => {
paddingLeft: 1.5, paddingLeft: 1.5,
paddingRight: 1, paddingRight: 1,
marginRight: 1.25, marginRight: 1.25,
textAlign: "left",
"& .MuiListItemText-primary": { "& .MuiListItemText-primary": {
color: "text.primary", color: "text.primary",
fontWeight: "700", fontWeight: "700",

View File

@ -88,11 +88,7 @@ export const LayoutTraffic = () => {
}; };
return ( return (
<Box <Box position="relative" onClick={trafficRef.current?.toggleStyle}>
width="150px"
position="relative"
onClick={trafficRef.current?.toggleStyle}
>
{trafficGraph && pageVisible && ( {trafficGraph && pageVisible && (
<div style={{ width: "100%", height: 60, marginBottom: 6 }}> <div style={{ width: "100%", height: 60, marginBottom: 6 }}>
<TrafficGraph ref={trafficRef} /> <TrafficGraph ref={trafficRef} />

View File

@ -21,23 +21,34 @@ export const ProfileBox = styled(Box)(
"dark-false": text.primary, "dark-false": text.primary,
}[key]!; }[key]!;
const borderLeft = { const borderSelect = {
"light-true": `3px solid ${primary.main}`, "light-true": {
"light-false": "none", borderLeft: `3px solid ${primary.main}`,
"dark-true": `3px solid ${primary.main}`, width: `calc(100% + 3px)`,
"dark-false": "none", marginLeft: `-3px`,
},
"light-false": {
width: "100%",
},
"dark-true": {
borderLeft: `3px solid ${primary.main}`,
width: `calc(100% + 3px)`,
marginLeft: `-3px`,
},
"dark-false": {
width: "100%",
},
}[key]; }[key];
return { return {
position: "relative", position: "relative",
width: "100%",
display: "block", display: "block",
cursor: "pointer", cursor: "pointer",
textAlign: "left", textAlign: "left",
padding: "8px 16px", padding: "8px 16px",
boxSizing: "border-box", boxSizing: "border-box",
backgroundColor, backgroundColor,
borderLeft, ...borderSelect,
borderRadius: "8px", borderRadius: "8px",
color, color,
"& h2": { color: h2color }, "& h2": { color: h2color },

View File

@ -113,7 +113,7 @@ export const ProxyRender = (props: RenderProps) => {
if (type === 1 && !group.hidden) { if (type === 1 && !group.hidden) {
return ( return (
<ProxyHead <ProxyHead
sx={{ pl: indent ? 4.5 : 2.5, pr: 3, mt: indent ? 1 : 0.5, mb: 1 }} sx={{ pl: 2, pr: 3, mt: indent ? 1 : 0.5, mb: 1 }}
groupName={group.name} groupName={group.name}
headState={headState!} headState={headState!}
onLocation={() => onLocation(group)} onLocation={() => onLocation(group)}
@ -130,7 +130,7 @@ export const ProxyRender = (props: RenderProps) => {
proxy={proxy!} proxy={proxy!}
selected={group.now === proxy?.name} selected={group.now === proxy?.name}
showType={headState?.showType} showType={headState?.showType}
sx={{ py: 0, pl: indent ? 4 : 2 }} sx={{ py: 0, pl: 1 }}
onClick={() => onChangeProxy(group, proxy!)} onClick={() => onChangeProxy(group, proxy!)}
/> />
); );
@ -141,7 +141,7 @@ export const ProxyRender = (props: RenderProps) => {
<Box <Box
sx={{ sx={{
py: 2, py: 2,
pl: indent ? 4.5 : 0, pl: 0,
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
alignItems: "center", alignItems: "center",
@ -161,7 +161,7 @@ export const ProxyRender = (props: RenderProps) => {
height: 56, height: 56,
display: "grid", display: "grid",
gap: 1, gap: 1,
pl: indent ? 4 : 2, pl: 2,
pr: 2, pr: 2,
pb: 1, pb: 1,
gridTemplateColumns: `repeat(${item.col! || 2}, 1fr)`, gridTemplateColumns: `repeat(${item.col! || 2}, 1fr)`,

View File

@ -125,7 +125,7 @@ const ConnectionsPage = () => {
title={t("Connections")} title={t("Connections")}
contentStyle={{ height: "100%" }} contentStyle={{ height: "100%" }}
header={ header={
<Box sx={{ mt: 1, display: "flex", alignItems: "center", gap: 2 }}> <Box sx={{ display: "flex", alignItems: "center", gap: 2 }}>
<Box sx={{ mx: 1 }}>Download: {parseTraffic(download)}</Box> <Box sx={{ mx: 1 }}>Download: {parseTraffic(download)}</Box>
<Box sx={{ mx: 1 }}>Upload: {parseTraffic(upload)}</Box> <Box sx={{ mx: 1 }}>Upload: {parseTraffic(upload)}</Box>
<IconButton <IconButton

View File

@ -42,7 +42,7 @@ const LogPage = () => {
title={t("Logs")} title={t("Logs")}
contentStyle={{ height: "100%" }} contentStyle={{ height: "100%" }}
header={ header={
<Box sx={{ mt: 1, display: "flex", alignItems: "center", gap: 2 }}> <Box sx={{ display: "flex", alignItems: "center", gap: 2 }}>
<IconButton <IconButton
size="small" size="small"
color="inherit" color="inherit"

View File

@ -240,7 +240,7 @@ const ProfilePage = () => {
<BasePage <BasePage
title={t("Profiles")} title={t("Profiles")}
header={ header={
<Box sx={{ mt: 1, display: "flex", alignItems: "center", gap: 1 }}> <Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
<IconButton <IconButton
size="small" size="small"
color="inherit" color="inherit"

View File

@ -113,7 +113,7 @@ const TestPage = () => {
<BasePage <BasePage
title={t("Test")} title={t("Test")}
header={ header={
<Box sx={{ mt: 1, display: "flex", alignItems: "center", gap: 1 }}> <Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
<Button <Button
variant="contained" variant="contained"
size="small" size="small"