Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

fix(theme): prevent flash of wrong theme on load (#565)

Corentin Thomassete4295e14abf3
diff --git a/.changeset/six-moments-bow.md b/.changeset/six-moments-bow.md
new file mode 100644
index 00000000..8674ddf5
--- /dev/null
+++ b/.changeset/six-moments-bow.md
@@ -0,0 +1,5 @@
+---
+"@papra/docker": patch
+---
+
+Prevent small flash of wrong theme on initial load for slower connections
diff --git a/apps/papra-client/index.html b/apps/papra-client/index.html
index e3625ee5..8c1b1755 100644
--- a/apps/papra-client/index.html
+++ b/apps/papra-client/index.html
@@ -65,8 +65,19 @@
</script>
<style>.sr-only {position: absolute;width: 1px;height: 1px;padding: 0;margin: -1px;overflow: hidden;clip: rect(0, 0, 0, 0);white-space: nowrap;border-width: 0;}</style>
+
+ <!-- Prevent flash of wrong theme on load -->
+ <script>
+ (function () {
+ const stored = localStorage?.getItem('papra_color_mode') ?? 'dark';
+
+ if (stored === 'dark') {
+ document.documentElement.setAttribute('data-kb-theme', 'dark');
+ }
+ })();
+ </script>
</head>
- <body>
+ <body class="bg-background text-foreground">
<h1 class="sr-only">Papra - Document archiving and sharing platform</h1>
<p class="sr-only">Papra, the document archiving and sharing platform.</p>
diff --git a/apps/papra-client/src/index.tsx b/apps/papra-client/src/index.tsx
index 7cf3617a..b742bf9b 100644
--- a/apps/papra-client/src/index.tsx
+++ b/apps/papra-client/src/index.tsx
@@ -1,7 +1,7 @@
/* @refresh reload */
import type { ConfigColorMode } from '@kobalte/core/color-mode';
-import { ColorModeProvider, ColorModeScript, createLocalStorageManager } from '@kobalte/core/color-mode';
+import { ColorModeProvider, createLocalStorageManager } from '@kobalte/core/color-mode';
import { Router } from '@solidjs/router';
import { QueryClientProvider } from '@tanstack/solid-query';
@@ -37,7 +37,6 @@ render(
<IdentifyUser />
<I18nProvider>
<ConfirmModalProvider>
- <ColorModeScript storageType={localStorageManager.type} storageKey={colorModeStorageKey} initialColorMode={initialColorMode} />
<ColorModeProvider
initialColorMode={initialColorMode}
storageManager={localStorageManager}