mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 06:53:44 +08:00
Style filter input (#724)
* refactor: reduce duplicate code * style: add a white background to the light color theme to avoid the gray text being too light
This commit is contained in:
parent
fd84e56c00
commit
ca8e3179bb
24
src/components/base/base-styled-text-field.tsx
Normal file
24
src/components/base/base-styled-text-field.tsx
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { TextField, type TextFieldProps, styled } from "@mui/material";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
export const BaseStyledTextField = styled((props: TextFieldProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TextField
|
||||||
|
hiddenLabel
|
||||||
|
fullWidth
|
||||||
|
size="small"
|
||||||
|
autoComplete="off"
|
||||||
|
variant="outlined"
|
||||||
|
spellCheck="false"
|
||||||
|
placeholder={t("Filter conditions")}
|
||||||
|
sx={{ input: { py: 0.65, px: 1.25 } }}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})(({ theme }) => ({
|
||||||
|
"& .MuiInputBase-root": {
|
||||||
|
background: theme.palette.mode === "light" ? "#fff" : undefined,
|
||||||
|
},
|
||||||
|
}));
|
@ -1,14 +1,6 @@
|
|||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import {
|
import { Box, Button, IconButton, MenuItem, Select } from "@mui/material";
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
IconButton,
|
|
||||||
MenuItem,
|
|
||||||
Paper,
|
|
||||||
Select,
|
|
||||||
TextField,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
import { Virtuoso } from "react-virtuoso";
|
import { Virtuoso } from "react-virtuoso";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@ -26,6 +18,7 @@ import {
|
|||||||
} from "@/components/connection/connection-detail";
|
} from "@/components/connection/connection-detail";
|
||||||
import parseTraffic from "@/utils/parse-traffic";
|
import parseTraffic from "@/utils/parse-traffic";
|
||||||
import { useCustomTheme } from "@/components/layout/use-custom-theme";
|
import { useCustomTheme } from "@/components/layout/use-custom-theme";
|
||||||
|
import { BaseStyledTextField } from "@/components/base/base-styled-text-field";
|
||||||
|
|
||||||
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
||||||
|
|
||||||
@ -185,17 +178,9 @@ const ConnectionsPage = () => {
|
|||||||
</Select>
|
</Select>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<TextField
|
<BaseStyledTextField
|
||||||
hiddenLabel
|
|
||||||
fullWidth
|
|
||||||
size="small"
|
|
||||||
autoComplete="off"
|
|
||||||
spellCheck="false"
|
|
||||||
variant="outlined"
|
|
||||||
placeholder={t("Filter conditions")}
|
|
||||||
value={filterText}
|
value={filterText}
|
||||||
onChange={(e) => setFilterText(e.target.value)}
|
onChange={(e) => setFilterText(e.target.value)}
|
||||||
sx={{ input: { py: 0.65, px: 1.25 } }}
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
IconButton,
|
IconButton,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
Paper,
|
|
||||||
Select,
|
Select,
|
||||||
TextField,
|
SelectProps,
|
||||||
|
styled,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { Virtuoso } from "react-virtuoso";
|
import { Virtuoso } from "react-virtuoso";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@ -19,6 +19,25 @@ import { atomEnableLog, atomLogData } from "@/services/states";
|
|||||||
import { BaseEmpty, BasePage } from "@/components/base";
|
import { BaseEmpty, BasePage } from "@/components/base";
|
||||||
import LogItem from "@/components/log/log-item";
|
import LogItem from "@/components/log/log-item";
|
||||||
import { useCustomTheme } from "@/components/layout/use-custom-theme";
|
import { useCustomTheme } from "@/components/layout/use-custom-theme";
|
||||||
|
import { BaseStyledTextField } from "@/components/base/base-styled-text-field";
|
||||||
|
|
||||||
|
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,
|
||||||
|
}));
|
||||||
|
|
||||||
const LogPage = () => {
|
const LogPage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -77,35 +96,19 @@ const LogPage = () => {
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Select
|
<StyledSelect
|
||||||
size="small"
|
|
||||||
autoComplete="off"
|
|
||||||
value={logState}
|
value={logState}
|
||||||
onChange={(e) => setLogState(e.target.value)}
|
onChange={(e) => setLogState(e.target.value)}
|
||||||
sx={{
|
|
||||||
width: 120,
|
|
||||||
height: 33.375,
|
|
||||||
mr: 1,
|
|
||||||
'[role="button"]': { py: 0.65 },
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<MenuItem value="all">ALL</MenuItem>
|
<MenuItem value="all">ALL</MenuItem>
|
||||||
<MenuItem value="inf">INFO</MenuItem>
|
<MenuItem value="inf">INFO</MenuItem>
|
||||||
<MenuItem value="warn">WARN</MenuItem>
|
<MenuItem value="warn">WARN</MenuItem>
|
||||||
<MenuItem value="err">ERROR</MenuItem>
|
<MenuItem value="err">ERROR</MenuItem>
|
||||||
</Select>
|
</StyledSelect>
|
||||||
|
|
||||||
<TextField
|
<BaseStyledTextField
|
||||||
hiddenLabel
|
|
||||||
fullWidth
|
|
||||||
size="small"
|
|
||||||
autoComplete="off"
|
|
||||||
spellCheck="false"
|
|
||||||
variant="outlined"
|
|
||||||
placeholder={t("Filter conditions")}
|
|
||||||
value={filterText}
|
value={filterText}
|
||||||
onChange={(e) => setFilterText(e.target.value)}
|
onChange={(e) => setFilterText(e.target.value)}
|
||||||
sx={{ input: { py: 0.65, px: 1.25 } }}
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
@ -2,15 +2,7 @@ import useSWR, { mutate } from "swr";
|
|||||||
import { useMemo, useRef, useState } from "react";
|
import { useMemo, useRef, useState } from "react";
|
||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import { useSetRecoilState } from "recoil";
|
import { useSetRecoilState } from "recoil";
|
||||||
import {
|
import { Box, Button, Grid, IconButton, Stack, Divider } from "@mui/material";
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
Grid,
|
|
||||||
IconButton,
|
|
||||||
Stack,
|
|
||||||
TextField,
|
|
||||||
Divider,
|
|
||||||
} from "@mui/material";
|
|
||||||
import {
|
import {
|
||||||
DndContext,
|
DndContext,
|
||||||
closestCenter,
|
closestCenter,
|
||||||
@ -56,6 +48,7 @@ import { ConfigViewer } from "@/components/setting/mods/config-viewer";
|
|||||||
import { throttle } from "lodash-es";
|
import { throttle } from "lodash-es";
|
||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
import { atomThemeMode } from "@/services/states";
|
import { atomThemeMode } from "@/services/states";
|
||||||
|
import { BaseStyledTextField } from "@/components/base/base-styled-text-field";
|
||||||
|
|
||||||
const ProfilePage = () => {
|
const ProfilePage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -299,16 +292,10 @@ const ProfilePage = () => {
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextField
|
<BaseStyledTextField
|
||||||
hiddenLabel
|
|
||||||
fullWidth
|
|
||||||
size="small"
|
|
||||||
value={url}
|
value={url}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
autoComplete="off"
|
|
||||||
spellCheck="false"
|
|
||||||
onChange={(e) => setUrl(e.target.value)}
|
onChange={(e) => setUrl(e.target.value)}
|
||||||
sx={{ input: { py: 0.65, px: 1.25 } }}
|
|
||||||
placeholder={t("Profile URL")}
|
placeholder={t("Profile URL")}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
sx: { pr: 1 },
|
sx: { pr: 1 },
|
||||||
|
@ -2,12 +2,13 @@ import useSWR from "swr";
|
|||||||
import { useState, useMemo } from "react";
|
import { useState, useMemo } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Virtuoso } from "react-virtuoso";
|
import { Virtuoso } from "react-virtuoso";
|
||||||
import { Box, TextField } from "@mui/material";
|
import { Box } from "@mui/material";
|
||||||
import { getRules } from "@/services/api";
|
import { getRules } from "@/services/api";
|
||||||
import { BaseEmpty, BasePage } from "@/components/base";
|
import { BaseEmpty, BasePage } from "@/components/base";
|
||||||
import RuleItem from "@/components/rule/rule-item";
|
import RuleItem from "@/components/rule/rule-item";
|
||||||
import { ProviderButton } from "@/components/rule/provider-button";
|
import { ProviderButton } from "@/components/rule/provider-button";
|
||||||
import { useCustomTheme } from "@/components/layout/use-custom-theme";
|
import { useCustomTheme } from "@/components/layout/use-custom-theme";
|
||||||
|
import { BaseStyledTextField } from "@/components/base/base-styled-text-field";
|
||||||
|
|
||||||
const RulesPage = () => {
|
const RulesPage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -41,17 +42,9 @@ const RulesPage = () => {
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextField
|
<BaseStyledTextField
|
||||||
hiddenLabel
|
|
||||||
fullWidth
|
|
||||||
size="small"
|
|
||||||
autoComplete="off"
|
|
||||||
variant="outlined"
|
|
||||||
spellCheck="false"
|
|
||||||
placeholder={t("Filter conditions")}
|
|
||||||
value={filterText}
|
value={filterText}
|
||||||
onChange={(e) => setFilterText(e.target.value)}
|
onChange={(e) => setFilterText(e.target.value)}
|
||||||
sx={{ input: { py: 0.65, px: 1.25 } }}
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user