: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(messaging): compile the preference page styles instead of loading a CDN (#99737)
Tom Piccirellofbbcc0a98061
diff --git a/.stylelintignore b/.stylelintignoreindex 66d985590b05..a2e749ef6651 100644--- a/.stylelintignore+++ b/.stylelintignore@@ -4,4 +4,6 @@ common/mosaic/storybookservices/mcp/src/ui-apps/styles/tailwind.cssnode_modules/**frontend/node_modules/**-products/**/node_modules/**\ No newline at end of file+products/**/node_modules/**+# Generated by `pnpm --filter=@posthog/frontend build:message-preferences`+frontend/public/message-preferences.cssdiff --git a/frontend/bin/build-message-preferences.mjs b/frontend/bin/build-message-preferences.mjsnew file mode 100644index 000000000000..4cc72df8b879--- /dev/null+++ b/frontend/bin/build-message-preferences.mjs@@ -0,0 +1,33 @@+// Build frontend/public/message-preferences.css, the stylesheet the messaging preference pages load.+//+// This runs the same PostCSS plugins as the app's CSS build in common/esbuilder/utils.mjs, so the+// pages get the app's production browser targets, and every plugin comes from the workspace lockfile.+//+// Usage:+// node bin/build-message-preferences.mjs++import tailwindcss from '@tailwindcss/postcss'+import autoprefixer from 'autoprefixer'+import fs from 'fs'+import path from 'path'+import postcss from 'postcss'+import postcssPresetEnv from 'postcss-preset-env'+import { fileURLToPath } from 'url'++const __dirname = path.dirname(fileURLToPath(import.meta.url))+const FRONTEND = path.resolve(__dirname, '..')+const SOURCE = path.join(FRONTEND, 'src/styles/message-preferences.css')+const OUT_FILE = path.join(FRONTEND, 'public/message-preferences.css')++// Browserslist otherwise follows NODE_ENV, and a shell with NODE_ENV=development would build for the+// development targets, which keep oklch() colors that older production browsers cannot read.+process.env.BROWSERSLIST_ENV = 'production'++const result = await postcss([tailwindcss, autoprefixer, postcssPresetEnv({ stage: 0 })]).process(+ fs.readFileSync(SOURCE, 'utf8'),+ { from: SOURCE }+)+for (const warning of result.warnings()) {+ console.warn(warning.toString())+}+fs.writeFileSync(OUT_FILE, result.css)diff --git a/frontend/package.json b/frontend/package.jsonindex 298243ab5216..fe3eff6045f9 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -24,6 +24,7 @@"build:products": "DEBUG=0 node build-products.mjs","build:app-urls": "node bin/build-app-url-manifest.mjs","build:app-urls:check": "node bin/build-app-url-manifest.mjs --check",+ "build:message-preferences": "node bin/build-message-preferences.mjs && oxfmt public/message-preferences.css","start": "pnpm start-http","start-http": "pnpm clean && pnpm copy-scripts && pnpm build:esbuild --dev","start-docker": "pnpm start-http --host 0.0.0.0",diff --git a/frontend/public/message-preferences.css b/frontend/public/message-preferences.cssnew file mode 100644index 000000000000..31eab948de61--- /dev/null+++ b/frontend/public/message-preferences.css@@ -0,0 +1,806 @@+/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */+@layer properties;+@layer theme, base, components, utilities;+@layer theme {+ :root,+ :host {+ --font-sans:+ ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',+ 'Noto Color Emoji';+ --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;+ --color-red-500: rgb(251, 44, 54);+ --color-amber-600: rgb(218, 119, 0);+ --color-green-500: rgb(0, 198, 90);+ --color-green-700: rgb(0, 129, 58);+ --color-blue-500: rgb(50, 128, 255);+ --color-blue-600: rgb(21, 93, 252);+ --color-gray-50: rgb(249, 250, 251);+ --color-gray-200: rgb(229, 231, 235);+ --color-gray-300: rgb(209, 213, 220);+ --color-gray-500: rgb(106, 114, 130);+ --color-gray-600: rgb(74, 85, 101);+ --color-gray-900: rgb(16, 24, 40);+ --color-white: #fff;+ --spacing: 0.25rem;+ --container-md: 28rem;+ --container-2xl: 42rem;+ --text-xs: 0.75rem;+ --text-xs--line-height: calc(1 / 0.75);+ --text-sm: 0.875rem;+ --text-sm--line-height: calc(1.25 / 0.875);+ --text-base: 1rem;+ --text-base--line-height: calc(1.5 / 1);+ --text-lg: 1.125rem;+ --text-lg--line-height: calc(1.75 / 1.125);+ --text-2xl: 1.5rem;+ --text-2xl--line-height: calc(2 / 1.5);+ --text-3xl: 1.875rem;+ --text-3xl--line-height: calc(2.25 / 1.875);+ --font-weight-medium: 500;+ --font-weight-semibold: 600;+ --font-weight-bold: 700;+ --font-weight-extrabold: 800;+ --radius-lg: 0.5rem;+ --radius-xl: 0.75rem;+ --ease-out: cubic-bezier(0, 0, 0.2, 1);+ --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);+ --default-transition-duration: 150ms;+ --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);+ --default-font-family: var(--font-sans);+ --default-mono-font-family: var(--font-mono);+ }++ @supports (color: color(display-p3 0 0 0%)) {+ :root,+ :host {+ --color-amber-600: rgb(218, 119, 0);+ --color-green-500: rgb(0, 198, 90);+ --color-green-700: rgb(0, 129, 58);+ --color-blue-500: rgb(50, 128, 255);+ }++ @media (color-gamut: p3) {+ :root,+ :host {+ --color-amber-600: color(display-p3 0.82714 0.46717 0.0336);+ --color-green-500: color(display-p3 0.30873 0.77475 0.37431);+ --color-green-700: color(display-p3 0.19836 0.5018 0.24533);+ --color-blue-500: color(display-p3 0.26642 0.49122 0.98862);+ }+ }+ }+}+@layer base {+ *,+ ::after,+ ::before,+ ::backdrop,+ ::file-selector-button {+ box-sizing: border-box;+ margin: 0;+ padding: 0;+ border: 0 solid;+ }+ html,+ :host {+ line-height: 1.5;+ -webkit-text-size-adjust: 100%;+ -moz-tab-size: 4;+ tab-size: 4;+ font-family: var(+ --default-font-family,+ ui-sans-serif,+ system-ui,+ sans-serif,+ 'Apple Color Emoji',+ 'Segoe UI Emoji',+ 'Segoe UI Symbol',+ 'Noto Color Emoji'+ );+ font-feature-settings: var(--default-font-feature-settings, normal);+ font-variation-settings: var(--default-font-variation-settings, normal);+ -webkit-tap-highlight-color: transparent;+ }+ hr {+ height: 0;+ color: inherit;+ border-top-width: 1px;+ }+ abbr:where([title]) {+ -webkit-text-decoration: underline dotted;+ text-decoration: underline;+ text-decoration: underline dotted;+ }+ h1,+ h2,+ h3,+ h4,+ h5,+ h6 {+ font-size: inherit;+ font-weight: inherit;+ }+ a {+ color: inherit;+ -webkit-text-decoration: inherit;+ text-decoration: inherit;+ }+ b,+ strong {+ font-weight: bolder;+ }+ code,+ kbd,+ samp,+ pre {+ font-family: var(+ --default-mono-font-family,+ ui-monospace,+ SFMono-Regular,+ Menlo,+ Monaco,+ Consolas,+ 'Liberation Mono',+ 'Courier New',+ monospace+ );+ font-feature-settings: var(--default-mono-font-feature-settings, normal);+ font-variation-settings: var(--default-mono-font-variation-settings, normal);+ font-size: 1em;+ }+ small {+ font-size: 80%;+ }+ sub,+ sup {+ font-size: 75%;+ line-height: 0;+ position: relative;+ vertical-align: baseline;+ }+ sub {+ bottom: -0.25em;+ }+ sup {+ top: -0.5em;+ }+ table {+ text-indent: 0;+ border-color: inherit;+ border-collapse: collapse;+ }+ :-moz-focusring {+ outline: auto;+ }+ progress {+ vertical-align: baseline;+ }+ summary {+ display: list-item;+ }+ ol,+ ul,+ menu {+ list-style: none;+ }+ img,+ svg,+ video,+ canvas,+ audio,+ iframe,+ embed,+ object {+ display: block;+ vertical-align: middle;+ }+ img,+ video {+ max-width: 100%;+ height: auto;+ }+ button,+ input,+ select,+ optgroup,+ textarea,+ ::file-selector-button {+ font: inherit;+ font-feature-settings: inherit;+ font-variation-settings: inherit;+ letter-spacing: inherit;+ color: inherit;+ border-radius: 0;+ background-color: transparent;+ opacity: 1;+ }+ :where(select:is([multiple], [size])) optgroup {+ font-weight: bolder;+ }+ :where(select:is([multiple], [size])) optgroup option {+ padding-inline-start: 20px;+ }+ ::file-selector-button {+ margin-inline-end: 4px;+ }+ ::-moz-placeholder {+ opacity: 1;+ }+ ::placeholder {+ opacity: 1;+ }+ @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {+ ::-moz-placeholder {+ color: currentcolor;+ }+ ::placeholder {+ color: currentcolor;+ }+ @supports (color: color-mix(in lab, red, red)) {+ ::-moz-placeholder {+ color: color-mix(in oklab, currentcolor 50%, transparent);+ }+ ::placeholder {+ color: color-mix(in oklab, currentcolor 50%, transparent);+ }+ }+ }+ textarea {+ resize: vertical;+ }+ ::-webkit-search-decoration {+ -webkit-appearance: none;+ }+ ::-webkit-date-and-time-value {+ min-height: 1lh;+ text-align: inherit;+ }+ ::-webkit-datetime-edit {+ display: inline-flex;+ }+ ::-webkit-datetime-edit-fields-wrapper {+ padding: 0;+ }+ ::-webkit-datetime-edit,+ ::-webkit-datetime-edit-year-field,+ ::-webkit-datetime-edit-month-field,+ ::-webkit-datetime-edit-day-field,+ ::-webkit-datetime-edit-hour-field,+ ::-webkit-datetime-edit-minute-field,+ ::-webkit-datetime-edit-second-field,+ ::-webkit-datetime-edit-millisecond-field,+ ::-webkit-datetime-edit-meridiem-field {+ padding-block: 0;+ }+ ::-webkit-calendar-picker-indicator {+ line-height: 1;+ }+ :-moz-ui-invalid {+ box-shadow: none;+ }+ button,+ input:where([type='button'], [type='reset'], [type='submit']),+ ::file-selector-button {+ -webkit-appearance: button;+ -moz-appearance: button;+ appearance: button;+ }+ ::-webkit-inner-spin-button,+ ::-webkit-outer-spin-button {+ height: auto;+ }+ [hidden]:where(:not([hidden='until-found'])) {+ display: none !important;+ }+}+@layer utilities {+ .invisible {+ visibility: hidden;+ }+ .absolute {+ position: absolute;+ }+ .fixed {+ position: fixed;+ }+ .relative {+ position: relative;+ }+ .static {+ position: static;+ }+ .top-4 {+ top: calc(var(--spacing) * 4);+ }+ .right-4 {+ right: calc(var(--spacing) * 4);+ }+ .mx-auto {+ margin-inline: auto;+ }+ .mt-1 {+ margin-top: calc(var(--spacing) * 1);+ }+ .mt-2 {+ margin-top: calc(var(--spacing) * 2);+ }+ .mt-6 {+ margin-top: calc(var(--spacing) * 6);+ }+ .mt-8 {+ margin-top: calc(var(--spacing) * 8);+ }+ .mb-2 {+ margin-bottom: calc(var(--spacing) * 2);+ }+ .mb-8 {+ margin-bottom: calc(var(--spacing) * 8);+ }+ .mb-12 {+ margin-bottom: calc(var(--spacing) * 12);+ }+ .block {+ display: block;+ }+ .flex {+ display: flex;+ }+ .hidden {+ display: none;+ }+ .inline {+ display: inline;+ }+ .inline-block {+ display: inline-block;+ }+ .h-6 {+ height: calc(var(--spacing) * 6);+ }+ .min-h-screen {+ min-height: 100vh;+ }+ .w-6 {+ width: calc(var(--spacing) * 6);+ }+ .w-12 {+ width: calc(var(--spacing) * 12);+ }+ .w-40 {+ width: calc(var(--spacing) * 40);+ }+ .w-full {+ width: 100%;+ }+ .max-w-2xl {+ max-width: var(--container-2xl);+ }+ .max-w-md {+ max-width: var(--container-md);+ }+ .min-w-0 {+ min-width: calc(var(--spacing) * 0);+ }+ .flex-1 {+ flex: 1;+ }+ .flex-shrink-0 {+ flex-shrink: 0;+ }+ .transform {+ transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);+ }+ .cursor-pointer {+ cursor: pointer;+ }+ .appearance-none {+ -webkit-appearance: none;+ -moz-appearance: none;+ appearance: none;+ }+ .flex-col {+ flex-direction: column;+ }+ .items-center {+ align-items: center;+ }+ .items-end {+ align-items: flex-end;+ }+ .items-start {+ align-items: flex-start;+ }+ .justify-between {+ justify-content: space-between;+ }+ .justify-center {+ justify-content: center;+ }+ .gap-4 {+ gap: calc(var(--spacing) * 4);+ }+ :where(.space-y-6 > :not(:last-child)) {+ --tw-space-y-reverse: 0;+ margin-block-start: calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));+ margin-block-end: calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)));+ }+ :where(.space-y-8 > :not(:last-child)) {+ --tw-space-y-reverse: 0;+ margin-block-start: calc(calc(var(--spacing) * 8) * var(--tw-space-y-reverse));+ margin-block-end: calc(calc(var(--spacing) * 8) * calc(1 - var(--tw-space-y-reverse)));+ }+ :where(.space-x-2 > :not(:last-child)) {+ --tw-space-x-reverse: 0;+ margin-inline-start: calc(calc(var(--spacing) * 2) * var(--tw-space-x-reverse));+ margin-inline-end: calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-x-reverse)));+ }+ .overflow-hidden {+ overflow: hidden;+ }+ .rounded-full {+ border-radius: calc(infinity * 1px);+ }+ .rounded-lg {+ border-radius: var(--radius-lg);+ }+ .rounded-xl {+ border-radius: var(--radius-xl);+ }+ .border-4 {+ border-style: var(--tw-border-style);+ border-width: 4px;+ }+ .border-gray-200 {+ border-color: var(--color-gray-200);+ }+ .bg-gray-50 {+ background-color: var(--color-gray-50);+ }+ .bg-gray-300 {+ background-color: var(--color-gray-300);+ }+ .bg-green-500 {+ background-color: var(--color-green-500);+ }+ .bg-red-500 {+ background-color: var(--color-red-500);+ }+ .bg-white {+ background-color: var(--color-white);+ }+ .p-6 {+ padding: calc(var(--spacing) * 6);+ }+ .p-8 {+ padding: calc(var(--spacing) * 8);+ }+ .px-4 {+ padding-inline: calc(var(--spacing) * 4);+ }+ .px-6 {+ padding-inline: calc(var(--spacing) * 6);+ }+ .py-4 {+ padding-block: calc(var(--spacing) * 4);+ }+ .py-12 {+ padding-block: calc(var(--spacing) * 12);+ }+ .text-center {+ text-align: center;+ }+ .text-right {+ text-align: right;+ }+ .text-2xl {+ font-size: var(--text-2xl);+ line-height: var(--tw-leading, var(--text-2xl--line-height));+ }+ .text-3xl {+ font-size: var(--text-3xl);+ line-height: var(--tw-leading, var(--text-3xl--line-height));+ }+ .text-base {+ font-size: var(--text-base);+ line-height: var(--tw-leading, var(--text-base--line-height));+ }+ .text-lg {+ font-size: var(--text-lg);+ line-height: var(--tw-leading, var(--text-lg--line-height));+ }+ .text-sm {+ font-size: var(--text-sm);+ line-height: var(--tw-leading, var(--text-sm--line-height));+ }+ .text-xs {+ font-size: var(--text-xs);+ line-height: var(--tw-leading, var(--text-xs--line-height));+ }+ .font-bold {+ --tw-font-weight: var(--font-weight-bold);+ font-weight: var(--font-weight-bold);+ }+ .font-extrabold {+ --tw-font-weight: var(--font-weight-extrabold);+ font-weight: var(--font-weight-extrabold);+ }+ .font-medium {+ --tw-font-weight: var(--font-weight-medium);+ font-weight: var(--font-weight-medium);+ }+ .font-semibold {+ --tw-font-weight: var(--font-weight-semibold);+ font-weight: var(--font-weight-semibold);+ }+ .text-amber-600 {+ color: var(--color-amber-600);+ }+ .text-blue-600 {+ color: var(--color-blue-600);+ }+ .text-gray-500 {+ color: var(--color-gray-500);+ }+ .text-gray-600 {+ color: var(--color-gray-600);+ }+ .text-gray-900 {+ color: var(--color-gray-900);+ }+ .text-green-700 {+ color: var(--color-green-700);+ }+ .text-white {+ color: var(--color-white);+ }+ .shadow-xl {+ --tw-shadow:+ 0 20px 25px -5px var(--tw-shadow-color, rgb(0 0 0 / 0.1)),+ 0 8px 10px -6px var(--tw-shadow-color, rgb(0 0 0 / 0.1));+ box-shadow:+ var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow),+ var(--tw-shadow);+ }+ .transition-all {+ transition-property: all;+ transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));+ transition-duration: var(--tw-duration, var(--default-transition-duration));+ }+ .transition-transform {+ transition-property: transform, translate, scale, rotate;+ transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));+ transition-duration: var(--tw-duration, var(--default-transition-duration));+ }+ .duration-200 {+ --tw-duration: 200ms;+ transition-duration: 200ms;+ }+ .duration-500 {+ --tw-duration: 500ms;+ transition-duration: 500ms;+ }+ .ease-in-out {+ --tw-ease: var(--ease-in-out);+ transition-timing-function: var(--ease-in-out);+ }+ .ease-out {+ --tw-ease: var(--ease-out);+ transition-timing-function: var(--ease-out);+ }+ .select-none {+ -webkit-user-select: none;+ -moz-user-select: none;+ user-select: none;+ }+ .checked\:translate-x-full:checked {+ --tw-translate-x: 100%;+ translate: var(--tw-translate-x) var(--tw-translate-y);+ }+ .checked\:bg-blue-500:checked {+ background-color: var(--color-blue-500);+ }+ @media (hover: hover) {+ .hover\:text-blue-500:hover {+ color: var(--color-blue-500);+ }+ }+ @media (hover: hover) {+ .hover\:underline:hover {+ text-decoration-line: underline;+ }+ }+ @media (hover: hover) {+ .hover\:shadow-md:hover {+ --tw-shadow:+ 0 4px 6px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1)),+ 0 2px 4px -2px var(--tw-shadow-color, rgb(0 0 0 / 0.1));+ box-shadow:+ var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow),+ var(--tw-ring-shadow), var(--tw-shadow);+ }+ }+ @media (width >= 40rem) {+ .sm\:px-6 {+ padding-inline: calc(var(--spacing) * 6);+ }+ }+ @media (width >= 64rem) {+ .lg\:px-8 {+ padding-inline: calc(var(--spacing) * 8);+ }+ }+}+@layer base {+ *,+ ::after,+ ::before,+ ::backdrop,+ ::file-selector-button {+ border-color: var(--color-gray-200, currentcolor);+ }+}+@property --tw-rotate-x {+ syntax: '*';+ inherits: false;+}+@property --tw-rotate-y {+ syntax: '*';+ inherits: false;+}+@property --tw-rotate-z {+ syntax: '*';+ inherits: false;+}+@property --tw-skew-x {+ syntax: '*';+ inherits: false;+}+@property --tw-skew-y {+ syntax: '*';+ inherits: false;+}+@property --tw-space-y-reverse {+ syntax: '*';+ inherits: false;+ initial-value: 0;+}+@property --tw-space-x-reverse {+ syntax: '*';+ inherits: false;+ initial-value: 0;+}+@property --tw-border-style {+ syntax: '*';+ inherits: false;+ initial-value: solid;+}+@property --tw-font-weight {+ syntax: '*';+ inherits: false;+}+@property --tw-shadow {+ syntax: '*';+ inherits: false;+ initial-value: 0 0 #0000;+}+@property --tw-shadow-color {+ syntax: '*';+ inherits: false;+}+@property --tw-shadow-alpha {+ syntax: '<percentage>';+ inherits: false;+ initial-value: 100%;+}+@property --tw-inset-shadow {+ syntax: '*';+ inherits: false;+ initial-value: 0 0 #0000;+}+@property --tw-inset-shadow-color {+ syntax: '*';+ inherits: false;+}+@property --tw-inset-shadow-alpha {+ syntax: '<percentage>';+ inherits: false;+ initial-value: 100%;+}+@property --tw-ring-color {+ syntax: '*';+ inherits: false;+}+@property --tw-ring-shadow {+ syntax: '*';+ inherits: false;+ initial-value: 0 0 #0000;+}+@property --tw-inset-ring-color {+ syntax: '*';+ inherits: false;+}+@property --tw-inset-ring-shadow {+ syntax: '*';+ inherits: false;+ initial-value: 0 0 #0000;+}+@property --tw-ring-inset {+ syntax: '*';+ inherits: false;+}+@property --tw-ring-offset-width {+ syntax: '<length>';+ inherits: false;+ initial-value: 0px;+}+@property --tw-ring-offset-color {+ syntax: '*';+ inherits: false;+ initial-value: #fff;+}+@property --tw-ring-offset-shadow {+ syntax: '*';+ inherits: false;+ initial-value: 0 0 #0000;+}+@property --tw-duration {+ syntax: '*';+ inherits: false;+}+@property --tw-ease {+ syntax: '*';+ inherits: false;+}+@property --tw-translate-x {+ syntax: '*';+ inherits: false;+ initial-value: 0;+}+@property --tw-translate-y {+ syntax: '*';+ inherits: false;+ initial-value: 0;+}+@property --tw-translate-z {+ syntax: '*';+ inherits: false;+ initial-value: 0;+}+@layer properties {+ @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or+ ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {+ *,+ ::before,+ ::after,+ ::backdrop {+ --tw-rotate-x: initial;+ --tw-rotate-y: initial;+ --tw-rotate-z: initial;+ --tw-skew-x: initial;+ --tw-skew-y: initial;+ --tw-space-y-reverse: 0;+ --tw-space-x-reverse: 0;+ --tw-border-style: solid;+ --tw-font-weight: initial;+ --tw-shadow: 0 0 #0000;+ --tw-shadow-color: initial;+ --tw-shadow-alpha: 100%;+ --tw-inset-shadow: 0 0 #0000;+ --tw-inset-shadow-color: initial;+ --tw-inset-shadow-alpha: 100%;+ --tw-ring-color: initial;+ --tw-ring-shadow: 0 0 #0000;+ --tw-inset-ring-color: initial;+ --tw-inset-ring-shadow: 0 0 #0000;+ --tw-ring-inset: initial;+ --tw-ring-offset-width: 0px;+ --tw-ring-offset-color: #fff;+ --tw-ring-offset-shadow: 0 0 #0000;+ --tw-duration: initial;+ --tw-ease: initial;+ --tw-translate-x: 0;+ --tw-translate-y: 0;+ --tw-translate-z: 0;+ }+ }+}diff --git a/frontend/src/styles/message-preferences.css b/frontend/src/styles/message-preferences.cssnew file mode 100644index 000000000000..4aefb500a88e--- /dev/null+++ b/frontend/src/styles/message-preferences.css@@ -0,0 +1,38 @@+/* Source for the stylesheet the messaging preference pages load.+ *+ * Those pages are Django templates, not part of the app bundle, so they need a stylesheet of+ * their own. Tailwind's play CDN is not an option: it is a third-party script on a page reached+ * from an email link that carries a signed subscriber token, and it compiles in the browser,+ * which Tailwind's own documentation says is not for production.+ *+ * This is deliberately the stock Tailwind theme rather than the app's. The templates use default+ * palette names (bg-gray-50, bg-blue-500, text-amber-600), which `common/tailwind` replaces with+ * PostHog CSS variables, so building them against the app theme would drop those utilities.+ *+ * Regenerate with `pnpm --filter=@posthog/frontend build:message-preferences` after editing+ * either template. The output is committed so the dev server and collectstatic both have it,+ * the same way frontend/public/posthog-ai-onboarding holds committed build output.+ *+ * The script runs this file through the same PostCSS plugins as the app's own CSS build, so the+ * pages get the app's production browser targets. Tailwind 4 writes colors as oklch(), which older+ * browsers in those targets cannot read, and postcss-preset-env lowers them to rgb() for them.+ */++/* `source(none)` turns off automatic source detection. Without it Tailwind also scans up from+ * this file into frontend/src, which made the output four times larger and, worse, let it+ * satisfy classes these templates never reference. */+@import 'tailwindcss' source(none);+@source '../../../posthog/templates/message_preferences';++/* The toggle knobs in preferences.html set `border-4` with no border color. Tailwind 4 draws an+ * uncolored border in currentColor, which is black on these pages, so this sets gray-200 as the+ * default border color that the templates are designed around. */+@layer base {+ *,+ ::after,+ ::before,+ ::backdrop,+ ::file-selector-button {+ border-color: var(--color-gray-200, currentcolor);+ }+}diff --git a/posthog/templates/message_preferences/one_click_unsubscribe_success.html b/posthog/templates/message_preferences/one_click_unsubscribe_success.htmlindex 1d1fef64664e..3bdb144e96ee 100644--- a/posthog/templates/message_preferences/one_click_unsubscribe_success.html+++ b/posthog/templates/message_preferences/one_click_unsubscribe_success.html@@ -1,10 +1,13 @@+{% load static %}<!DOCTYPE html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Message preferences</title>- <script src="https://cdn.tailwindcss.com"></script>+ {# Compiled from the Tailwind classes in this directory. Run #}+ {# `pnpm --filter=@posthog/frontend build:message-preferences` after changing a class here. #}+ <link rel="stylesheet" href="{% static 'message-preferences.css' %}" /></head><body>{% block content %}diff --git a/posthog/templates/message_preferences/preferences.html b/posthog/templates/message_preferences/preferences.htmlindex 964df2048a7d..41aadf834528 100644--- a/posthog/templates/message_preferences/preferences.html+++ b/posthog/templates/message_preferences/preferences.html@@ -1,10 +1,14 @@+{% load static %}<!DOCTYPE html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Message preferences</title>- <script src="https://cdn.tailwindcss.com"></script>+ {# Compiled from the Tailwind classes in this directory, including the ones the inline #}+ {# script below builds as strings. Run `pnpm --filter=@posthog/frontend #}+ {# build:message-preferences` after changing a class in either place. #}+ <link rel="stylesheet" href="{% static 'message-preferences.css' %}" /></head><body>{% block content %}diff --git a/products/messaging/backend/api/test/test_message_preference_styles.py b/products/messaging/backend/api/test/test_message_preference_styles.pynew file mode 100644index 000000000000..0bf88c96689b--- /dev/null+++ b/products/messaging/backend/api/test/test_message_preference_styles.py@@ -0,0 +1,80 @@+import re+from pathlib import Path++from django.conf import settings+from django.test import SimpleTestCase++TEMPLATE_DIR = Path(settings.BASE_DIR) / "posthog" / "templates" / "message_preferences"+STYLESHEET = Path(settings.BASE_DIR) / "frontend" / "public" / "message-preferences.css"+REBUILD = "pnpm --filter=@posthog/frontend build:message-preferences"++# Tailwind compiles these templates ahead of time, so a class added to the markup does nothing+# until someone reruns the build. Nothing else notices: the page still renders, just unstyled.+_CLASS_ATTRIBUTE = re.compile(r'class="([^"]*)"')+# Django tags and variables share the attribute with the class list, so remove them before+# splitting. A `{% if %}` branch puts real classes mid-list, and dropping the whole token would+# skip them.+_TEMPLATE_TAG = re.compile(r"\{%.*?%\}|\{\{.*?\}\}")+# Whatever a malformed or multi-line tag leaves behind is not a class name.+_TEMPLATE_SYNTAX = re.compile(r"[{}%|'\"]|^(if|else|endif|elif|for|endfor)$")+# A Tailwind utility as these templates write them: lowercase, digits, dashes, with optional+# variant prefixes such as `hover:` or `sm:`. Deliberately strict, so a stray word in an+# attribute does not become an assertion.+_UTILITY = re.compile(r"^[a-z][a-z0-9]*(-[a-z0-9.]+)*(:[a-z0-9-]+)*$")++# Hooks for the inline script, not utilities, so they are unstyled on purpose. A marker class is+# shaped exactly like a Tailwind utility, so nothing but this list can tell the two apart.+_SCRIPT_HOOKS = frozenset({"toggle-checkbox", "toggle-label"})++# The inline script in preferences.html builds these into `className`, so no `class="..."`+# attribute holds them and the scan cannot reach them. They are listed so the toast and the saving+# state keep their colors if the script moves out of the template or the Tailwind `@source` scope+# stops covering it. A class the script starts to use must be added here by hand.+_SCRIPT_UTILITIES = frozenset(+ {+ "bg-green-500",+ "bg-red-500",+ "duration-500",+ "ease-out",+ "fixed",+ "px-6",+ "py-4",+ "right-4",+ "text-amber-600",+ "text-white",+ "top-4",+ "transform",+ }+)+++def _selector_present(css: str, utility: str) -> bool:+ # Tailwind escapes the characters that are not selector-safe, so `hover:shadow-md` is written+ # `.hover\:shadow-md`. The trailing guard stops `.flex` matching inside `.flex-1`.+ escaped = re.escape(utility).replace(":", r"\\:")+ return re.search(r"\." + escaped + r"(?![a-zA-Z0-9_-])", css) is not None+++class TestMessagePreferenceStyles(SimpleTestCase):+ def test_every_class_in_the_templates_is_in_the_compiled_stylesheet(self) -> None:+ css = STYLESHEET.read_text()++ missing: dict[str, set[str]] = {}+ for template in sorted(TEMPLATE_DIR.glob("*.html")):+ for attribute in _CLASS_ATTRIBUTE.findall(template.read_text()):+ for token in _TEMPLATE_TAG.sub(" ", attribute).split():+ if token in _SCRIPT_HOOKS or _TEMPLATE_SYNTAX.search(token) or not _UTILITY.match(token):+ continue+ if not _selector_present(css, token):+ missing.setdefault(template.name, set()).add(token)++ for utility in _SCRIPT_UTILITIES:+ if not _selector_present(css, utility):+ missing.setdefault("preferences.html inline script", set()).add(utility)++ assert not missing, (+ f"These classes are used in the message preference templates but are not in "+ f"{STYLESHEET.name}, so they render unstyled: "+ + "; ".join(f"{name}: {sorted(classes)}" for name, classes in sorted(missing.items()))+ + f". Run `{REBUILD}` and commit the result."+ )