summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatain <[email protected]>2022-06-17 10:48:45 +0800
committerMatain <[email protected]>2022-06-17 10:48:45 +0800
commit64c7b310be8420b06fe43e612ae2fe3ae5bc52a2 (patch)
treec5a94bd42b0191ef6cb70d867c5f4f3eb9e90c01 /src
parenta0fedebe3e03bda70b59881b0c49b87af6771a33 (diff)
Revert "Merge branch 'master' of https://github.com/haishanh/yacd into haishanh-master"
This reverts commit ea5d7cf003eeef30cb7bbe789c6ba7f314bf1ce4, reversing changes made to 4fd2c8f646e48dd0c07d0c2041de52e9a4f8bc82.
Diffstat (limited to 'src')
-rw-r--r--src/components/Root.scss2
-rw-r--r--src/components/proxies/Proxy.module.scss7
-rw-r--r--src/components/proxies/Proxy.tsx27
3 files changed, 33 insertions, 3 deletions
diff --git a/src/components/Root.scss b/src/components/Root.scss
index 8a7a57c..0a7fc4f 100644
--- a/src/components/Root.scss
+++ b/src/components/Root.scss
@@ -90,6 +90,7 @@ body {
--color-background: #202020;
--color-background2: rgba(32, 32, 32, 0.3);
--color-bg-card: #2d2d2d;
+ --card-hover-border-lightness: 30%;
--color-text: #ddd;
--color-text-secondary: #ccc;
--color-text-highlight: #fff;
@@ -118,6 +119,7 @@ body {
--color-background: #eee;
--color-background2: rgba(240, 240, 240, 0.3);
--color-bg-card: #fafafa;
+ --card-hover-border-lightness: 80%;
--color-text: #222;
--color-text-secondary: #646464;
--color-text-highlight: #040404;
diff --git a/src/components/proxies/Proxy.module.scss b/src/components/proxies/Proxy.module.scss
index 4507a07..c9a59cd 100644
--- a/src/components/proxies/Proxy.module.scss
+++ b/src/components/proxies/Proxy.module.scss
@@ -15,7 +15,7 @@
border: 1px solid var(--color-focus-blue);
}
- max-width: 280px;
+ max-width: 200px;
@media (--breakpoint-not-small) {
min-width: 200px;
border-radius: 10px;
@@ -34,7 +34,7 @@
transition: transform 0.2s ease-in-out;
cursor: pointer;
&:hover {
- transform: translateY(-2px);
+ border-color: hsl(0deg, 0%, var(--card-hover-border-lightness));
}
}
}
@@ -58,6 +58,9 @@
width: 100%;
margin-bottom: 5px;
font-size: 0.85em;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
@media (--breakpoint-not-small) {
font-size: 0.85em;
}
diff --git a/src/components/proxies/Proxy.tsx b/src/components/proxies/Proxy.tsx
index 424d320..745de34 100644
--- a/src/components/proxies/Proxy.tsx
+++ b/src/components/proxies/Proxy.tsx
@@ -1,6 +1,7 @@
import cx from 'clsx';
import * as React from 'react';
import { keyCodes } from 'src/misc/keycode';
+import { TooltipPopup, useTooltip } from '@reach/tooltip';
import { getDelay, getProxies, NonProxyTypes } from '../../store/proxies';
import { connect } from '../StateProvider';
@@ -114,7 +115,27 @@ function formatProxyType(t: string) {
if (t === 'Shadowsocks') return 'SS';
return t;
}
+const positionProxyNameTooltip = (triggerRect: { left: number; top: number }) => {
+ return {
+ left: triggerRect.left + window.scrollX - 5,
+ top: triggerRect.top + window.scrollY - 38,
+ };
+};
+function ProxyNameTooltip({ children, label, 'aria-label': ariaLabel }) {
+ const [trigger, tooltip] = useTooltip();
+ return (
+ <>
+ {React.cloneElement(children, trigger)}
+ <TooltipPopup
+ {...tooltip}
+ label={label}
+ aria-label={ariaLabel}
+ position={positionProxyNameTooltip}
+ />
+ </>
+ );
+}
function ProxyImpl({
now,
name,
@@ -151,7 +172,11 @@ function ProxyImpl({
onKeyDown={handleKeyDown}
role={isSelectable ? 'menuitem' : ''}
>
- <div className={s0.proxyName}>{name}</div>
+ <div className={s0.proxyName}>
+ <ProxyNameTooltip label={name} aria-label={'proxy name: ' + name}>
+ <span>{name}</span>
+ </ProxyNameTooltip>
+ </div>
<div className={s0.row}>
<span className={s0.proxyType} style={{ opacity: now ? 0.6 : 0.2 }}>
{formatProxyType(proxy.type)}