Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

feat: dynamic color theme support for PWA

Smaug6739187898efa4df
diff --git a/frontend/app/composables/useAppColors.ts b/frontend/app/composables/useAppColors.ts
index bc227fbf..3b183bb0 100644
--- a/frontend/app/composables/useAppColors.ts
+++ b/frontend/app/composables/useAppColors.ts
@@ -12,6 +12,7 @@ function setAppColor(color: string | number) {
if (typeof color === 'number') {
color = getAppAccent(color);
}
+ setThemeColor(`--${color}`);
if (color === 'primary') color = 'accent';
document.documentElement.style.setProperty('--primary', `var(--${color})`);
document.documentElement.style.setProperty('--primary-dark', `var(--${color}-dark)`);
@@ -23,6 +24,17 @@ function setAppColor(color: string | number) {
document.body.style.colorScheme = colorMode.preference;
}
+function setThemeColor(cssVar: string) {
+ let meta = document.querySelector('meta[name="theme-color"]');
+ if (!meta) {
+ meta = document.createElement('meta');
+ meta.setAttribute('name', 'theme-color');
+ document.head.appendChild(meta);
+ }
+ const computedColor = getComputedStyle(document.documentElement).getPropertyValue(cssVar).trim();
+ meta.setAttribute('content', computedColor);
+}
+
export const useAppColors = () => {
return {
getAppAccent,