Skip to content

Commit

Permalink
feat(style): adjust style impl
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzgydi committed Dec 12, 2021
1 parent adc634e commit 3b1a816
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
38 changes: 13 additions & 25 deletions src/components/list-item-link.tsx
Original file line number Diff line number Diff line change
@@ -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 type { LinkProps } from "react-router-dom";

Expand All @@ -12,42 +12,30 @@ const ListItemLink = (props: LinkProps) => {
return (
<ListItem sx={{ py: 0.5, maxWidth: 250, mx: "auto" }}>
<ListItemButton
selected={!!match}
sx={[
{
color: "primary",
borderRadius: 2,
textAlign: "center",
"& .MuiListItemText-primary": { color: "text.secondary" },
},
(theme) => {
if (!match) return {};

if (theme.palette.mode === "light") {
return {
bgcolor: "rgba(91,92,157,0.15)",
"&:hover": { bgcolor: "rgba(91,92,157,0.15)" },
};
}
({ 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 {
bgcolor: "rgba(91,92,157,0.35)",
"&:hover": { bgcolor: "rgba(91,92,157,0.35)" },
"&.Mui-selected": { bgcolor },
"&.Mui-selected:hover": { bgcolor },
"&.Mui-selected .MuiListItemText-primary": { color },
};
},
]}
onClick={() => navigate(to)}
>
<ListItemText
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";
},
}}
/>
<ListItemText primary={children} />
</ListItemButton>
</ListItem>
);
Expand Down
23 changes: 20 additions & 3 deletions src/components/proxy-group.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from "react";
import { Virtuoso } from "react-virtuoso";
import {
alpha,
Box,
Collapse,
Divider,
Expand Down Expand Up @@ -32,9 +33,26 @@ const Item = ({ proxy, selected, onClick }: ItemProps) => {
return (
<ListItem sx={{ py: 0, pl: 4 }}>
<ListItemButton
dense
selected={selected}
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} />
<ListItemIcon
Expand Down Expand Up @@ -77,10 +95,9 @@ const ProxyGroup = ({ group }: Props) => {

return (
<>
<ListItem button onClick={() => setOpen(!open)}>
<ListItem button onClick={() => setOpen(!open)} dense>
<ListItemText
primary={group.name}
sx={{ my: 0.25 }}
secondary={
<>
<SendRounded color="primary" sx={{ mr: 1, fontSize: 14 }} />
Expand Down

0 comments on commit 3b1a816

Please sign in to comment.