feat(proxies): mount tooltip portal within rootElement

This commit is contained in:
kunish 2024-10-13 01:59:03 +08:00
parent 9621001b42
commit 554b361184
No known key found for this signature in database
GPG Key ID: 67D3ACD788F3A7CD
4 changed files with 9 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import {
favNightTheme, favNightTheme,
setCurTheme, setCurTheme,
setLatestConnectionMsg, setLatestConnectionMsg,
setRootElement,
useTwemoji, useTwemoji,
useWsRequest, useWsRequest,
} from '~/signals' } from '~/signals'
@ -33,6 +34,7 @@ export const App: ParentComponent = ({ children }) => {
return ( return (
<div <div
ref={(el) => setRootElement(el)}
class={twMerge( class={twMerge(
'relative flex h-screen flex-col overscroll-y-none subpixel-antialiased', 'relative flex h-screen flex-col overscroll-y-none subpixel-antialiased',
useTwemoji() ? 'font-twemoji' : 'font-no-twemoji', useTwemoji() ? 'font-twemoji' : 'font-no-twemoji',

View File

@ -8,7 +8,7 @@ import {
formatProxyType, formatProxyType,
getLatencyClassName, getLatencyClassName,
} from '~/helpers' } from '~/helpers'
import { curTheme, useProxies } from '~/signals' import { rootElement, useProxies } from '~/signals'
export const ProxyNodeCard = (props: { export const ProxyNodeCard = (props: {
proxyName: string proxyName: string
@ -79,8 +79,8 @@ export const ProxyNodeCard = (props: {
</div> </div>
</Tooltip.Trigger> </Tooltip.Trigger>
<Tooltip.Portal> <Tooltip.Portal mount={rootElement()}>
<Tooltip.Content data-theme={curTheme()} class="z-50 bg-transparent"> <Tooltip.Content class="z-50">
<Tooltip.Arrow class="text-neutral" /> <Tooltip.Arrow class="text-neutral" />
<div class="flex flex-col items-center gap-2 rounded-box bg-neutral p-2.5 text-neutral-content"> <div class="flex flex-col items-center gap-2 rounded-box bg-neutral p-2.5 text-neutral-content">

3
src/signals/global.ts Normal file
View File

@ -0,0 +1,3 @@
export const [rootElement, setRootElement] = createSignal(
document.createElement('div'),
)

View File

@ -1,5 +1,6 @@
export * from './config' export * from './config'
export * from './connections' export * from './connections'
export * from './global'
export * from './logs' export * from './logs'
export * from './proxies' export * from './proxies'
export * from './request' export * from './request'