refactor: Upgrade to the new UI (#521)

Co-authored-by: MystiPanda <mystipanda@proton.me>
This commit is contained in:
Amnesiash
2024-03-09 21:37:21 +08:00
committed by GitHub
parent f335941b62
commit 0cda07106b
39 changed files with 533 additions and 182 deletions

View File

@@ -113,12 +113,12 @@ export const ProviderButton = () => {
return (
<>
<ListItem
sx={(theme) => ({
sx={{
p: 0,
borderRadius: "10px",
boxShadow: theme.shadows[2],
border: "solid 2px var(--divider-color)",
mb: 1,
})}
}}
key={key}
>
<ListItemText
@@ -161,7 +161,6 @@ export const ProviderButton = () => {
<LinearProgress
variant="determinate"
value={progress}
color="inherit"
/>
</>
)}

View File

@@ -50,30 +50,36 @@ export const ProxyItemMini = (props: Props) => {
sx={[
{
height: 56,
borderRadius: 1,
borderRadius: 1.5,
pl: 1.5,
pr: 1,
justifyContent: "space-between",
alignItems: "center",
},
({ palette: { mode, primary } }) => {
const bgcolor =
mode === "light"
? alpha(primary.main, 0.15)
: alpha(primary.main, 0.35);
const bgcolor = mode === "light" ? "#ffffff" : "#24252f";
const color = mode === "light" ? primary.main : primary.light;
const showDelay = delay > 0;
const shadowColor =
mode === "light" ? "rgba(0,0,0,0.04)" : "rgba(255,255,255,0.08)";
const selectColor = mode === "light" ? primary.main : primary.light;
return {
"&:hover .the-check": { display: !showDelay ? "block" : "none" },
"&:hover .the-delay": { display: showDelay ? "block" : "none" },
"&:hover .the-icon": { display: "none" },
"&.Mui-selected": { bgcolor, boxShadow: `0 0 0 1px ${bgcolor}` },
"&.Mui-selected .MuiListItemText-secondary": { color },
boxShadow: `0 0 0 1px ${shadowColor}`,
"&:hover ": {
bgcolor:
mode === "light"
? alpha(primary.main, 0.15)
: alpha(primary.main, 0.35),
},
"&.Mui-selected": {
width: `calc(100% + 3px)`,
marginLeft: `-3px`,
borderLeft: `3px solid ${selectColor}`,
bgcolor,
},
// "&.Mui-selected .MuiListItemText-secondary": { color },
backgroundColor: bgcolor,
};
},
]}
@@ -82,13 +88,15 @@ export const ProxyItemMini = (props: Props) => {
<Typography
variant="body2"
component="div"
color="text.secondary"
color="text.primary"
sx={{
display: "block",
textOverflow: "ellipsis",
wordBreak: "break-all",
overflow: "hidden",
whiteSpace: "nowrap",
fontSize: "13px",
fontWeight: "700",
}}
>
{proxy.name}
@@ -114,7 +122,8 @@ export const ProxyItemMini = (props: Props) => {
wordBreak: "break-all",
overflow: "hidden",
whiteSpace: "nowrap",
fontSize: "0.75rem",
fontSize: "11px",
fontWeight: "700",
marginRight: "8px",
}}
>
@@ -191,8 +200,8 @@ export const ProxyItemMini = (props: Props) => {
};
const Widget = styled(Box)(({ theme: { typography } }) => ({
padding: "3px 6px",
fontSize: 14,
padding: "2px 4px",
fontSize: 12,
fontFamily: typography.fontFamily,
borderRadius: "4px",
}));
@@ -200,15 +209,15 @@ const Widget = styled(Box)(({ theme: { typography } }) => ({
const TypeBox = styled(Box)(({ theme: { palette, typography } }) => ({
display: "inline-block",
border: "1px solid #ccc",
borderColor: alpha(palette.text.secondary, 0.36),
color: alpha(palette.text.secondary, 0.42),
borderColor: palette.mode === "light" ? "#d9d9d9" : "#424242",
color: palette.mode === "light" ? "#8c8c8c" : "#ffffff",
borderRadius: 4,
fontSize: 10,
fontFamily: typography.fontFamily,
marginRight: "4px",
marginTop: "auto",
padding: "0 2px",
lineHeight: 1.25,
padding: "0 4px",
lineHeight: 1.5,
}));
const TypeTypo = styled(Box)(({ theme: { palette, typography } }) => ({

View File

@@ -11,6 +11,7 @@ import {
styled,
SxProps,
Theme,
Typography,
} from "@mui/material";
import { BaseLoading } from "@/components/base";
import delayManager from "@/services/delay";
@@ -78,19 +79,28 @@ export const ProxyItem = (props: Props) => {
sx={[
{ borderRadius: 1 },
({ palette: { mode, primary } }) => {
const bgcolor =
mode === "light"
? alpha(primary.main, 0.15)
: alpha(primary.main, 0.35);
const color = mode === "light" ? primary.main : primary.light;
const bgcolor = mode === "light" ? "#ffffff" : "#24252f";
const selectColor = mode === "light" ? primary.main : primary.light;
const showDelay = delay > 0;
return {
"&:hover .the-check": { display: !showDelay ? "block" : "none" },
"&:hover .the-delay": { display: showDelay ? "block" : "none" },
"&:hover .the-icon": { display: "none" },
"&.Mui-selected": { bgcolor },
"&.Mui-selected .MuiListItemText-secondary": { color },
"&:hover ": {
bgcolor:
mode === "light"
? alpha(primary.main, 0.15)
: alpha(primary.main, 0.35),
},
"&.Mui-selected": {
borderLeft: `3px solid ${selectColor}`,
bgcolor,
},
// "&.Mui-selected .MuiListItemText-secondary": { bgcolor },
backgroundColor: bgcolor,
marginBottom: "8px",
height: "40px",
};
},
]}
@@ -99,7 +109,14 @@ export const ProxyItem = (props: Props) => {
title={proxy.name}
secondary={
<>
<span style={{ marginRight: 4 }}>
<span
style={{
marginRight: "8px",
fontSize: "13px",
color: "text.primary",
fontWeight: "700",
}}
>
{proxy.name}
{showType && proxy.now && ` - ${proxy.now}`}
</span>

View File

@@ -17,6 +17,8 @@ import { ProxyItem } from "./proxy-item";
import { ProxyItemMini } from "./proxy-item-mini";
import type { IRenderItem } from "./use-render-list";
import { useVerge } from "@/hooks/use-verge";
import { useRecoilState } from "recoil";
import { atomThemeMode } from "@/services/states";
interface RenderProps {
item: IRenderItem;
@@ -33,11 +35,21 @@ export const ProxyRender = (props: RenderProps) => {
const { type, group, headState, proxy, proxyCol } = item;
const { verge } = useVerge();
const enable_group_icon = verge?.enable_group_icon ?? true;
const [mode] = useRecoilState(atomThemeMode);
console.log(mode);
const isDark = mode === "light" ? false : true;
const itembackgroundcolor = isDark ? "#282A36" : "#ffffff";
if (type === 0 && !group.hidden) {
return (
<ListItemButton
dense
style={{
background: itembackgroundcolor,
height: "64px",
margin: "8px 16px",
borderRadius: "8px",
}}
onClick={() => onHeadState(group.name, { open: !headState?.open })}
>
{enable_group_icon &&
@@ -45,8 +57,8 @@ export const ProxyRender = (props: RenderProps) => {
group.icon.trim().startsWith("http") && (
<img
src={group.icon}
height="40px"
style={{ marginRight: "8px" }}
height="32px"
style={{ marginRight: "12px", borderRadius: "6px" }}
/>
)}
{enable_group_icon &&
@@ -54,8 +66,8 @@ export const ProxyRender = (props: RenderProps) => {
group.icon.trim().startsWith("data") && (
<img
src={group.icon}
height="40px"
style={{ marginRight: "8px" }}
height="32px"
style={{ marginRight: "12px", borderRadius: "6px" }}
/>
)}
{enable_group_icon &&
@@ -63,13 +75,14 @@ export const ProxyRender = (props: RenderProps) => {
group.icon.trim().startsWith("<svg") && (
<img
src={`data:image/svg+xml;base64,${btoa(group.icon)}`}
height="40px"
height="32px"
/>
)}
<ListItemText
primary={group.name}
primary={<StyledPrimary>{group.name}</StyledPrimary>}
secondary={
<ListItemTextChild
color="text.secondary"
sx={{
overflow: "hidden",
display: "flex",
@@ -78,11 +91,18 @@ export const ProxyRender = (props: RenderProps) => {
}}
>
<StyledTypeBox>{group.type}</StyledTypeBox>
<StyledSubtitle>{group.now}</StyledSubtitle>
<StyledSubtitle
sx={{
color: isDark ? "#ffffff" : "#8c8c8c",
fontWeight: "600",
}}
>
{group.now}
</StyledSubtitle>
</ListItemTextChild>
}
secondaryTypographyProps={{
sx: { display: "flex", alignItems: "center" },
sx: { display: "flex", alignItems: "center", color: "#ccc" },
}}
/>
{headState?.open ? <ExpandLessRounded /> : <ExpandMoreRounded />}
@@ -164,8 +184,16 @@ export const ProxyRender = (props: RenderProps) => {
return null;
};
const StyledPrimary = styled("span")`
font-size: 14px;
font-weight: 700;
line-height: 1.5;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
const StyledSubtitle = styled("span")`
font-size: 0.8rem;
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -182,7 +210,7 @@ const StyledTypeBox = styled(ListItemTextChild)(({ theme }) => ({
color: alpha(theme.palette.primary.main, 0.8),
borderRadius: 4,
fontSize: 10,
padding: "0 2px",
lineHeight: 1.25,
marginRight: "4px",
padding: "0 4px",
lineHeight: 1.5,
marginRight: "8px",
}));