refactor(webui): separate presentation views and expand component gallery (#6179)
* refactor(webui): organize shared components with an internal gallery * refactor(webui): decouple views and expand component gallery * fix(docker): include channel sources in WebUI build * refactor(webui): cover all channel interfaces in gallery * docs(webui): remove manual paragraph wrapping
This commit is contained in:
1 parent
db804ef94a
commit
30e43aec82
109 files changed
+7874
-3459
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { ExternalLink, Info, RotateCw } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import type { currentWebPreviewRestriction } from "@/lib/web-preview";
|
||||
|
||||
export function WebPreviewPanelView({ url, restriction, loopback, onRefresh, children }: {
|
||||
url: URL | null;
|
||||
restriction: ReturnType<typeof currentWebPreviewRestriction>;
|
||||
loopback: boolean;
|
||||
onRefresh: () => void;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const buttonClass = "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
|
||||
return (
|
||||
<section aria-label={t("webPreview.title")} data-testid="web-preview-panel" className="flex min-h-0 flex-1 flex-col">
|
||||
<div className="flex h-9 shrink-0 items-center gap-1 border-b border-border/40 px-2">
|
||||
<p className="min-w-0 flex-1 truncate px-1 text-xs text-muted-foreground" title={url?.href}>{url?.href}</p>
|
||||
<Popover>
|
||||
<PopoverTrigger asChild><button type="button" className={buttonClass} aria-label={t("previewTabs.websiteInfo")} title={t("previewTabs.websiteInfo")}><Info className="size-3.5" aria-hidden /></button></PopoverTrigger>
|
||||
<PopoverContent align="end" className="w-72 space-y-2 rounded-control p-3 text-xs leading-relaxed text-muted-foreground">
|
||||
<p>{t("webPreview.isolated")}</p>
|
||||
<p>{t("webPreview.blockedHint")}</p>
|
||||
{loopback ? <p>{t("webPreview.loopback")}</p> : null}
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
{!restriction ? <button type="button" className={buttonClass} onClick={onRefresh} title={t("webPreview.refresh")} aria-label={t("webPreview.refresh")}>
|
||||
<RotateCw className="h-4 w-4" aria-hidden />
|
||||
</button> : null}
|
||||
{url ? <a className={buttonClass} href={url.href} target="_blank" rel="noreferrer noopener" title={t("webPreview.external")} aria-label={t("webPreview.external")}>
|
||||
<ExternalLink className="h-4 w-4" aria-hidden />
|
||||
</a> : null}
|
||||
</div>
|
||||
{restriction ? <div role="status" className="flex min-h-0 flex-1 items-center justify-center overflow-auto p-6 text-center text-sm text-muted-foreground">
|
||||
{t(`webPreview.${restriction}`)}
|
||||
</div> : children}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user