feat(style): adjust style impl

This commit is contained in:
GyDi 2021-12-12 15:34:17 +08:00
parent adc634e5ea
commit 3b1a816b3b
2 changed files with 33 additions and 28 deletions

View File

@ -1,4 +1,4 @@
import { ListItem, ListItemButton, ListItemText } from "@mui/material"; import { alpha, ListItem, ListItemButton, ListItemText } from "@mui/material";
import { useMatch, useResolvedPath, useNavigate } from "react-router-dom"; import { useMatch, useResolvedPath, useNavigate } from "react-router-dom";
import type { LinkProps } from "react-router-dom"; import type { LinkProps } from "react-router-dom";
@ -12,42 +12,30 @@ const ListItemLink = (props: LinkProps) => {
return ( return (
<ListItem sx={{ py: 0.5, maxWidth: 250, mx: "auto" }}> <ListItem sx={{ py: 0.5, maxWidth: 250, mx: "auto" }}>
<ListItemButton <ListItemButton
selected={!!match}
sx={[ sx={[
{ {
color: "primary",
borderRadius: 2, borderRadius: 2,
textAlign: "center", textAlign: "center",
"& .MuiListItemText-primary": { color: "text.secondary" },
}, },
(theme) => { ({ palette: { mode, primary } }) => {
if (!match) return {}; const bgcolor =
mode === "light"
if (theme.palette.mode === "light") { ? alpha(primary.main, 0.15)
return { : alpha(primary.main, 0.35);
bgcolor: "rgba(91,92,157,0.15)", const color = mode === "light" ? primary.main : primary.light;
"&:hover": { bgcolor: "rgba(91,92,157,0.15)" },
};
}
return { return {
bgcolor: "rgba(91,92,157,0.35)", "&.Mui-selected": { bgcolor },
"&:hover": { bgcolor: "rgba(91,92,157,0.35)" }, "&.Mui-selected:hover": { bgcolor },
"&.Mui-selected .MuiListItemText-primary": { color },
}; };
}, },
]} ]}
onClick={() => navigate(to)} onClick={() => navigate(to)}
> >
<ListItemText <ListItemText primary={children} />
primary={children}
sx={{
color: (theme) => {
if (!match) return "text.secondary";
const light = theme.palette.mode === "light";
if (match && light) return "primary.main";
return "primary.light";
},
}}
/>
</ListItemButton> </ListItemButton>
</ListItem> </ListItem>
); );

View File

@ -1,6 +1,7 @@
import { useState } from "react"; import { useState } from "react";
import { Virtuoso } from "react-virtuoso"; import { Virtuoso } from "react-virtuoso";
import { import {
alpha,
Box, Box,
Collapse, Collapse,
Divider, Divider,
@ -32,9 +33,26 @@ const Item = ({ proxy, selected, onClick }: ItemProps) => {
return ( return (
<ListItem sx={{ py: 0, pl: 4 }}> <ListItem sx={{ py: 0, pl: 4 }}>
<ListItemButton <ListItemButton
dense
selected={selected} selected={selected}
onClick={() => onClick?.(proxy.name)} onClick={() => onClick?.(proxy.name)}
sx={{ borderRadius: 1, py: 0.5 }} 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;
return {
"&.Mui-selected": { bgcolor },
"&.Mui-selected .MuiListItemText-secondary": { color },
};
},
]}
> >
<ListItemText title={proxy.name} secondary={proxy.name} /> <ListItemText title={proxy.name} secondary={proxy.name} />
<ListItemIcon <ListItemIcon
@ -77,10 +95,9 @@ const ProxyGroup = ({ group }: Props) => {
return ( return (
<> <>
<ListItem button onClick={() => setOpen(!open)}> <ListItem button onClick={() => setOpen(!open)} dense>
<ListItemText <ListItemText
primary={group.name} primary={group.name}
sx={{ my: 0.25 }}
secondary={ secondary={
<> <>
<SendRounded color="primary" sx={{ mr: 1, fontSize: 14 }} /> <SendRounded color="primary" sx={{ mr: 1, fontSize: 14 }} />