Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(devex): add dark mode to the admin console (#130392)

Steven Shults4fe659aab5f1
diff --git a/frontend/bin/build-admin-console.mjs b/frontend/bin/build-admin-console.mjs
index ffec5d5c2d6a..12727f770c35 100644
--- a/frontend/bin/build-admin-console.mjs
+++ b/frontend/bin/build-admin-console.mjs
@@ -44,6 +44,11 @@ function inlineFonts(css) {
})
}
+function writeMonoIcon() {
+ const icon = fs.readFileSync(path.join(FRONTEND, 'public/posthog-icon.svg'), 'utf8')
+ fs.writeFileSync(path.join(OUT_DIR, 'posthog-icon-mono.svg'), icon.replace(/fill="[^"]+"/g, 'fill="#fff"'))
+}
+
function copyHoggies() {
const hoggieDir = path.join(OUT_DIR, 'hoggies')
fs.mkdirSync(hoggieDir, { recursive: true })
@@ -93,5 +98,6 @@ async function writeCrests() {
fs.mkdirSync(OUT_DIR, { recursive: true })
fs.rmSync(path.join(OUT_DIR, 'fonts'), { recursive: true, force: true })
await buildStylesheet()
+writeMonoIcon()
copyHoggies()
await writeCrests()
diff --git a/frontend/public/admin-console/console.css b/frontend/public/admin-console/console.css
index 1c10af1dde86..aa56a8f57da2 100644
--- a/frontend/public/admin-console/console.css
+++ b/frontend/public/admin-console/console.css
@@ -649,15 +649,15 @@
.max-w-xl {
max-width: var(--container-xl);
}
- .min-w-\(--anchor-width\) {
- min-width: var(--anchor-width);
- }
.min-w-0 {
min-width: calc(0.25rem * 0);
}
.min-w-\[240px\] {
min-width: 240px;
}
+ .min-w-\[max\(10rem\,var\(--anchor-width\)\)\] {
+ min-width: max(10rem, var(--anchor-width));
+ }
.flex-1 {
flex: 1;
}
@@ -1177,10 +1177,6 @@
--tw-ring-color: color-mix(in oklab, var(--foreground) 10%, transparent);
}
}
- .ring-offset-1 {
- --tw-ring-offset-width: 1px;
- --tw-ring-offset-shadow: var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
- }
.outline-hidden {
--tw-outline-style: none;
outline-style: none;
@@ -1470,24 +1466,6 @@
.data-disabled\:opacity-50[data-disabled] {
opacity: 50%;
}
- .data-highlighted\:border-ring[data-highlighted] {
- border-color: var(--ring);
- }
- .data-highlighted\:ring-2[data-highlighted] {
- --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width))
- var(--tw-ring-color, currentcolor);
- box-shadow:
- var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow),
- var(--tw-shadow);
- }
- .data-highlighted\:ring-ring\/30[data-highlighted] {
- --tw-ring-color: var(--ring);
- }
- @supports (color: color-mix(in lab, red, red)) {
- .data-highlighted\:ring-ring\/30[data-highlighted] {
- --tw-ring-color: color-mix(in oklab, var(--ring) 30%, transparent);
- }
- }
.data-open\:bg-fill-selected[data-open] {
background-color: var(--fill-selected);
}
@@ -1736,6 +1714,18 @@
.rtl\:rotate-180:where([dir='rtl'], [dir='rtl'], [dir='rtl'] *) {
rotate: 180deg;
}
+ .dark\:block:is(
+ :is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) *
+ ) {
+ display: block;
+ }
+ .dark\:hidden:is(
+ :is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) *
+ ) {
+ display: none;
+ }
.\[\&_kbd\]\:ml-auto kbd {
margin-left: auto;
}
@@ -1955,6 +1945,229 @@
--fill-hover: color-mix(in oklab, var(--foreground) 7%, transparent);
}
}
+:is([data-quill-inverted], [data-quill-inverted] *) {
+ --csstools-color-scheme--light: ;
+ color-scheme: dark;
+ --foreground: rgb(243, 244, 246);
+ --card-foreground: var(--foreground);
+ --muted-foreground: rgb(161, 161, 161);
+ --subtle-foreground: var(--muted-foreground);
+}
+@supports (color: color-mix(in lab, red, red)) {
+ :is([data-quill-inverted], [data-quill-inverted] *) {
+ --subtle-foreground: color-mix(in oklab, var(--muted-foreground) 80%, transparent);
+ }
+}
+:is([data-quill-inverted], [data-quill-inverted] *) {
+ --primary-foreground: rgb(3, 7, 18);
+ --destructive: rgb(43, 25, 30);
+ --destructive-foreground: rgb(237, 90, 90);
+ --success: rgb(20, 44, 31);
+ --success-foreground: rgb(185, 248, 207);
+ --warning: rgb(52, 41, 26);
+ --warning-foreground: rgb(202, 181, 58);
+ --info: rgba(25, 60, 184, 0.4);
+ --info-foreground: rgb(190, 219, 255);
+ --completed: rgb(46, 34, 61);
+ --completed-foreground: rgb(199, 184, 226);
+ --ring: rgb(161, 161, 161);
+ --background: oklch(0.187 calc(var(--theme-tint) * 1.1) var(--theme-dark-hue));
+ --card: oklch(0.2 calc(var(--theme-tint) * 1.2) var(--theme-dark-hue));
+ --muted: oklch(0.209 calc(var(--theme-tint) * 1.33) var(--theme-dark-hue));
+ --chrome: oklch(0.225 calc(var(--theme-tint) * 1.1) var(--theme-dark-hue));
+ --primary: var(--primary-dark);
+ --primary-on-foreground: var(--primary-light);
+ --border: oklch(0.27 calc(var(--theme-tint) * 1.2) var(--theme-dark-hue));
+ --input: oklch(0.3 calc(var(--theme-tint) * 1.5) var(--theme-dark-hue));
+ --fill-expanded: var(--foreground);
+}
+@supports (color: color(display-p3 0 0 0%)) {
+ :is([data-quill-inverted], [data-quill-inverted] *) {
+ --info-foreground: rgb(190, 219, 255);
+ }
+
+ @media (color-gamut: p3) {
+ :is([data-quill-inverted], [data-quill-inverted] *) {
+ --info-foreground: color(display-p3 0.76688 0.85521 0.98748);
+ }
+ }
+}
+@supports (color: color-mix(in lab, red, red)) {
+ :is([data-quill-inverted], [data-quill-inverted] *) {
+ --fill-expanded: color-mix(in oklab, var(--foreground) 14%, transparent);
+ }
+}
+:is([data-quill-inverted], [data-quill-inverted] *) {
+ --fill-selected: var(--foreground);
+}
+@supports (color: color-mix(in lab, red, red)) {
+ :is([data-quill-inverted], [data-quill-inverted] *) {
+ --fill-selected: color-mix(in oklab, var(--foreground) 10%, transparent);
+ }
+}
+:is([data-quill-inverted], [data-quill-inverted] *) {
+ --fill-hover: var(--foreground);
+}
+@supports (color: color-mix(in lab, red, red)) {
+ :is([data-quill-inverted], [data-quill-inverted] *) {
+ --fill-hover: color-mix(in oklab, var(--foreground) 7%, transparent);
+ }
+}
+:is([data-quill-inverted], [data-quill-inverted] *) {
+ --data-color-2: #7f26d9;
+ --data-color-3: #3e7a76;
+ --data-color-4: #bf0d6c;
+ --data-color-5: #f0474f;
+ --data-color-6: #b36114;
+ --data-color-10: #6576b3;
+}
+:is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+) {
+ --csstools-color-scheme--light: initial;
+ color-scheme: light;
+ --foreground: rgb(3, 7, 18);
+ --card-foreground: var(--foreground);
+ --muted-foreground: rgb(74, 85, 101);
+ --subtle-foreground: var(--muted-foreground);
+}
+@supports (color: color-mix(in lab, red, red)) {
+ :is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+ ) {
+ --subtle-foreground: color-mix(in oklab, var(--muted-foreground) 80%, transparent);
+ }
+}
+:is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+) {
+ --primary-foreground: rgb(255, 255, 255);
+ --destructive: rgb(248, 222, 216);
+ --destructive-foreground: rgb(190, 15, 39);
+ --success: rgb(205, 248, 217);
+ --success-foreground: rgb(1, 102, 48);
+ --warning: rgb(248, 229, 203);
+ --warning-foreground: rgb(135, 76, 0);
+ --info: rgb(190, 219, 255);
+ --info-foreground: rgb(66, 78, 93);
+ --completed: rgb(238, 226, 255);
+ --completed-foreground: rgb(92, 24, 215);
+ --ring: rgb(74, 85, 101);
+ --background: oklch(0.966 calc(var(--theme-tint) * 0.79) var(--theme-hue));
+ --card: oklch(0.995 calc(var(--theme-tint) * 0.3) var(--theme-hue));
+ --muted: oklch(0.953 calc(var(--theme-tint) * 1.28) var(--theme-hue));
+ --chrome: oklch(0.923 calc(var(--theme-tint) * 1.67) var(--theme-hue));
+ --primary: var(--primary-light);
+ --primary-on-foreground: var(--primary-dark);
+ --border: oklch(0.88 calc(var(--theme-tint) * 0.8) var(--theme-hue));
+ --input: oklch(0.81 calc(var(--theme-tint) * 0.5) var(--theme-hue));
+ --fill-expanded: var(--foreground);
+}
+@supports (color: color(display-p3 0 0 0%)) {
+ :is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+ ) {
+ --warning-foreground: rgb(135, 76, 0);
+ --info: rgb(190, 219, 255);
+ --completed: rgb(238, 226, 255);
+ }
+
+ @media (color-gamut: p3) {
+ :is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+ ) {
+ --warning-foreground: color(display-p3 0.50318 0.30478 0.07554);
+ --info: color(display-p3 0.76688 0.85521 0.98748);
+ --completed: color(display-p3 0.9251 0.88403 1);
+ }
+ }
+}
+@supports (color: color-mix(in lab, red, red)) {
+ :is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+ ) {
+ --fill-expanded: color-mix(in oklab, var(--foreground) 6%, transparent);
+ }
+}
+:is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+) {
+ --fill-selected: var(--foreground);
+}
+@supports (color: color-mix(in lab, red, red)) {
+ :is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+ ) {
+ --fill-selected: color-mix(in oklab, var(--foreground) 6%, transparent);
+ }
+}
+:is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+) {
+ --fill-hover: var(--foreground);
+}
+@supports (color: color-mix(in lab, red, red)) {
+ :is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+ ) {
+ --fill-hover: color-mix(in oklab, var(--foreground) 4%, transparent);
+ }
+}
+:is(
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted],
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']),
+ :is(.dark, [theme='dark'], [data-theme='dark']) [data-quill-inverted] *,
+ [data-quill-inverted]:is(.dark, [theme='dark'], [data-theme='dark']) *
+) {
+ --data-color-1: #1d4aff;
+ --data-color-2: #621da6;
+ --data-color-3: #42827e;
+ --data-color-4: #ce0e74;
+ --data-color-5: #f14f58;
+ --data-color-6: #7c440e;
+ --data-color-7: #529a0a;
+ --data-color-8: #0476fb;
+ --data-color-9: #fe729e;
+ --data-color-10: #35416b;
+ --data-color-11: #41cbc4;
+ --data-color-12: #b64b02;
+ --data-color-13: #e4a604;
+ --data-color-14: #a56eff;
+ --data-color-15: #30d5c8;
+ --color-graph-axis-label: var(--muted-foreground);
+ --color-graph-axis-line: var(--border);
+ --color-graph-crosshair: var(--muted-foreground);
+}
:root {
--radius-xs: calc(var(--radius) - 7px);
--radius-sm: calc(var(--radius) - 5px);
@@ -2523,6 +2736,17 @@ body.is-desktop .group\/field:has(> [role='checkbox']) .quill-label {
transform: none;
}
}
+ :is(.quill-button, .quill-select__item) {
+ --quill-row-ring-color: var(--ring);
+ }
+ @supports (color: color-mix(in lab, red, red)) {
+ :is(.quill-button, .quill-select__item) {
+ --quill-row-ring-color: color-mix(in oklab, var(--ring) 30%, transparent);
+ }
+ }
+ :is(.quill-button, .quill-select__item) {
+ --quill-row-ring: 0 0 0 1px var(--card), 0 0 0 3px var(--quill-row-ring-color);
+ }
.quill-button {
font-size: var(--text-ui, 0.8125rem);
cursor: pointer;
@@ -2618,15 +2842,8 @@ body.is-desktop .group\/field:has(> [role='checkbox']) .quill-label {
}
.quill-button--variant-default[data-highlighted] {
background-color: var(--fill-hover);
- }
- .quill-button--variant-default[data-highlighted]:not(:hover) {
border-color: var(--ring);
- box-shadow: 0 0 0 2px var(--ring);
- }
- @supports (color: color-mix(in lab, red, red)) {
- .quill-button--variant-default[data-highlighted]:not(:hover) {
- box-shadow: 0 0 0 2px color-mix(in oklab, var(--ring) 30%, transparent);
- }
+ box-shadow: var(--quill-row-ring);
}
.quill-button--variant-default:is([aria-selected='true'], [aria-checked='true']):has(
+ :is([aria-selected='true'], [aria-checked='true'])
@@ -2801,6 +3018,26 @@ body.is-desktop .group\/field:has(> [role='checkbox']) .quill-label {
:is(.quill-button--variant-destructive, .quill-button--variant-destructive-outline):focus-visible {
border-color: currentColor;
}
+ :is(.quill-button--variant-destructive, .quill-button--variant-destructive-outline)[data-highlighted] {
+ --quill-row-ring-color: var(--destructive-foreground);
+ }
+ @supports (color: color-mix(in lab, red, red)) {
+ :is(.quill-button--variant-destructive, .quill-button--variant-destructive-outline)[data-highlighted] {
+ --quill-row-ring-color: color-mix(in oklab, var(--destructive-foreground) 60%, transparent);
+ }
+ }
+ :is(.quill-button--variant-destructive, .quill-button--variant-destructive-outline)[data-highlighted] {
+ box-shadow: var(--quill-row-ring);
+ border-color: currentColor;
+ }
+ :is(
+ .quill-button--variant-default,
+ .quill-button--variant-destructive,
+ .quill-button--variant-destructive-outline
+ )[data-highlighted]:hover {
+ box-shadow: none;
+ border-color: #0000;
+ }
.quill-button--variant-link {
color: var(--primary);
text-underline-offset: 4px;
@@ -3642,10 +3879,10 @@ body.is-desktop .group\/field:has(> [role='checkbox']) .quill-label {
.quill-menu-label {
text-transform: uppercase;
letter-spacing: 0.075em;
- padding-block: 0.375rem;
+ padding-block: 0.25rem;
padding-inline: 0.5rem;
font-weight: 600;
- line-height: 1.25rem;
+ line-height: 1rem;
}
:is(.dark, [theme='dark']) .quill-menu-label {
color: var(--subtle-foreground, var(--muted-foreground));
@@ -5439,10 +5676,6 @@ body.is-desktop .group\/field:has(> [role='checkbox']) .quill-label {
pointer-events: none;
opacity: 0.5;
}
- .quill-combobox__content .quill-button--variant-default:is([data-highlighted], :focus-visible) {
- box-shadow: none;
- border-color: #0000;
- }
.quill-combobox__item:not([data-variant='destructive'])[data-highlighted]
:not([data-keep-color]):not([data-keep-color] *) {
color: var(--foreground);
@@ -5735,29 +5968,9 @@ body.is-desktop .group\/field:has(> [role='checkbox']) .quill-label {
border-color: color-mix(in oklab, var(--foreground) 40%, transparent);
}
}
- :is(
- [data-slot='dropdown-menu-checkbox-item'],
- [data-slot='dropdown-menu-radio-item'],
- [data-slot='context-menu-checkbox-item'],
- [data-slot='context-menu-radio-item']
- ):is([aria-checked='true'], [data-checked]):has(+ :is([aria-checked='true'], [data-checked])) {
- border-bottom-right-radius: 0;
- border-bottom-left-radius: 0;
- }
- :is([aria-checked='true'], [data-checked])
- + :is(
- [data-slot='dropdown-menu-checkbox-item'],
- [data-slot='dropdown-menu-radio-item'],
- [data-slot='context-menu-checkbox-item'],
- [data-slot='context-menu-radio-item']
- ):is([aria-checked='true'], [data-checked]) {
- border-top-left-radius: 0;
- border-top-right-radius: 0;
- }
:is(.quill-menu__content, .quill-menu__sub-content)
- .quill-button:is(.quill-button--variant-default, .quill-button--variant-destructive):is(
- [data-highlighted],
- :focus-visible
+ .quill-button:is(.quill-button--variant-default, .quill-button--variant-destructive):focus-visible:not(
+ [data-highlighted]
) {
box-shadow: none;
border-color: #0000;
@@ -7767,10 +7980,18 @@ body.is-desktop .group\/field:has(> [role='checkbox']) .quill-label {
color 0.1s;
position: relative;
}
- .quill-select__item:focus {
+ .quill-select__item:is(:focus, :hover) {
color: var(--foreground);
background-color: var(--fill-hover);
}
+ .quill-select__item[data-highlighted] {
+ box-shadow:
+ inset 0 0 0 1px var(--ring),
+ var(--quill-row-ring);
+ }
+ .quill-select__item[data-highlighted]:hover {
+ box-shadow: none;
+ }
.quill-select__item:not(:hover)[aria-selected='true'] {
background-color: var(--fill-selected);
}
@@ -8837,20 +9058,32 @@ body.is-desktop .group\/field:has(> [role='checkbox']) .quill-label {
--console-env: #a0ca21;
--console-env-ink: #4a5e0f;
--theme-hue: 125;
+ --theme-dark-hue: 125;
--theme-tint: 0.012;
}
[data-env='eu'] {
--console-env: #1490e8;
--console-env-ink: #0b4f80;
--theme-hue: 240;
+ --theme-dark-hue: 240;
--theme-tint: 0.012;
}
[data-env='us'] {
--console-env: #ff5c1c;
--console-env-ink: #a12d00;
--theme-hue: 40;
+ --theme-dark-hue: 40;
--theme-tint: 0.014;
}
+[data-env='dev'][theme='dark'] {
+ --console-env-ink: #c8e86a;
+}
+[data-env='eu'][theme='dark'] {
+ --console-env-ink: #7cc4f5;
+}
+[data-env='us'][theme='dark'] {
+ --console-env-ink: #ff9a70;
+}
@layer components {
.console-body {
font-family: RoundHog, var(--font-sans);
@@ -8864,7 +9097,7 @@ body.is-desktop .group\/field:has(> [role='checkbox']) .quill-label {
}
@supports (color: color-mix(in lab, red, red)) {
.console-env-pill {
- background: color-mix(in oklab, var(--console-env) 22%, white);
+ background: color-mix(in oklab, var(--console-env) 22%, var(--card));
}
}
.console-env-pill {
diff --git a/frontend/public/admin-console/console.js b/frontend/public/admin-console/console.js
index 4f5662f7fe86..a0bbf1ea309f 100644
--- a/frontend/public/admin-console/console.js
+++ b/frontend/public/admin-console/console.js
@@ -1,4 +1,4 @@
-// The only script the admin console loads. A POST form disables its submit buttons when it submits, so a
+// The only script file the admin console loads. A POST form disables its submit buttons when it submits, so a
// double click sends one request. The page reloads after every submit, which re-enables them.
document.addEventListener('submit', (event) => {
const form = event.target
diff --git a/frontend/public/admin-console/posthog-icon-mono.svg b/frontend/public/admin-console/posthog-icon-mono.svg
new file mode 100644
index 000000000000..2dddc485de57
--- /dev/null
+++ b/frontend/public/admin-console/posthog-icon-mono.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 28" aria-hidden="true" width="52"><g data-logo-part="blue"><path fill="#fff" d="M10.74 7.16 4.54.8A2.66 2.66 0 0 0 0 2.66V7.5l10.74 11.18z"/><path fill="#fff" d="M9.19 28h1.55v-9.32L0 7.5v10.73z"/><path fill="#fff" d="M0 25.41A2.6 2.6 0 0 0 2.58 28H9.2L0 18.23z"/></g><g data-logo-part="red"><path fill="#fff" d="M10.74 2.66v4.5l11.22 11.52V7.63L15.3.8a2.66 2.66 0 0 0-4.56 1.86"/><path fill="#fff" d="M10.74 28h8.96l-8.96-9.32z"/><path fill="#fff" d="M10.74 7.16v11.52L19.7 28h2.26v-9.32z"/></g><g data-logo-part="yellow"><path fill="#fff" d="M21.96 2.67v4.96l11.3 11.6h.02V7.75L26.63.85a2.8 2.8 0 0 0-2-.85 2.67 2.67 0 0 0-2.67 2.67"/><path fill="#fff" d="M21.96 7.63v11.05L31.03 28h2.25v-8.75z"/><path fill="#fff" d="M21.96 28h9.07l-9.07-9.32z"/></g><g data-logo-part="head"><path fill="#fff" d="M51.66 25.22A1.9 1.9 0 0 0 50 23.33l-.34-.04c-1-.13-1.94-.6-2.65-1.33L33.28 7.75V28H49a2.66 2.66 0 0 0 2.67-2.67zM39.2 23.54h-.09a1.78 1.78 0 1 1 .1 0"/></g><defs><linearGradient id="logo-jump-p0" x1="21.96" x2="33.28" y1="9.62" y2="9.62" gradientUnits="userSpaceOnUse"><stop stop-color="#ffd849"/><stop offset=".96" stop-color="#fbae01"/></linearGradient><linearGradient id="logo-jump-p1" x1="21.96" x2="33.28" y1="17.81" y2="17.81" gradientUnits="userSpaceOnUse"><stop stop-color="#ffb700"/><stop offset="1" stop-color="#f9aa01"/></linearGradient><linearGradient id="logo-jump-p2" x1="21.96" x2="31.03" y1="23.34" y2="23.34" gradientUnits="userSpaceOnUse"><stop stop-color="#ff9500"/><stop offset="1" stop-color="#f8aa00"/></linearGradient><linearGradient id="logo-jump-p3" x1="10.74" x2="21.96" y1="9.34" y2="9.34" gradientUnits="userSpaceOnUse"><stop stop-color="#ff651e"/><stop offset="1" stop-color="#e4400a"/></linearGradient><linearGradient id="logo-jump-p4" x1="10.74" x2="19.7" y1="23.34" y2="23.34" gradientUnits="userSpaceOnUse"><stop stop-color="#c42c00"/><stop offset="1" stop-color="#d63600"/></linearGradient><linearGradient id="logo-jump-p5" x1="10.74" x2="21.96" y1="17.58" y2="17.58" gradientUnits="userSpaceOnUse"><stop stop-color="#ef3c00"/><stop offset="1" stop-color="#d63601"/></linearGradient><linearGradient id="logo-jump-p6" x1="0" x2="10.74" y1="9.34" y2="9.34" gradientUnits="userSpaceOnUse"><stop stop-color="#3f80ff"/><stop offset="1" stop-color="#084fe0"/></linearGradient><linearGradient id="logo-jump-p7" x1="0" x2="10.74" y1="17.75" y2="17.75" gradientUnits="userSpaceOnUse"><stop stop-color="#0255ff"/><stop offset="1" stop-color="#0145d2"/></linearGradient><linearGradient id="logo-jump-p8" x1="0" x2="9.19" y1="23.11" y2="23.11" gradientUnits="userSpaceOnUse"><stop stop-color="#0041c6"/><stop offset="1" stop-color="#0045d0"/></linearGradient></defs></svg>
\ No newline at end of file
diff --git a/frontend/src/styles/admin-console.css b/frontend/src/styles/admin-console.css
index a46c16edbfed..4cc7d50b7d5e 100644
--- a/frontend/src/styles/admin-console.css
+++ b/frontend/src/styles/admin-console.css
@@ -46,6 +46,7 @@
--console-env: #a0ca21;
--console-env-ink: #4a5e0f;
--theme-hue: 125;
+ --theme-dark-hue: 125;
--theme-tint: 0.012;
}
@@ -53,6 +54,7 @@
--console-env: #1490e8;
--console-env-ink: #0b4f80;
--theme-hue: 240;
+ --theme-dark-hue: 240;
--theme-tint: 0.012;
}
@@ -60,9 +62,22 @@
--console-env: #ff5c1c;
--console-env-ink: #a12d00;
--theme-hue: 40;
+ --theme-dark-hue: 40;
--theme-tint: 0.014;
}
+[data-env='dev'][theme='dark'] {
+ --console-env-ink: #c8e86a;
+}
+
+[data-env='eu'][theme='dark'] {
+ --console-env-ink: #7cc4f5;
+}
+
+[data-env='us'][theme='dark'] {
+ --console-env-ink: #ff9a70;
+}
+
@layer components {
.console-body {
font-family: RoundHog, var(--font-sans);
@@ -74,7 +89,7 @@
.console-env-pill {
color: var(--console-env-ink);
- background: color-mix(in oklab, var(--console-env) 22%, white);
+ background: color-mix(in oklab, var(--console-env) 22%, var(--card));
border: 1px solid var(--console-env);
}
diff --git a/posthog/admin/console/AGENTS.md b/posthog/admin/console/AGENTS.md
index bcb032b0fced..ab8c7a25efcf 100644
--- a/posthog/admin/console/AGENTS.md
+++ b/posthog/admin/console/AGENTS.md
@@ -20,7 +20,7 @@ Before you add or change a panel, operation or tool, invoke `/extending-the-admi
1. In `products/<product>/backend/console.py`, subclass `Panel` and decorate it with `@console.register_panel`. Import only your product's `facade/`, `posthog.admin.console`, and, for a bridge, the `ModelAdmin` that still holds the view. `products/workflows/backend/console.py` is the reference.
2. Set `owner = Owner(name=..., crest=...)`. The crest is a mini crest slug from `@posthog/brand`, for example `workflows`.
3. For each action, return an `Operation`. Put its inputs in a Django `forms.Form` (`form_class`); the console renders and validates it. Its `handler(request, obj, form)` returns `None` when done. The handler is a service function, or `AdminViewBridge(Model, SomeAdmin.view_method)` while the logic still lives in a `ModelAdmin`. A bridged view must take a POST and answer with a redirect. Later, replace the bridge with a service function; the panel stays as it is.
-4. Run `pnpm --filter=@posthog/frontend build:admin-console` when you add an owner crest or change a template. `posthog/admin/test_admin_console.py` fails when a template class or an owner crest is missing from the build output.
+4. Run `pnpm --filter=@posthog/frontend build:admin-console` when you add an owner crest or change a template. `posthog/admin/test_admin_console.py` fails when a template class, a linked asset or an owner crest is missing from the build output.
## Add a tool
diff --git a/posthog/admin/test_admin_console.py b/posthog/admin/test_admin_console.py
index 4e7788ae9b94..2dda6fec628f 100644
--- a/posthog/admin/test_admin_console.py
+++ b/posthog/admin/test_admin_console.py
@@ -7,7 +7,9 @@ from posthog.test.base import BaseTest
from unittest.mock import MagicMock, patch
from django.conf import settings
-from django.test import Client, SimpleTestCase
+from django.http import HttpRequest, HttpResponse
+from django.template.loader import render_to_string
+from django.test import Client, RequestFactory, SimpleTestCase, override_settings
from django.utils.html import format_html
from parameterized import parameterized
@@ -15,8 +17,10 @@ from parameterized import parameterized
from posthog.admin.console.panels import MAX_FACTS_PER_PANEL, Fact, Operation, Owner, Panel, ReasonForm
from posthog.admin.console.registry import ConsoleRegistry, console
from posthog.admin.console.tools import Cell, ConsoleTool, Page, Row, Table
+from posthog.csp_middleware import CSPMiddleware
from posthog.llm.gateway_internal_client import AIGatewayInternalError, CreditResult
from posthog.models.events_retention_config import OrganizationEventsRetentionConfig
+from posthog.models.user import User
from products.workflows.backend.facade.api import get_email_sending_state
@@ -77,6 +81,19 @@ class TestAdminConsoleAssets(SimpleTestCase):
+ "; ".join(f"{name}: {sorted(classes)}" for name, classes in sorted(missing.items()))
)
+ def test_every_asset_the_templates_link_to_ships(self) -> None:
+ linked = {
+ name
+ for template in TEMPLATE_DIR.glob("*.html")
+ for name in re.findall(r"/static/admin-console/([^\"?{]+)[\"?]", template.read_text())
+ }
+ assert linked, "No linked assets found, so this test checks nothing."
+
+ missing = sorted(name for name in linked if not (CONSOLE_ASSETS / name).is_file())
+ assert not missing, (
+ f"These assets are linked from the console templates but missing. Rebuild with `{REBUILD}`: {missing}"
+ )
+
def test_every_owner_crest_ships(self) -> None:
owners = [panel.owner for panel in console.panels_for("team")] + [tool.owner for tool in console.tools()]
missing = sorted(
@@ -137,6 +154,43 @@ class TestAdminConsoleAssets(SimpleTestCase):
contribute()
+class TestAdminConsoleTheme(SimpleTestCase):
+ def _request(self, theme_mode: str | None) -> HttpRequest:
+ request = RequestFactory().get("/admin/console/")
+ request.user = User(email="[email protected]", theme_mode=theme_mode)
+ return request
+
+ @parameterized.expand(
+ [
+ ("no_saved_preference", None, "light"),
+ ("dark", "dark", "dark"),
+ ("system", "system", "system"),
+ ]
+ )
+ def test_the_console_uses_the_theme_saved_in_the_app(
+ self, _name: str, theme_mode: str | None, expected: str
+ ) -> None:
+ html_tag = re.search(
+ r"<html[^>]*>", render_to_string("admin_console/base.html", request=self._request(theme_mode))
+ )
+
+ assert html_tag is not None
+ assert re.search(rf'\stheme="{expected}"', html_tag.group(0))
+
+ @override_settings(ADMIN_PORTAL_ENABLED=True)
+ def test_the_admin_csp_allows_the_inline_theme_script(self) -> None:
+ response = CSPMiddleware(
+ lambda request: HttpResponse(render_to_string("admin_console/base.html", request=request))
+ )(self._request("system"))
+
+ script_src = next(d for d in response["Content-Security-Policy"].split("; ") if d.startswith("script-src "))
+ allowed = re.search(r"'nonce-([^']+)'", script_src)
+ assert allowed is not None
+ inline_scripts = re.findall(r"<script(?![^>]*\ssrc=)[^>]*>", response.content.decode())
+ assert inline_scripts
+ assert all(f'nonce="{allowed.group(1)}"' in tag for tag in inline_scripts), inline_scripts
+
+
class TestAdminConsoleViews(BaseTest):
def setUp(self) -> None:
super().setUp()
diff --git a/posthog/templates/admin_console/base.html b/posthog/templates/admin_console/base.html
index 34134f11a877..97399829c9b1 100644
--- a/posthog/templates/admin_console/base.html
+++ b/posthog/templates/admin_console/base.html
@@ -1,8 +1,19 @@
<!DOCTYPE html>
-<html lang="en" data-env="{{ console_env }}">
+<html lang="en"
+ data-env="{{ console_env }}"
+ theme="{% firstof request.user.theme_mode 'light' %}">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
+ {# Inline and before the stylesheet, so a system dark mode does not flash light on every page load. #}
+ <script nonce="{{ request.csp_nonce }}">
+ if (document.documentElement.getAttribute('theme') === 'system') {
+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)')
+ const applyTheme = () => document.documentElement.setAttribute('theme', prefersDark.matches ? 'dark' : 'light')
+ applyTheme()
+ prefersDark.addEventListener('change', applyTheme)
+ }
+ </script>
<title>{% block title %}PostHog Admin{% endblock %}</title>
{# Not the static tag: production hashes its URLs, and the CDN only serves unhashed names. #}
<link rel="stylesheet"
@@ -18,7 +29,11 @@
<header class="flex flex-wrap items-center gap-4 min-h-12 px-4 py-2 bg-chrome border-b border-border">
<a href="{% url 'admin_console_home' %}"
class="flex items-center gap-2 font-extrabold text-[15px] whitespace-nowrap text-foreground no-underline">
- <img src="/static/posthog-icon.svg" class="h-[18px]" alt="" />PostHog Admin
+ <img src="/static/posthog-icon.svg" class="h-[18px] dark:hidden" alt="" />
+ <img src="/static/admin-console/posthog-icon-mono.svg"
+ class="h-[18px] hidden dark:block"
+ alt="" />
+ PostHog Admin
</a>
<span class="console-env-pill inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-bold uppercase tracking-wide whitespace-nowrap">
<span class="console-env-dot size-[7px] rounded-full"></span>{{ console_env_label }}