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
feat(standalone/setup): add icons
Elian Doran3151e8666518
diff --git a/apps/client-standalone/src/lightweight/browser_routes.ts b/apps/client-standalone/src/lightweight/browser_routes.tsindex 0a28f5f5d5..2f7426e6e3 100644--- a/apps/client-standalone/src/lightweight/browser_routes.ts+++ b/apps/client-standalone/src/lightweight/browser_routes.ts@@ -5,6 +5,7 @@import { BootstrapDefinition } from '@triliumnext/commons';import { entity_changes, getContext, getSharedBootstrapItems, getSql, routes, sql_init } from '@triliumnext/core';+import { getIconConfig } from '@triliumnext/core/src/services/bootstrap_utils';import packageJson from '../../package.json' with { type: 'json' };import { type BrowserRequest, BrowserRouter } from './browser_router';@@ -230,6 +231,7 @@ function bootstrapRoute(): BootstrapDefinition {assetPath,themeCssUrl: false,themeUseNextAsBase: "next",+ ...getIconConfig(assetPath)};}diff --git a/apps/client/src/setup.css b/apps/client/src/setup.cssindex 8dbb76e2d0..d3952d374e 100644--- a/apps/client/src/setup.css+++ b/apps/client/src/setup.css@@ -37,6 +37,9 @@ body.setup {.setup-option-card {padding: 1.5em;cursor: pointer;+ display: flex;+ align-items: center;+ gap: 1rem;&:hover {background-color: var(--card-background-hover-color);@@ -44,6 +47,11 @@ body.setup {transition: background-color .2s ease-out;}+ .tn-icon {+ font-size: 2.5em;+ color: var(--muted-text-color);+ }+h3 {font-size: 1.5em;font-weight: normal;diff --git a/apps/client/src/setup.tsx b/apps/client/src/setup.tsxindex 2a48f455cd..753766ce4c 100644--- a/apps/client/src/setup.tsx+++ b/apps/client/src/setup.tsx@@ -4,6 +4,7 @@ import { render } from "preact";import { initLocale, t } from "./services/i18n";import { CardFrame } from "./widgets/react/Card";+import Icon from "./widgets/react/Icon";async function main() {await initLocale();@@ -21,16 +22,19 @@ function App() {<div class="setup-options"><SetupOptionCard+ icon="bx bx-file-blank"title={t("setup.new-document")}description={t("setup.new-document-description")}/><SetupOptionCard+ icon="bx bx-server"title={t("setup.sync-from-server")}description={t("setup.sync-from-server-description")}/><SetupOptionCard+ icon="bx bx-desktop"title={t("setup.sync-from-desktop")}description={t("setup.sync-from-desktop-description")}/>@@ -39,11 +43,15 @@ function App() {);}-function SetupOptionCard({ title, description }: { title: string; description: string }) {+function SetupOptionCard({ title, description, icon }: { title: string; description: string, icon: string }) {return (<CardFrame className="setup-option-card">- <h3>{title}</h3>- <p>{description}</p>+ <Icon icon={icon} />++ <main>+ <h3>{title}</h3>+ <p>{description}</p>+ </main></CardFrame>);}diff --git a/packages/commons/src/lib/server_api.ts b/packages/commons/src/lib/server_api.tsindex edd6139738..e1d5c48a6f 100644--- a/packages/commons/src/lib/server_api.ts+++ b/packages/commons/src/lib/server_api.ts@@ -320,6 +320,8 @@ interface BootstrapCommonItems {assetPath: string;themeCssUrl: string | false;themeUseNextAsBase?: "next" | "next-light" | "next-dark";+ iconPackCss: string;+ iconRegistry: IconRegistry;}/**@@ -347,8 +349,6 @@ export type BootstrapDefinition = BootstrapCommonItems & ({appPath: string;currentLocale: Locale;isRtl: boolean;- iconPackCss: string;- iconRegistry: IconRegistry;TRILIUM_SAFE_MODE: boolean;} | {dbInitialized: false;diff --git a/packages/trilium-core/src/services/bootstrap_utils.ts b/packages/trilium-core/src/services/bootstrap_utils.tsindex 19fa1b81c1..fdd4bac43a 100644--- a/packages/trilium-core/src/services/bootstrap_utils.ts+++ b/packages/trilium-core/src/services/bootstrap_utils.ts@@ -7,7 +7,6 @@ import { getCurrentLocale } from "./i18n";export default function getSharedBootstrapItems(assetPath: string): Pick<BootstrapDefinition, "assetPath" | "headingStyle" | "layoutOrientation" | "maxEntityChangeIdAtLoad" | "maxEntityChangeSyncIdAtLoad" | "isProtectedSessionAvailable" | "iconRegistry" | "iconPackCss" | "currentLocale" | "isRtl"> {const sql = getSql();- const iconPacks = getIconPacks();const currentLocale = getCurrentLocale();return {@@ -19,6 +18,14 @@ export default function getSharedBootstrapItems(assetPath: string): Pick<BootstrisProtectedSessionAvailable: protected_session.isProtectedSessionAvailable(),currentLocale,isRtl: !!currentLocale.rtl,+ ...getIconConfig(assetPath)+ }+}++export function getIconConfig(assetPath: string): Pick<BootstrapDefinition, "iconRegistry" | "iconPackCss"> {+ const iconPacks = getIconPacks();++ return {iconRegistry: generateIconRegistry(iconPacks),iconPackCss: iconPacks.map(p => generateCss(p, p.builtin@@ -26,5 +33,5 @@ export default function getSharedBootstrapItems(assetPath: string): Pick<Bootstr: `api/attachments/download/${p.fontAttachmentId}`)).filter(Boolean).join("\n\n"),- }+ };}