Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
import { Component, Show, createUniqueId } from 'solid-js';
import { Portal } from 'solid-js/web';
import CircleHelp from 'lucide-solid/icons/circle-help';
import ExternalLink from 'lucide-solid/icons/external-link';
import X from 'lucide-solid/icons/x';
import { helpIconSizeClasses, type HelpIconProps } from './helpIconModel';
import { useHelpIconState } from './useHelpIconState';
export type { HelpIconProps } from './helpIconModel';
export const HelpIcon: Component<HelpIconProps> = (props) => {
const state = useHelpIconState(props);
const helpContent = state.helpContent();
const popoverId = `help-popover-${createUniqueId()}`;
const titleId = `${popoverId}-title`;
// Don't render if no content available
if (!helpContent) {
return null;
}
return (
<>
<button
ref={state.setButtonRef}
type="button"
class={`inline-flex min-h-11 min-w-11 max-w-full items-center justify-center gap-1.5 transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-8 sm:min-w-8 ${props.triggerLabel ? 'rounded-sm px-2 py-1 text-xs font-medium text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300' : 'rounded-full p-1 text-slate-400 hover:text-blue-500 dark:hover:text-blue-400'} ${props.class ?? ''}`}
onClick={state.toggleOpen}
aria-label={props.triggerLabel ?? `Help: ${helpContent.title}`}
aria-expanded={state.isOpen()}
aria-haspopup="dialog"
aria-controls={state.isOpen() ? popoverId : undefined}
>
<CircleHelp class={`${helpIconSizeClasses[state.size()]} shrink-0`} strokeWidth={2} />
<Show when={props.triggerLabel}>
<span class="min-w-0 text-left whitespace-normal wrap-anywhere">
{props.triggerLabel}
</span>
</Show>
</button>
<Show when={state.isOpen()}>
<Portal mount={document.body}>
<div
ref={state.setPopoverRef}
id={popoverId}
role="dialog"
aria-labelledby={titleId}
class="fixed z-9999 flex max-h-[calc(100dvh-16px)] flex-col bg-surface rounded-md shadow-xs border border-border overflow-hidden animate-in fade-in-0 zoom-in-95 duration-150 min-w-[200px]"
style={{
top: `${state.popoverPosition().top}px`,
left: `${state.popoverPosition().left}px`,
'max-width': `min(${state.maxWidth()}px, calc(100vw - 16px))`,
}}
>
{/* Header */}
<div class="shrink-0 px-3 py-2 bg-surface-alt border-b border-border flex items-center justify-between gap-2">
<span id={titleId} class="text-sm font-medium text-base-content">
{helpContent.title}
</span>
<button
ref={state.setCloseButtonRef}
type="button"
class="inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm text-slate-400 transition-colors hover:text-muted sm:min-h-8 sm:min-w-8"
onClick={state.closeAndRestoreFocus}
aria-label="Close help"
>
<X class="w-3.5 h-3.5" strokeWidth={2} />
</button>
</div>
{/* Content */}
<div class="min-h-0 overflow-y-auto px-3 py-2.5 text-xs text-muted space-y-2">
<p class="whitespace-pre-line leading-relaxed">{helpContent.description}</p>
<Show when={helpContent.examples && helpContent.examples.length > 0}>
<div class="pt-2 border-t border-border-subtle">
<p class="text-[10px] uppercase tracking-wide text-muted font-medium mb-1.5">
Examples
</p>
<ul class="space-y-1 text-[11px]">
{helpContent.examples!.map((example) => (
<li class="flex items-start gap-1.5">
<span class="text-muted mt-0.5 select-none" aria-hidden="true">
-
</span>
<span class="text-muted">{example}</span>
</li>
))}
</ul>
</div>
</Show>
<Show when={helpContent.docUrl}>
<div class="pt-2 border-t border-border-subtle">
<a
href={helpContent.docUrl}
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center gap-1 text-[11px] font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline"
>
Learn more
<ExternalLink class="w-3 h-3" strokeWidth={2} />
</a>
</div>
</Show>
</div>
</div>
</Portal>
</Show>
</>
);
};
export default HelpIcon;