From 890bfbe02d4112ff6cf10c204c9ddb56849112b4 Mon Sep 17 00:00:00 2001 From: MystiPanda Date: Thu, 4 Jul 2024 18:50:21 +0800 Subject: [PATCH] chore: unified style --- src/components/profile/group-item.tsx | 9 +-- src/components/profile/rule-item.tsx | 105 ++++++++++++++++++-------- 2 files changed, 78 insertions(+), 36 deletions(-) diff --git a/src/components/profile/group-item.tsx b/src/components/profile/group-item.tsx index 3da2fc58..bff1f0e9 100644 --- a/src/components/profile/group-item.tsx +++ b/src/components/profile/group-item.tsx @@ -9,7 +9,6 @@ import { import { DeleteForeverRounded, UndoRounded } from "@mui/icons-material"; import { useSortable } from "@dnd-kit/sortable"; import { CSS } from "@dnd-kit/utilities"; -import { useThemeMode } from "@/services/states"; interface Props { type: "prepend" | "original" | "delete" | "append"; group: IProxyGroupConfig; @@ -18,8 +17,6 @@ interface Props { export const GroupItem = (props: Props) => { let { type, group, onDelete } = props; - const themeMode = useThemeMode(); - const itembackgroundcolor = themeMode === "dark" ? "#282A36" : "#ffffff"; const sortable = type === "prepend" || type === "append"; const { attributes, listeners, setNodeRef, transform, transition } = sortable @@ -37,11 +34,12 @@ export const GroupItem = (props: Props) => { sx={({ palette }) => ({ background: type === "original" - ? itembackgroundcolor + ? palette.mode === "dark" + ? alpha(palette.background.paper, 0.3) + : alpha(palette.grey[400], 0.3) : type === "delete" ? alpha(palette.error.main, 0.3) : alpha(palette.success.main, 0.3), - height: "100%", margin: "8px 0", borderRadius: "8px", @@ -79,6 +77,7 @@ export const GroupItem = (props: Props) => { {...attributes} {...listeners} ref={setNodeRef} + sx={{ cursor: sortable ? "move" : "" }} primary={ { }; return ( ({ - p: 0, - borderRadius: "10px", - border: "solid 2px", - borderColor: + background: type === "original" - ? "var(--divider-color)" + ? palette.mode === "dark" + ? alpha(palette.background.paper, 0.3) + : alpha(palette.grey[400], 0.3) : type === "delete" - ? alpha(palette.error.main, 0.5) - : alpha(palette.success.main, 0.5), - mb: 1, + ? alpha(palette.error.main, 0.3) + : alpha(palette.success.main, 0.3), + height: "100%", + margin: "8px 0", + borderRadius: "8px", transform: CSS.Transform.toString(transform), transition, })} @@ -50,34 +51,76 @@ export const RuleItem = (props: Props) => { {...attributes} {...listeners} ref={setNodeRef} - sx={{ px: 1 }} + sx={{ cursor: sortable ? "move" : "" }} primary={ - <> - - {rule.length === 3 ? rule[1] : "-"} - - + + {rule.length === 3 ? rule[1] : "-"} + } secondary={ - - {rule[0]} - {rule.length === 3 ? rule[2] : rule[1]} - + + + {rule[0]} + + + {rule.length === 3 ? rule[2] : rule[1]} + + } + secondaryTypographyProps={{ + sx: { + display: "flex", + alignItems: "center", + color: "#ccc", + }, + }} /> - - + {type === "delete" ? : } ); }; + +const StyledPrimary = styled("span")` + font-size: 15px; + font-weight: 700; + line-height: 1.5; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +`; + +const StyledSubtitle = styled("span")` + font-size: 13px; + overflow: hidden; + color: text.secondary; + text-overflow: ellipsis; + white-space: nowrap; +`; + +const ListItemTextChild = styled("span")` + display: block; +`; + +const StyledTypeBox = styled(ListItemTextChild)(({ theme }) => ({ + display: "inline-block", + border: "1px solid #ccc", + borderColor: alpha(theme.palette.primary.main, 0.5), + color: alpha(theme.palette.primary.main, 0.8), + borderRadius: 4, + fontSize: 10, + padding: "0 4px", + lineHeight: 1.5, + marginRight: "8px", +}));