Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/icon pack/preview: tweak appearance
Adorian Doran9d0f6784cb0c
diff --git a/apps/client/src/widgets/react/IsolatedFrame.tsx b/apps/client/src/widgets/react/IsolatedFrame.tsxindex 1e29c2cd78..c1705b87b3 100644--- a/apps/client/src/widgets/react/IsolatedFrame.tsx+++ b/apps/client/src/widgets/react/IsolatedFrame.tsx@@ -12,6 +12,8 @@ interface IsolatedFrameProps {css?: string;/** Host `:root` CSS custom properties to mirror into the frame, so its CSS can use `var(...)`. Re-synced on theme change. */cssVars?: string[];+ /** Class name applied to the frame's `<body>`, e.g. to toggle a mode the injected CSS keys off. */+ bodyClassName?: string;children?: ComponentChildren;}@@ -25,7 +27,7 @@ interface IsolatedFrameProps {* with {@link IsolatedFrameProps.cssVars}. Because the document has no base URL, any URLs referenced* from that CSS must be absolute.*/-export default function IsolatedFrame({ className, title, css, cssVars, children }: IsolatedFrameProps) {+export default function IsolatedFrame({ className, title, css, cssVars, bodyClassName, children }: IsolatedFrameProps) {const iframeRef = useRef<HTMLIFrameElement>(null);const [ body, setBody ] = useState<HTMLElement | null>(null);const colorScheme = useColorScheme();@@ -51,6 +53,10 @@ export default function IsolatedFrame({ className, title, css, cssVars, childrenstyle.textContent = `${buildRootVars(cssVars)}${css ?? ""}`;}, [ css, cssVars, colorScheme, body ]);+ useLayoutEffect(() => {+ if (body) body.className = bodyClassName ?? "";+ }, [ bodyClassName, body ]);+return (<><iframe ref={iframeRef} className={className} title={title} onLoad={captureBody} />diff --git a/apps/client/src/widgets/type_widgets/icon_pack/IconPackPreview.tsx b/apps/client/src/widgets/type_widgets/icon_pack/IconPackPreview.tsxindex 1c75543dd2..f6ef7e25ae 100644--- a/apps/client/src/widgets/type_widgets/icon_pack/IconPackPreview.tsx+++ b/apps/client/src/widgets/type_widgets/icon_pack/IconPackPreview.tsx@@ -20,7 +20,6 @@ const NON_INTERACTIVE_ICON_LIMIT = 250;/** Theme variables forwarded into the isolated preview frame so it matches the app's colours. */const PREVIEW_CSS_VARS = ["--main-text-color",- "--main-background-color","--hover-item-background-color","--hover-item-text-color","--accented-background-color"@@ -67,8 +66,8 @@ export function IconPackPreview({ note, content, interactive = true }: IconPackPconst visibleIcons = interactive ? parsed.icons : parsed.icons.slice(0, NON_INTERACTIVE_ICON_LIMIT);return (- <IsolatedFrame className="icon-pack-frame" title={t("icon_pack.preview_title")} css={css} cssVars={PREVIEW_CSS_VARS}>- <div className={interactive ? "ip-grid interactive" : "ip-grid"}>+ <IsolatedFrame className="icon-pack-frame" title={t("icon_pack.preview_title")} css={css} cssVars={PREVIEW_CSS_VARS} bodyClassName={interactive ? "interactive" : undefined}>+ <div className="ip-grid">{visibleIcons.map((icon) => (<div className="ip-cell" key={icon.id} title={interactive ? iconTooltip(prefix, icon) : undefined}><span className="ip-glyph">{icon.glyph}</span>diff --git a/apps/client/src/widgets/type_widgets/icon_pack/icon_pack_preview.css b/apps/client/src/widgets/type_widgets/icon_pack/icon_pack_preview.cssindex dd1e6deaa9..519bd377de 100644--- a/apps/client/src/widgets/type_widgets/icon_pack/icon_pack_preview.css+++ b/apps/client/src/widgets/type_widgets/icon_pack/icon_pack_preview.css@@ -12,23 +12,20 @@ body {margin: 0;height: 100%;user-select: none;+ /* Read-only previews (collection tiles) are clipped; interactive mode scrolls (see below). */overflow: hidden;}-html:has(.ip-grid.interactive),-body:has(.ip-grid.interactive) {- overflow: auto;-}--body {color: var(--main-text-color, #000);- background: var(--main-background-color, #fff);- padding: 8px;+ padding: 0;box-sizing: border-box;- /* Read-only previews (collection tiles) are clipped, not scrollable — see the interactive override below. */}+body.interactive {+ overflow: auto;+ padding: 20px;+}.ip-grid {--icon-size: 24px;@@ -40,9 +37,9 @@ body {justify-content: start;}-.ip-grid.ip-grid.interactive {- --icon-size-ratio: .75;+body.interactive .ip-grid {--icon-size: 48px;+ --icon-size-ratio: .75;}.ip-cell {@@ -59,7 +56,7 @@ body {}/* Hover highlight only in interactive mode (off for read-only content-renderer previews). */-.ip-grid.interactive .ip-cell:hover {+body.interactive .ip-cell:hover {background: var(--hover-item-background-color, rgba(127, 127, 127, 0.2));color: var(--hover-item-text-color);transform: scale(1.5);