summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorHaishan <[email protected]>2022-06-06 23:39:56 +0800
committerHaishan <[email protected]>2022-06-06 23:39:56 +0800
commit78f3434cb52f53c66936de278f0828c19ef63666 (patch)
treee7f9685cc0f3d8eaa6a94ad330e8876752ecb276 /src/components
parent23e734aa548354bb7ceff5ad8d85de95cd860a55 (diff)
Run prettier
Diffstat (limited to 'src/components')
-rw-r--r--src/components/APIConfig.tsx5
-rw-r--r--src/components/BackendList.tsx11
-rw-r--r--src/components/Collapsible.tsx13
-rw-r--r--src/components/CollapsibleSectionHeader.tsx7
-rw-r--r--src/components/ConnectionTable.tsx5
-rw-r--r--src/components/Logs.tsx2
-rw-r--r--src/components/Rules.tsx2
-rw-r--r--src/components/Search.tsx7
-rw-r--r--src/components/SideBar.tsx9
-rw-r--r--src/components/SvgYacd.tsx7
-rw-r--r--src/components/ToggleSwitch.tsx5
-rw-r--r--src/components/TrafficChart.tsx10
-rw-r--r--src/components/about/About.tsx29
-rw-r--r--src/components/proxies/ClosePrevConns.tsx9
-rw-r--r--src/components/proxies/Proxies.tsx20
-rw-r--r--src/components/proxies/Proxy.module.scss3
-rw-r--r--src/components/proxies/Proxy.tsx27
-rw-r--r--src/components/proxies/ProxyGroup.module.scss9
-rw-r--r--src/components/proxies/ProxyGroup.tsx23
-rw-r--r--src/components/proxies/ProxyList.tsx7
-rw-r--r--src/components/proxies/ProxyPageFab.tsx7
-rw-r--r--src/components/proxies/ProxyProvider.tsx7
-rw-r--r--src/components/proxies/ProxyProviderList.tsx6
-rw-r--r--src/components/proxies/Settings.tsx6
-rw-r--r--src/components/proxies/hooks.tsx12
-rw-r--r--src/components/proxies/proxies.hooks.tsx9
-rw-r--r--src/components/rules/RuleProviderItem.module.scss13
-rw-r--r--src/components/rules/RuleProviderItem.tsx14
-rw-r--r--src/components/shared/Fab.tsx12
-rw-r--r--src/components/shared/RotateIcon.tsx9
-rw-r--r--src/components/shared/TextFitler.tsx5
-rw-r--r--src/components/svg/Equalizer.tsx5
32 files changed, 83 insertions, 232 deletions
diff --git a/src/components/APIConfig.tsx b/src/components/APIConfig.tsx
index 6e11bc4..4a11c92 100644
--- a/src/components/APIConfig.tsx
+++ b/src/components/APIConfig.tsx
@@ -72,9 +72,9 @@ function APIConfig({ dispatch }) {
const detectApiServer = async () => {
// if there is already a clash API server at `/`, just use it as default value
const res = await fetch('/');
- res.json().then(data => {
+ res.json().then((data) => {
if (data['hello'] === 'clash') {
- setBaseURL(window.location.origin)
+ setBaseURL(window.location.origin);
}
});
};
@@ -82,7 +82,6 @@ function APIConfig({ dispatch }) {
detectApiServer();
}, []);
-
return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div className={s0.root} ref={contentEl} onKeyDown={handleContentOnKeyDown}>
diff --git a/src/components/BackendList.tsx b/src/components/BackendList.tsx
index 8e0d906..e4f4d80 100644
--- a/src/components/BackendList.tsx
+++ b/src/components/BackendList.tsx
@@ -2,10 +2,7 @@ import cx from 'clsx';
import * as React from 'react';
import { Eye, EyeOff, X as Close } from 'react-feather';
import { useToggle } from 'src/hooks/basic';
-import {
- getClashAPIConfigs,
- getSelectedClashAPIConfigIndex,
-} from 'src/store/app';
+import { getClashAPIConfigs, getSelectedClashAPIConfigIndex } from 'src/store/app';
import { ClashAPIConfig } from 'src/types';
import s from './BackendList.module.scss';
@@ -137,11 +134,7 @@ function Button({
disabled?: boolean;
}) {
return (
- <button
- disabled={disabled}
- className={cx(className, s.btn)}
- onClick={onClick}
- >
+ <button disabled={disabled} className={cx(className, s.btn)} onClick={onClick}>
{children}
</button>
);
diff --git a/src/components/Collapsible.tsx b/src/components/Collapsible.tsx
index e9a1ee8..819bc7c 100644
--- a/src/components/Collapsible.tsx
+++ b/src/components/Collapsible.tsx
@@ -60,20 +60,11 @@ const Collapsible = memo(({ children, isOpen }) => {
return (
<div>
<motion.div
- animate={
- isOpen && previous === isOpen
- ? 'initialOpen'
- : isOpen
- ? 'open'
- : 'closed'
- }
+ animate={isOpen && previous === isOpen ? 'initialOpen' : isOpen ? 'open' : 'closed'}
custom={height}
variants={variantsCollpapsibleWrap}
>
- <motion.div
- variants={variantsCollpapsibleChildContainer}
- ref={refToMeature}
- >
+ <motion.div variants={variantsCollpapsibleChildContainer} ref={refToMeature}>
{children}
</motion.div>
</motion.div>
diff --git a/src/components/CollapsibleSectionHeader.tsx b/src/components/CollapsibleSectionHeader.tsx
index 2d5ecd1..8b701e1 100644
--- a/src/components/CollapsibleSectionHeader.tsx
+++ b/src/components/CollapsibleSectionHeader.tsx
@@ -39,12 +39,7 @@ export default function Header({ name, type, toggle, isOpen, qty }: Props) {
{typeof qty === 'number' ? <span className={s.qty}>{qty}</span> : null}
- <Button
- kind="minimal"
- onClick={toggle}
- className={s.btn}
- title="Toggle collapsible section"
- >
+ <Button kind="minimal" onClick={toggle} className={s.btn} title="Toggle collapsible section">
<span className={cx(s.arrow, { [s.isOpen]: isOpen })}>
<ChevronDown size={20} />
</span>
diff --git a/src/components/ConnectionTable.tsx b/src/components/ConnectionTable.tsx
index 2323e2e..15261a3 100644
--- a/src/components/ConnectionTable.tsx
+++ b/src/components/ConnectionTable.tsx
@@ -64,10 +64,7 @@ function Table({ data }) {
return (
<div {...headerGroup.getHeaderGroupProps()} className={s.tr}>
{headerGroup.headers.map((column) => (
- <div
- {...column.getHeaderProps(column.getSortByToggleProps())}
- className={s.th}
- >
+ <div {...column.getHeaderProps(column.getSortByToggleProps())} className={s.th}>
<span>{column.render('Header')}</span>
<span className={s.sortIconContainer}>
{column.isSorted ? (
diff --git a/src/components/Logs.tsx b/src/components/Logs.tsx
index d9c53d7..5930634 100644
--- a/src/components/Logs.tsx
+++ b/src/components/Logs.tsx
@@ -3,7 +3,7 @@ import * as React from 'react';
import { Pause, Play } from 'react-feather';
import { useTranslation } from 'react-i18next';
import { areEqual, FixedSizeList as List, ListChildComponentProps } from 'react-window';
-import { fetchLogs, reconnect as reconnectLogs,stop as stopLogs } from 'src/api/logs';
+import { fetchLogs, reconnect as reconnectLogs, stop as stopLogs } from 'src/api/logs';
import ContentHeader from 'src/components/ContentHeader';
import LogSearch from 'src/components/LogSearch';
import { connect, useStoreActions } from 'src/components/StateProvider';
diff --git a/src/components/Rules.tsx b/src/components/Rules.tsx
index 47644e7..e6e1422 100644
--- a/src/components/Rules.tsx
+++ b/src/components/Rules.tsx
@@ -41,7 +41,7 @@ function getItemSizeFactory({ provider }) {
const providerQty = provider.names.length;
if (idx < providerQty) {
// provider
- return 90;
+ return 110;
}
// rule
return 80;
diff --git a/src/components/Search.tsx b/src/components/Search.tsx
index 6edc4a5..9762d8f 100644
--- a/src/components/Search.tsx
+++ b/src/components/Search.tsx
@@ -25,12 +25,7 @@ function RuleSearch({ dispatch, searchText, updateSearchText }) {
<div className={s0.RuleSearch}>
<div className={s0.RuleSearchContainer}>
<div className={s0.inputWrapper}>
- <input
- type="text"
- value={text}
- onChange={onChange}
- className={s0.input}
- />
+ <input type="text" value={text} onChange={onChange} className={s0.input} />
</div>
<div className={s0.iconWrapper}>
<SearchIcon size={20} />
diff --git a/src/components/SideBar.tsx b/src/components/SideBar.tsx
index dbe7f0d..2c5ba0c 100644
--- a/src/components/SideBar.tsx
+++ b/src/components/SideBar.tsx
@@ -3,14 +3,7 @@ import cx from 'clsx';
import * as React from 'react';
import { Info } from 'react-feather';
import { useTranslation } from 'react-i18next';
-import {
- FcAreaChart,
- FcDocument,
- FcGlobe,
- FcLink,
- FcRuler,
- FcSettings,
-} from 'react-icons/fc';
+import { FcAreaChart, FcDocument, FcGlobe, FcLink, FcRuler, FcSettings } from 'react-icons/fc';
import { Link, useLocation } from 'react-router-dom';
import { ThemeSwitcher } from 'src/components/shared/ThemeSwitcher';
diff --git a/src/components/SvgYacd.tsx b/src/components/SvgYacd.tsx
index 63c0bd5..499456d 100644
--- a/src/components/SvgYacd.tsx
+++ b/src/components/SvgYacd.tsx
@@ -25,12 +25,7 @@ function SvgYacd({
}: Props) {
const faceClasName = cx({ [s.path]: animate });
return (
- <svg
- width={width}
- height={height}
- viewBox="0 0 320 320"
- xmlns="http://www.w3.org/2000/svg"
- >
+ <svg width={width} height={height} viewBox="0 0 320 320" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fillRule="evenodd">
{/* face */}
<path
diff --git a/src/components/ToggleSwitch.tsx b/src/components/ToggleSwitch.tsx
index 9eb1019..58400c9 100644
--- a/src/components/ToggleSwitch.tsx
+++ b/src/components/ToggleSwitch.tsx
@@ -10,10 +10,7 @@ type Props = {
};
function ToggleSwitch({ options, value, name, onChange }: Props) {
- const idxSelected = useMemo(
- () => options.map((o) => o.value).indexOf(value),
- [options, value]
- );
+ const idxSelected = useMemo(() => options.map((o) => o.value).indexOf(value), [options, value]);
const getPortionPercentage = useCallback(
(idx: number) => {
diff --git a/src/components/TrafficChart.tsx b/src/components/TrafficChart.tsx
index 367166a..c6bf8ff 100644
--- a/src/components/TrafficChart.tsx
+++ b/src/components/TrafficChart.tsx
@@ -1,15 +1,11 @@
import * as React from 'react';
import { useTranslation } from 'react-i18next';
-import { State } from '$src/store/types';
+import { State } from '$src/store/types';
import { fetchData } from '../api/traffic';
import useLineChart from '../hooks/useLineChart';
-import {
- chartJSResource,
- chartStyles,
- commonDataSetProps,
-} from '../misc/chart';
+import { chartJSResource, chartStyles, commonDataSetProps } from '../misc/chart';
import { getClashAPIConfig, getSelectedChartStyleIndex } from '../store/app';
import { connect } from './StateProvider';
@@ -50,7 +46,7 @@ function TrafficChart({ apiConfig, selectedChartStyleIndex }) {
},
],
}),
- [ traffic, selectedChartStyleIndex, t]
+ [traffic, selectedChartStyleIndex, t]
);
useLineChart(ChartMod.Chart, 'trafficChart', data, traffic);
diff --git a/src/components/about/About.tsx b/src/components/about/About.tsx
index 6ed01ad..f59ce20 100644
--- a/src/components/about/About.tsx
+++ b/src/components/about/About.tsx
@@ -11,15 +11,7 @@ import s from './About.module.scss';
type Props = { apiConfig: ClashAPIConfig };
-function Version({
- name,
- link,
- version,
-}: {
- name: string;
- link: string;
- version: string;
-}) {
+function Version({ name, link, version }: { name: string; link: string; version: string }) {
return (
<div className={s.root}>
<h2>{name}</h2>
@@ -28,12 +20,7 @@ function Version({
<span className={s.mono}>{version}</span>
</p>
<p>
- <a
- className={s.link}
- href={link}
- target="_blank"
- rel="noopener noreferrer"
- >
+ <a className={s.link} href={link} target="_blank" rel="noopener noreferrer">
<GitHub size={20} />
<span>Source</span>
</a>
@@ -50,17 +37,9 @@ function AboutImpl(props: Props) {
<>
<ContentHeader title="About" />
{version && version.version ? (
- <Version
- name="Clash"
- version={version.version}
- link="https://github.com/Dreamacro/clash"
- />
+ <Version name="Clash" version={version.version} link="https://github.com/Dreamacro/clash" />
) : null}
- <Version
- name="Yacd"
- version={__VERSION__}
- link="https://github.com/haishanh/yacd"
- />
+ <Version name="Yacd" version={__VERSION__} link="https://github.com/haishanh/yacd" />
</>
);
}
diff --git a/src/components/proxies/ClosePrevConns.tsx b/src/components/proxies/ClosePrevConns.tsx
index 5617efe..f26a5e9 100644
--- a/src/components/proxies/ClosePrevConns.tsx
+++ b/src/components/proxies/ClosePrevConns.tsx
@@ -10,10 +10,7 @@ type Props = {
onClickSecondaryButton?: () => void;
};
-export function ClosePrevConns({
- onClickPrimaryButton,
- onClickSecondaryButton,
-}: Props) {
+export function ClosePrevConns({ onClickPrimaryButton, onClickSecondaryButton }: Props) {
const primaryButtonRef = useRef<HTMLButtonElement>(null);
const secondaryButtonRef = useRef<HTMLButtonElement>(null);
useEffect(() => {
@@ -33,8 +30,8 @@ export function ClosePrevConns({
<div onKeyDown={handleKeyDown}>
<h2>Close Connections?</h2>
<p>
- Click "Yes" to close those connections that are still using the old
- selected proxy in this group
+ Click "Yes" to close those connections that are still using the old selected proxy in this
+ group
</p>
<div style={{ height: 30 }} />
<FlexCenter>
diff --git a/src/components/proxies/Proxies.tsx b/src/components/proxies/Proxies.tsx
index c1606dd..12d3cb2 100644
--- a/src/components/proxies/Proxies.tsx
+++ b/src/components/proxies/Proxies.tsx
@@ -35,9 +35,7 @@ function Proxies({
apiConfig,
showModalClosePrevConns,
}) {
- const refFetchedTimestamp = useRef<{ startAt?: number; completeAt?: number }>(
- {}
- );
+ const refFetchedTimestamp = useRef<{ startAt?: number; completeAt?: number }>({});
const fetchProxiesHooked = useCallback(() => {
refFetchedTimestamp.current.startAt = Date.now();
@@ -75,10 +73,7 @@ function Proxies({
return (
<>
- <BaseModal
- isOpen={isSettingsModalOpen}
- onRequestClose={closeSettingsModal}
- >
+ <BaseModal isOpen={isSettingsModalOpen} onRequestClose={closeSettingsModal}>
<Settings />
</BaseModal>
<div className={s0.topBar}>
@@ -110,15 +105,8 @@ function Proxies({
</div>
<ProxyProviderList items={proxyProviders} />
<div style={{ height: 60 }} />
- <ProxyPageFab
- dispatch={dispatch}
- apiConfig={apiConfig}
- proxyProviders={proxyProviders}
- />
- <BaseModal
- isOpen={showModalClosePrevConns}
- onRequestClose={closeModalClosePrevConns}
- >
+ <ProxyPageFab dispatch={dispatch} apiConfig={apiConfig} proxyProviders={proxyProviders} />
+ <BaseModal isOpen={showModalClosePrevConns} onRequestClose={closeModalClosePrevConns}>
<ClosePrevConns
onClickPrimaryButton={() => closePrevConnsAndTheModal(apiConfig)}
onClickSecondaryButton={closeModalClosePrevConns}
diff --git a/src/components/proxies/Proxy.module.scss b/src/components/proxies/Proxy.module.scss
index b25948b..044722f 100644
--- a/src/components/proxies/Proxy.module.scss
+++ b/src/components/proxies/Proxy.module.scss
@@ -58,9 +58,6 @@
width: 100%;
margin-bottom: 5px;
font-size: 0.85em;
- @media (--breakpoint-not-small) {
- font-size: 1em;
- }
}
.proxySmall {
diff --git a/src/components/proxies/Proxy.tsx b/src/components/proxies/Proxy.tsx
index 424d320..8dc8caa 100644
--- a/src/components/proxies/Proxy.tsx
+++ b/src/components/proxies/Proxy.tsx
@@ -58,18 +58,8 @@ type ProxyProps = {
onClick?: (proxyName: string) => unknown;
};
-function ProxySmallImpl({
- now,
- name,
- proxy,
- latency,
- isSelectable,
- onClick,
-}: ProxyProps) {
- const color = useMemo(() => getProxyDotBackgroundColor(latency, proxy.type), [
- latency,
- proxy,
- ]);
+function ProxySmallImpl({ now, name, proxy, latency, isSelectable, onClick }: ProxyProps) {
+ const color = useMemo(() => getProxyDotBackgroundColor(latency, proxy.type), [latency, proxy]);
const title = useMemo(() => {
let ret = name;
if (latency && typeof latency.number === 'number') {
@@ -115,14 +105,7 @@ function formatProxyType(t: string) {
return t;
}
-function ProxyImpl({
- now,
- name,
- proxy,
- latency,
- isSelectable,
- onClick,
-}: ProxyProps) {
+function ProxyImpl({ now, name, proxy, latency, isSelectable, onClick }: ProxyProps) {
const color = useMemo(() => getLabelColor(latency), [latency]);
const doSelect = React.useCallback(() => {
isSelectable && onClick && onClick(name);
@@ -156,9 +139,7 @@ function ProxyImpl({
<span className={s0.proxyType} style={{ opacity: now ? 0.6 : 0.2 }}>
{formatProxyType(proxy.type)}
</span>
- {latency && latency.number ? (
- <ProxyLatency number={latency.number} color={color} />
- ) : null}
+ {latency && latency.number ? <ProxyLatency number={latency.number} color={color} /> : null}
</div>
</div>
);
diff --git a/src/components/proxies/ProxyGroup.module.scss b/src/components/proxies/ProxyGroup.module.scss
index 5409ea8..6e9d91f 100644
--- a/src/components/proxies/ProxyGroup.module.scss
+++ b/src/components/proxies/ProxyGroup.module.scss
@@ -2,6 +2,15 @@
margin-bottom: 12px;
}
+.groupHead {
+ display: flex;
+ align-items: center;
+}
+
+.latencyButton {
+ margin-left: 5px;
+}
+
.zapWrapper {
width: 20px;
height: 20px;
diff --git a/src/components/proxies/ProxyGroup.tsx b/src/components/proxies/ProxyGroup.tsx
index 32705c1..d6a4e99 100644
--- a/src/components/proxies/ProxyGroup.tsx
+++ b/src/components/proxies/ProxyGroup.tsx
@@ -1,11 +1,9 @@
import * as React from 'react';
import { Zap } from 'react-feather';
-import {
- getCollapsibleIsOpen,
- getHideUnavailableProxies,
- getProxySortBy,
-} from '../../store/app';
+import { State } from '$src/store/types';
+
+import { getCollapsibleIsOpen, getHideUnavailableProxies, getProxySortBy } from '../../store/app';
import { getProxies, switchProxy } from '../../store/proxies';
import Button from '../Button';
import CollapsibleSectionHeader from '../CollapsibleSectionHeader';
@@ -37,13 +35,7 @@ function ProxyGroupImpl({
apiConfig,
dispatch,
}) {
- const all = useFilteredAndSorted(
- allItems,
- delay,
- hideUnavailableProxies,
- proxySortBy,
- proxies
- );
+ const all = useFilteredAndSorted(allItems, delay, hideUnavailableProxies, proxySortBy, proxies);
const isSelectable = useMemo(() => type === 'Selector', [type]);
@@ -57,7 +49,7 @@ function ProxyGroupImpl({
}, [isOpen, updateCollapsibleIsOpen, name]);
const itemOnTapCallback = useCallback(
- (proxyName) => {
+ (proxyName: string) => {
if (!isSelectable) return;
dispatch(switchProxy(apiConfig, name, proxyName));
},
@@ -75,7 +67,7 @@ function ProxyGroupImpl({
return (
<div className={s0.group}>
- <div style={{ display: 'flex', alignItems: 'center' }}>
+ <div className={s0.groupHead}>
<CollapsibleSectionHeader
name={name}
type={type}
@@ -84,6 +76,7 @@ function ProxyGroupImpl({
isOpen={isOpen}
/>
<Button
+ className={s0.latencyButton}
title="Test latency"
kind="minimal"
onClick={testLatency}
@@ -102,7 +95,7 @@ function ProxyGroupImpl({
);
}
-export const ProxyGroup = connect((s, { name, delay }) => {
+export const ProxyGroup = connect((s: State, { name, delay }) => {
const proxies = getProxies(s);
const collapsibleIsOpen = getCollapsibleIsOpen(s);
const proxySortBy = getProxySortBy(s);
diff --git a/src/components/proxies/ProxyList.tsx b/src/components/proxies/ProxyList.tsx
index a86bb88..3856c68 100644
--- a/src/components/proxies/ProxyList.tsx
+++ b/src/components/proxies/ProxyList.tsx
@@ -11,12 +11,7 @@ type ProxyListProps = {
show?: boolean;
};
-export function ProxyList({
- all,
- now,
- isSelectable,
- itemOnTapCallback,
-}: ProxyListProps) {
+export function ProxyList({ all, now, isSelectable, itemOnTapCallback }: ProxyListProps) {
const proxies = all;
return (
diff --git a/src/components/proxies/ProxyPageFab.tsx b/src/components/proxies/ProxyPageFab.tsx
index 7cc6d03..44e446f 100644
--- a/src/components/proxies/ProxyPageFab.tsx
+++ b/src/components/proxies/ProxyPageFab.tsx
@@ -2,12 +2,7 @@ import * as React from 'react';
import { Zap } from 'react-feather';
import { useTranslation } from 'react-i18next';
import { useUpdateProviderItems } from 'src/components/proxies/proxies.hooks';
-import {
- Action,
- Fab,
- IsFetching,
- position as fabPosition,
-} from 'src/components/shared/Fab';
+import { Action, Fab, IsFetching, position as fabPosition } from 'src/components/shared/Fab';
import { RotateIcon } from 'src/components/shared/RotateIcon';
import { requestDelayAll } from 'src/store/proxies';
import { DispatchFn, FormattedProxyProvider } from 'src/store/types';
diff --git a/src/components/proxies/ProxyProvider.tsx b/src/components/proxies/ProxyProvider.tsx
index 055a572..af5be18 100644
--- a/src/components/proxies/ProxyProvider.tsx
+++ b/src/components/proxies/ProxyProvider.tsx
@@ -48,12 +48,7 @@ function ProxyProviderImpl({
dispatch,
apiConfig,
}: Props) {
- const proxies = useFilteredAndSorted(
- all,
- delay,
- hideUnavailableProxies,
- proxySortBy
- );
+ const proxies = useFilteredAndSorted(all, delay, hideUnavailableProxies, proxySortBy);
const [isHealthcheckLoading, setIsHealthcheckLoading] = useState(false);
const updateProvider = useUpdateProviderItem({ dispatch, apiConfig, name });
diff --git a/src/components/proxies/ProxyProviderList.tsx b/src/components/proxies/ProxyProviderList.tsx
index 1528f37..754eeac 100644
--- a/src/components/proxies/ProxyProviderList.tsx
+++ b/src/components/proxies/ProxyProviderList.tsx
@@ -3,11 +3,7 @@ import ContentHeader from 'src/components/ContentHeader';
import { ProxyProvider } from 'src/components/proxies/ProxyProvider';
import { FormattedProxyProvider } from 'src/store/types';
-export function ProxyProviderList({
- items,
-}: {
- items: FormattedProxyProvider[];
-}) {
+export function ProxyProviderList({ items }: { items: FormattedProxyProvider[] }) {
if (items.length === 0) return null;
return (
diff --git a/src/components/proxies/Settings.tsx b/src/components/proxies/Settings.tsx
index 5e1ff98..55e18fe 100644
--- a/src/components/proxies/Settings.tsx
+++ b/src/components/proxies/Settings.tsx
@@ -2,11 +2,7 @@ import * as React from 'react';
import { useTranslation } from 'react-i18next';
import Select from 'src/components/shared/Select';
-import {
- getAutoCloseOldConns,
- getHideUnavailableProxies,
- getProxySortBy,
-} from '../../store/app';
+import { getAutoCloseOldConns, getHideUnavailableProxies, getProxySortBy } from '../../store/app';
import { connect, useStoreActions } from '../StateProvider';
import Switch from '../SwitchThemed';
import s from './Settings.module.scss';
diff --git a/src/components/proxies/hooks.tsx b/src/components/proxies/hooks.tsx
index 861c0e5..a43dc0e 100644
--- a/src/components/proxies/hooks.tsx
+++ b/src/components/proxies/hooks.tsx
@@ -45,22 +45,14 @@ const getSortDelay = (
const ProxySortingFns = {
Natural: (proxies: string[]) => proxies,
- LatencyAsc: (
- proxies: string[],
- delay: DelayMapping,
- proxyMapping?: ProxiesMapping
- ) => {
+ LatencyAsc: (proxies: string[], delay: DelayMapping, proxyMapping?: ProxiesMapping) => {
return proxies.sort((a, b) => {
const d1 = getSortDelay(delay[a], proxyMapping && proxyMapping[a]);
const d2 = getSortDelay(delay[b], proxyMapping && proxyMapping[b]);
return d1 - d2;
});
},
- LatencyDesc: (
- proxies: string[],
- delay: DelayMapping,
- proxyMapping?: ProxiesMapping
- ) => {
+ LatencyDesc: (proxies: string[], delay: DelayMapping, proxyMapping?: ProxiesMapping) => {
return proxies.sort((a, b) => {
const d1 = getSortDelay(delay[a], proxyMapping && proxyMapping[a]);
const d2 = getSortDelay(delay[b], proxyMapping && proxyMapping[b]);
diff --git a/src/components/proxies/proxies.hooks.tsx b/src/components/proxies/proxies.hooks.tsx
index ec51c9b..20695ac 100644
--- a/src/components/proxies/proxies.hooks.tsx
+++ b/src/components/proxies/proxies.hooks.tsx
@@ -14,11 +14,10 @@ export function useUpdateProviderItem({
apiConfig: ClashAPIConfig;
name: string;
}) {
- return useCallback(() => dispatch(updateProviderByName(apiConfig, name)), [
- apiConfig,
- dispatch,
- name,
- ]);
+ return useCallback(
+ () => dispatch(updateProviderByName(apiConfig, name)),
+ [apiConfig, dispatch, name]
+ );
}
export function useUpdateProviderItems({
diff --git a/src/components/rules/RuleProviderItem.module.scss b/src/components/rules/RuleProviderItem.module.scss
index 532ec8a..c3e1f07 100644
--- a/src/components/rules/RuleProviderItem.module.scss
+++ b/src/components/rules/RuleProviderItem.module.scss
@@ -13,6 +13,7 @@
.middle {
display: grid;
+ gap: 6px;
grid-template-rows: 1fr auto auto;
align-items: center;
}
@@ -21,13 +22,13 @@
color: #777;
}
-.refreshButtonWrapper {
+.action {
display: grid;
- place-items: center;
- opacity: 0;
- transition: opacity 0.2s;
+ gap: 4px;
+ grid-template-columns: auto 1fr;
+ align-items: center;
}
-.RuleProviderItem:hover .refreshButtonWrapper {
- opacity: 1;
+.refreshBtn {
+ padding: 5px;
}
diff --git a/src/components/rules/RuleProviderItem.tsx b/src/components/rules/RuleProviderItem.tsx
index fc88ae1..c27e464 100644
--- a/src/components/rules/RuleProviderItem.tsx
+++ b/src/components/rules/RuleProviderItem.tsx
@@ -24,14 +24,14 @@ export function RuleProviderItem({
<div className={s.middle}>
<SectionNameType name={name} type={`${vehicleType} / ${behavior}`} />
<div className={s.gray}>{ruleCount < 2 ? `${ruleCount} rule` : `${ruleCount} rules`}</div>
- <small className={s.gray}>Updated {timeAgo} ago</small>
+ <div className={s.action}>
+ <Button onClick={onClickRefreshButton} disabled={isRefreshing} className={s.refreshBtn}>
+ <RotateIcon isRotating={isRefreshing} size={13} />
+ <span className="visually-hidden">Refresh</span>
+ </Button>
+ <small className={s.gray}>Updated {timeAgo} ago</small>
+ </div>
</div>
- <span className={s.refreshButtonWrapper}>
- <Button onClick={onClickRefreshButton} disabled={isRefreshing} kind="circular">
- <RotateIcon isRotating={isRefreshing} />
- <span className="visually-hidden">Refresh</span>
- </Button>
- </span>
</div>
);
}
diff --git a/src/components/shared/Fab.tsx b/src/components/shared/Fab.tsx
index 832306e..8e72432 100644
--- a/src/components/shared/Fab.tsx
+++ b/src/components/shared/Fab.tsx
@@ -28,8 +28,7 @@ const AB: React.FC<ABProps> = ({ children, ...p }) => (
</button>
);
-interface MBProps
- extends Omit<React.HTMLAttributes<HTMLButtonElement>, 'tabIndex'> {
+interface MBProps extends Omit<React.HTMLAttributes<HTMLButtonElement>, 'tabIndex'> {
tabIndex?: number;
}
@@ -77,10 +76,7 @@ const Fab: React.FC<FabProps> = ({
return event === 'click' ? (isOpen ? close() : open()) : null;
};
- const actionOnClick = (
- e: React.FormEvent,
- userFunc: (e: React.FormEvent) => void
- ) => {
+ const actionOnClick = (e: React.FormEvent, userFunc: (e: React.FormEvent) => void) => {
e.persist();
setIsOpen(false);
setTimeout(() => {
@@ -141,9 +137,7 @@ const Fab: React.FC<FabProps> = ({
</MB>
{text && (
<span
- className={`${'right' in style ? 'right' : ''} ${
- alwaysShowTitle ? 'always-show' : ''
- }`}
+ className={`${'right' in style ? 'right' : ''} ${alwaysShowTitle ? 'always-show' : ''}`}
aria-hidden={ariaHidden}
>
{text}
diff --git a/src/components/shared/RotateIcon.tsx b/src/components/shared/RotateIcon.tsx
index d9dcbd9..d291ece 100644
--- a/src/components/shared/RotateIcon.tsx
+++ b/src/components/shared/RotateIcon.tsx
@@ -4,13 +4,12 @@ import { RotateCw } from 'react-feather';
import s from './RotateIcon.module.scss';
-export function RotateIcon({ isRotating }: { isRotating: boolean }) {
- const cls = cx(s.rotate, {
- [s.isRotating]: isRotating,
- });
+export function RotateIcon(props: { isRotating: boolean; size?: number }) {
+ const size = props.size || 16;
+ const cls = cx(s.rotate, { [s.isRotating]: props.isRotating });
return (
<span className={cls}>
- <RotateCw size={16} />
+ <RotateCw size={size} />
</span>
);
}
diff --git a/src/components/shared/TextFitler.tsx b/src/components/shared/TextFitler.tsx
index e4a4a88..7af61ac 100644
--- a/src/components/shared/TextFitler.tsx
+++ b/src/components/shared/TextFitler.tsx
@@ -4,10 +4,7 @@ import { useTextInut } from 'src/hooks/useTextInput';
import s from './TextFitler.module.scss';
-export function TextFilter(props: {
- textAtom: RecoilState<string>;
- placeholder?: string;
-}) {
+export function TextFilter(props: { textAtom: RecoilState<string>; placeholder?: string }) {
const [onChange, text] = useTextInut(props.textAtom);
return (
<input
diff --git a/src/components/svg/Equalizer.tsx b/src/components/svg/Equalizer.tsx
index 274720f..ae3c858 100644
--- a/src/components/svg/Equalizer.tsx
+++ b/src/components/svg/Equalizer.tsx
@@ -5,10 +5,7 @@ type Props = {
color?: string;
};
-export default function Equalizer({
- color = 'currentColor',
- size = 24,
-}: Props) {
+export default function Equalizer({ color = 'currentColor', size = 24 }: Props) {
return (
<svg
fill="none"