Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

dark mode color improvements (#95)

Myles Scolnicke7d1a9d54880
diff --git a/frontend/src/components/shortcuts/renderShortcut.tsx b/frontend/src/components/shortcuts/renderShortcut.tsx
index 7e2fbff11f..c366032737 100644
--- a/frontend/src/components/shortcuts/renderShortcut.tsx
+++ b/frontend/src/components/shortcuts/renderShortcut.tsx
@@ -2,6 +2,7 @@
import { HotkeyAction, HOTKEYS } from "@/core/hotkeys/hotkeys";
import { isPlatformMac } from "@/core/shortcuts/shortcuts";
import { Kbd } from "../ui/kbd";
+import { DropdownMenuShortcut } from "../ui/dropdown-menu";
export function renderShortcut(shortcut: HotkeyAction) {
const hotkey = HOTKEYS.getHotkey(shortcut);
@@ -22,11 +23,11 @@ export function renderMinimalShortcut(shortcut: HotkeyAction) {
const hotkey = HOTKEYS.getHotkey(shortcut);
return (
- <span className="text-xs flex gap-1 text-muted-foreground items-center font-mono">
+ <DropdownMenuShortcut className="flex gap-1 items-center font-mono">
{prettyPrintHotkey(hotkey.key).map((key) => (
<span key={key}>{capitalize(key)}</span>
))}
- </span>
+ </DropdownMenuShortcut>
);
}
diff --git a/frontend/src/components/ui/button.tsx b/frontend/src/components/ui/button.tsx
index e3ad4b9ef1..1171136c33 100644
--- a/frontend/src/components/ui/button.tsx
+++ b/frontend/src/components/ui/button.tsx
@@ -21,21 +21,21 @@ const buttonVariants = cva(
),
destructive: cn(
"border shadow-smSolid",
- "bg-[var(--red-9)] hover:bg-[var(--red-10)]",
- "text-[var(--red-1)]",
+ "bg-[var(--red-9)] hover:bg-[var(--red-10)] dark:bg-[var(--red-6)] dark:hover:bg-[var(--red-7)]",
+ "text-[var(--red-1)] dark:text-[var(--red-12)]",
"border-[var(--red-11)]",
activeCommon
),
success: cn(
"border shadow-smSolid",
- "bg-[var(--grass-9)] hover:bg-[var(--grass-10)]",
- "text-[var(--grass-1)]",
+ "bg-[var(--grass-9)] hover:bg-[var(--grass-10)] dark:bg-[var(--grass-6)] dark:hover:bg-[var(--grass-7)]",
+ "text-[var(--grass-1)] dark:text-[var(--grass-12)]",
"border-[var(--grass-11)]",
activeCommon
),
warn: cn(
"border shadow-smSolid",
- "bg-[var(--yellow-9)] hover:bg-[var(--yellow-10)]",
+ "bg-[var(--yellow-9)] hover:bg-[var(--yellow-10)] dark:bg-[var(--yellow-6)] dark:hover:bg-[var(--yellow-7)]",
"text-[var(--yellow-12)]",
"border-[var(--yellow-11)]",
activeCommon
diff --git a/frontend/src/components/ui/slider.tsx b/frontend/src/components/ui/slider.tsx
index 3eb565b52a..c333380ec3 100644
--- a/frontend/src/components/ui/slider.tsx
+++ b/frontend/src/components/ui/slider.tsx
@@ -27,14 +27,14 @@ const Slider = React.forwardRef<
)}
{...props}
>
- <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-slate-200">
- <SliderPrimitive.Range className="absolute h-full bg-blue-500 dark:bg-blue-800" />
+ <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-slate-200 dark:bg-accent/60">
+ <SliderPrimitive.Range className="absolute h-full bg-blue-500 dark:bg-primary" />
</SliderPrimitive.Track>
<TooltipProvider>
<TooltipRoot delayDuration={0} open={open}>
<TooltipTrigger asChild={true}>
<SliderPrimitive.Thumb
- className="block h-4 w-4 rounded-full shadow-xsSolid border border-blue-500 dark:bg-blue-800 bg-white hover:bg-blue-300 focus:bg-blue-300 transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50"
+ className="block h-4 w-4 rounded-full shadow-xsSolid border border-blue-500 dark:border-primary dark:bg-accent bg-white hover:bg-blue-300 focus:bg-blue-300 transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50"
onFocus={openActions.setTrue}
onBlur={openActions.setFalse}
onMouseEnter={openActions.setTrue}
diff --git a/frontend/src/css/codemirror.css b/frontend/src/css/codemirror.css
index 4bfabb867e..9c04311213 100644
--- a/frontend/src/css/codemirror.css
+++ b/frontend/src/css/codemirror.css
@@ -4,3 +4,7 @@
will often lose focus during find/replace or in another editor */
background-color: #d7d4f0 !important;
}
+
+.dark .cm-selectionBackground {
+ background-color: #4d4d4d !important;
+}
diff --git a/frontend/src/css/globals.css b/frontend/src/css/globals.css
index b77860cee9..4683a8dd43 100644
--- a/frontend/src/css/globals.css
+++ b/frontend/src/css/globals.css
@@ -96,11 +96,14 @@
--card-foreground: 155 5% 68.3%; /* sage-11 */
--border: 153 3.7% 24.2%; /* sage-6 */
--input: 154 3.3% 28.7%; /* sage-7 */
- --primary: 193 52.6% 14.1%; /* cyan-3 */
+ --primary: 192 59.8% 39%; /* cyan-8 */
--primary-foreground: 190 80% 84%; /* cyan-12 */
--secondary: 155 7% 93%; /* sage-12 */
- --secondary-foreground: 193 51.9% 11.9%; /* cyan-3 */
+ --secondary-foreground: 151 5.5% 15.2%; /* sage-3 */
+ --destructive: 0 100% 70%; /* red-10 */
+ --destructive-foreground: 210 40% 98%; /* red-1 */
--accent: 192 56.6% 26.5%; /* cyan-7 */
+ --accent-foreground: 190 80% 84%; /* cyan-12 */
}
}
diff --git a/frontend/src/editor/cell/cell-actions.tsx b/frontend/src/editor/cell/cell-actions.tsx
index cdb3adbca6..5cb038069e 100644
--- a/frontend/src/editor/cell/cell-actions.tsx
+++ b/frontend/src/editor/cell/cell-actions.tsx
@@ -255,7 +255,7 @@ export const CellActionsDropdown = ({
}}
className={cn(
action.variant === "danger" &&
- "aria-selected:bg-[var(--red-5)] aria-selected:text-destructive-[var(--red-11)]"
+ "aria-selected:bg-[var(--red-5)] aria-selected:text-[var(--red-12)]"
)}
>
<div className="flex items-center flex-1">
diff --git a/frontend/src/plugins/core/componentFactory.tsx b/frontend/src/plugins/core/componentFactory.tsx
index 92e4b8df51..09264580bf 100644
--- a/frontend/src/plugins/core/componentFactory.tsx
+++ b/frontend/src/plugins/core/componentFactory.tsx
@@ -31,6 +31,7 @@ import { renderError } from "./BadPlugin";
import { renderHTML } from "./RenderHTML";
import { invariant } from "../../utils/invariant";
import { Logger } from "../../utils/Logger";
+import { getTheme } from "@/theme/useTheme";
export interface PluginSlotHandle {
/**
@@ -52,6 +53,7 @@ interface PluginSlotProps<T> {
}
/* Handles synchronization of value on behalf of the component */
+// eslint-disable-next-line react/function-component-definition
function PluginSlotInternal<T>(
{ hostElement, plugin, children, getInitialValue }: PluginSlotProps<T>,
ref: React.Ref<PluginSlotHandle>
@@ -150,13 +152,18 @@ function PluginSlotInternal<T>(
}
// Render the plugin
- return plugin.render({
- setValue: setValueAndSendInput,
- value,
- data: parseResult.data,
- children: childNodes,
- host: hostElement,
- });
+ const theme = getTheme();
+ return (
+ <div className={`contents ${theme}`}>
+ {plugin.render({
+ setValue: setValueAndSendInput,
+ value,
+ data: parseResult.data,
+ children: childNodes,
+ host: hostElement,
+ })}
+ </div>
+ );
}
const PluginSlot: React.ForwardRefExoticComponent<
@@ -277,7 +284,6 @@ export function registerReactComponent<T>(plugin: IPlugin<T, unknown>): void {
private async copyStyles() {
const shadowRoot = this.shadowRoot;
invariant(shadowRoot, "Shadow root should exist");
-
// If we don't support adopted stylesheets, we need to copy the styles
if (!this.isAdoptedStyleSheetsSupported()) {
this.copyStylesFallback();
diff --git a/frontend/src/stories/button.stories.mdx b/frontend/src/stories/button.stories.mdx
index 769d6d171d..9e92b88473 100644
--- a/frontend/src/stories/button.stories.mdx
+++ b/frontend/src/stories/button.stories.mdx
@@ -12,7 +12,7 @@ import { Mail, Trash2Icon, Loader2 } from "lucide-react";
</Story>
<Story name="Success">
- <Button variant="sucess">Button</Button>
+ <Button variant="success">Button</Button>
</Story>
<Story name="Warn">
diff --git a/frontend/src/theme/useTheme.ts b/frontend/src/theme/useTheme.ts
index 2ccc1e31db..ef52beac34 100644
--- a/frontend/src/theme/useTheme.ts
+++ b/frontend/src/theme/useTheme.ts
@@ -1,4 +1,5 @@
/* Copyright 2023 Marimo. All rights reserved. */
+import { store } from "@/core/state/jotai";
import { useAtom } from "jotai";
import { atomWithStorage } from "jotai/utils";
@@ -23,3 +24,10 @@ export function useTheme() {
// Dark theme is not ready so return light theme.
return { theme: "light" as const, setTheme };
}
+
+export function getTheme(): Theme {
+ if (process.env.NODE_ENV === "development") {
+ return store.get(themeAtom);
+ }
+ return "light";
+}