Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: apply more dark more flash fixes

Richie McIlroye2cb9e17c182
diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx
index 46b2563b8..d2c4976d8 100644
--- a/apps/desktop/src/App.tsx
+++ b/apps/desktop/src/App.tsx
@@ -10,6 +10,7 @@ import "unfonts.css";
import "./styles/theme.css";
import { commands } from "./utils/tauri";
import { themeStore } from "./store/theme";
+import "./store/early-theme-loader";
const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
const localStorageDarkMode = localStorage.getItem("darkMode");
diff --git a/apps/desktop/src/routes/(window-chrome)/settings/apps/index.tsx b/apps/desktop/src/routes/(window-chrome)/settings/apps/index.tsx
index 3f1ae7e43..fe4ef1e7d 100644
--- a/apps/desktop/src/routes/(window-chrome)/settings/apps/index.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/settings/apps/index.tsx
@@ -30,8 +30,8 @@ export default function AppsTab() {
<div class="p-4">
<For each={apps}>
{(app) => (
- <div class="p-1.5 bg-white rounded-lg border border-[--gray-500]">
- <div class="flex justify-between items-center border-b border-[--gray-500] pb-2">
+ <div class="p-1.5 bg-white rounded-lg border border-[--gray-200]">
+ <div class="flex justify-between items-center border-b border-[--gray-200] pb-2">
<div class="flex items-center gap-3">
<div class="p-2 rounded-lg bg-[--gray-100]">
<app.icon class="w-4 h-4 text-[--text-tertiary]" />
diff --git a/apps/desktop/src/routes/(window-chrome)/settings/hotkeys.tsx b/apps/desktop/src/routes/(window-chrome)/settings/hotkeys.tsx
index 9faf21059..77a57a21c 100644
--- a/apps/desktop/src/routes/(window-chrome)/settings/hotkeys.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/settings/hotkeys.tsx
@@ -107,7 +107,7 @@ function Inner(props: { initialStore: HotkeysStore | null }) {
<div class="w-[9rem] h-[2rem] ">
<Switch>
<Match when={listening()?.action === item()}>
- <div class="border border-[--gray-500] rounded-lg text-[--text-tertiary] w-full h-full bg-[--gray-100] flex flex-row items-center justify-between px-[0.375rem]">
+ <div class="border border-[--gray-300] rounded-lg text-[--text-tertiary] w-full h-full bg-[--gray-100] flex flex-row items-center justify-between px-[0.375rem]">
<Show when={hotkeys[item()]} fallback="Listening">
{(binding) => <HotkeyText binding={binding()} />}
</Show>
@@ -148,7 +148,7 @@ function Inner(props: { initialStore: HotkeysStore | null }) {
<Match when={listening()?.action !== item()}>
<button
type="button"
- class="border border-[--gray-500] rounded-lg text-[--text-tertiary] w-full h-full"
+ class="border border-[--gray-200] rounded-lg text-[--text-tertiary] w-full h-full"
onClick={(e) => {
e.stopPropagation();
setListening({
diff --git a/apps/desktop/src/routes/prev-recordings.tsx b/apps/desktop/src/routes/prev-recordings.tsx
index 66d5a9cc7..ea3191a88 100644
--- a/apps/desktop/src/routes/prev-recordings.tsx
+++ b/apps/desktop/src/routes/prev-recordings.tsx
@@ -43,6 +43,11 @@ type MediaEntry = {
};
export default function () {
+ onMount(() => {
+ document.documentElement.setAttribute("data-transparent-window", "true");
+ document.body.style.background = "transparent";
+ });
+
const [recordings, setRecordings] = makePersisted(
createStore<MediaEntry[]>([]),
{ name: "recordings-store" }
diff --git a/apps/desktop/src/store/early-theme-loader.ts b/apps/desktop/src/store/early-theme-loader.ts
new file mode 100644
index 000000000..5e470e168
--- /dev/null
+++ b/apps/desktop/src/store/early-theme-loader.ts
@@ -0,0 +1,26 @@
+const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
+const localStorageDarkMode = localStorage.getItem('darkMode');
+
+// Check if current window is one that should remain transparent
+const isTransparentWindow = window.location.pathname === '/prev-recordings' ||
+ window.location.pathname === '/window-capture-occluder';
+
+// Only apply dark background if not a transparent window
+if (!isTransparentWindow) {
+ // Check stored preference first, then system preference
+ if (localStorageDarkMode === 'true' || (localStorageDarkMode === null && darkModeMediaQuery.matches)) {
+ document.documentElement.classList.add('dark');
+ }
+
+ // Add base background color to prevent flash
+ const style = document.createElement('style');
+ style.textContent = `
+ html.dark:not([data-transparent-window]) {
+ background-color: #1E1E1E;
+ }
+ html.dark:not([data-transparent-window]) body {
+ background-color: #1E1E1E;
+ }
+ `;
+ document.head.appendChild(style);
+}
\ No newline at end of file
diff --git a/apps/desktop/src/styles/theme.css b/apps/desktop/src/styles/theme.css
index 5dfb6a5db..9d3633230 100644
--- a/apps/desktop/src/styles/theme.css
+++ b/apps/desktop/src/styles/theme.css
@@ -98,3 +98,17 @@
--shadow-s: 0px 8px 16px 0px rgba(0, 0, 0, 0.4);
}
+
+[data-transparent-window] {
+ background: transparent !important;
+}
+
+[data-transparent-window] body {
+ background: transparent !important;
+}
+
+/* Ensure transparent windows stay transparent in dark mode */
+.dark [data-transparent-window],
+.dark [data-transparent-window] body {
+ background: transparent !important;
+}
\ No newline at end of file