-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zephyruso
authored and
Zephyruso
committed
Sep 2, 2023
1 parent
5952425
commit 9ed0540
Showing
3 changed files
with
59 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
import { Show, createEffect, createMemo, createSignal } from 'solid-js' | ||
import { DELAY } from '~/config/enum' | ||
import { useProxies } from '~/signals/proxies' | ||
|
||
const Delay = (props: { delay: number | undefined }) => { | ||
const delay = props.delay | ||
const Delay = (props: { name?: string }) => { | ||
const { proxyNodeMap } = useProxies() | ||
const [textClassName, setTextClassName] = createSignal('') | ||
const delay = createMemo(() => { | ||
return proxyNodeMap()[props.name!]?.delay! | ||
}) | ||
|
||
if (typeof delay !== 'number' || delay === DELAY.NOT_CONNECTED) { | ||
return '' | ||
} | ||
createEffect(() => { | ||
setTextClassName('text-success') | ||
|
||
let textClassName = 'text-success' | ||
if (delay() > DELAY.HIGH) { | ||
setTextClassName('text-error') | ||
} else if (delay() > DELAY.MEDIUM) { | ||
setTextClassName('text-warning') | ||
} | ||
}) | ||
|
||
if (delay > DELAY.HIGH) { | ||
textClassName = 'text-error' | ||
} else if (delay > DELAY.MEDIUM) { | ||
textClassName = 'text-warning' | ||
} | ||
|
||
return <span class={textClassName}>{delay}ms</span> | ||
return ( | ||
<> | ||
<Show | ||
when={typeof delay() === 'number' && delay() !== DELAY.NOT_CONNECTED} | ||
> | ||
<span class={textClassName()}>{delay()}ms</span> | ||
</Show> | ||
</> | ||
) | ||
} | ||
|
||
export default Delay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters