Skip to content

Commit

Permalink
chore: fix select component bg in connection
Browse files Browse the repository at this point in the history
  • Loading branch information
dongchengjie committed May 18, 2024
1 parent ae6f42a commit 021e430
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
19 changes: 19 additions & 0 deletions src/components/base/base-styled-select.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Select, SelectProps, styled } from "@mui/material";

export const BaseStyledSelect = styled((props: SelectProps<string>) => {
return (
<Select
size="small"
autoComplete="off"
sx={{
width: 120,
height: 33.375,
mr: 1,
'[role="button"]': { py: 0.65 },
}}
{...props}
/>
);
})(({ theme }) => ({
background: theme.palette.mode === "light" ? "#fff" : undefined,
}));
23 changes: 12 additions & 11 deletions src/pages/connections.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { useLockFn } from "ahooks";
import { Box, Button, IconButton, MenuItem, Select } from "@mui/material";
import {
Box,
Button,
IconButton,
MenuItem,
Select,
SelectProps,
styled,
} from "@mui/material";
import { useRecoilState } from "recoil";
import { Virtuoso } from "react-virtuoso";
import { useTranslation } from "react-i18next";
Expand All @@ -19,6 +27,7 @@ import {
import parseTraffic from "@/utils/parse-traffic";
import { useCustomTheme } from "@/components/layout/use-custom-theme";
import { BaseSearchBox } from "@/components/base/base-search-box";
import { BaseStyledSelect } from "@/components/base/base-styled-select";

const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };

Expand Down Expand Up @@ -163,24 +172,16 @@ const ConnectionsPage = () => {
}}
>
{!isTableLayout && (
<Select
size="small"
autoComplete="off"
<BaseStyledSelect
value={curOrderOpt}
onChange={(e) => setOrderOpt(e.target.value)}
sx={{
mr: 1,
width: i18n.language === "en" ? 190 : 120,
height: 33.375,
'[role="button"]': { py: 0.65 },
}}
>
{Object.keys(orderOpts).map((opt) => (
<MenuItem key={opt} value={opt}>
<span style={{ fontSize: 14 }}>{t(opt)}</span>
</MenuItem>
))}
</Select>
</BaseStyledSelect>
)}
<BaseSearchBox onSearch={(match) => setMatch(() => match)} />
</Box>
Expand Down
23 changes: 3 additions & 20 deletions src/pages/logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,7 @@ import { BaseEmpty, BasePage } from "@/components/base";
import LogItem from "@/components/log/log-item";
import { useCustomTheme } from "@/components/layout/use-custom-theme";
import { BaseSearchBox } from "@/components/base/base-search-box";

const StyledSelect = styled((props: SelectProps<string>) => {
return (
<Select
size="small"
autoComplete="off"
sx={{
width: 120,
height: 33.375,
mr: 1,
'[role="button"]': { py: 0.65 },
}}
{...props}
/>
);
})(({ theme }) => ({
background: theme.palette.mode === "light" ? "#fff" : undefined,
}));
import { BaseStyledSelect } from "@/components/base/base-styled-select";

const LogPage = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -95,15 +78,15 @@ const LogPage = () => {
alignItems: "center",
}}
>
<StyledSelect
<BaseStyledSelect
value={logState}
onChange={(e) => setLogState(e.target.value)}
>
<MenuItem value="all">ALL</MenuItem>
<MenuItem value="inf">INFO</MenuItem>
<MenuItem value="warn">WARN</MenuItem>
<MenuItem value="err">ERROR</MenuItem>
</StyledSelect>
</BaseStyledSelect>
<BaseSearchBox onSearch={(match) => setMatch(() => match)} />
</Box>

Expand Down

0 comments on commit 021e430

Please sign in to comment.