diff --git a/.storybook/decorators/withTheme.tsx b/.storybook/decorators/withTheme.tsx index 90699cd60ffab..a1374cb810292 100644 --- a/.storybook/decorators/withTheme.tsx +++ b/.storybook/decorators/withTheme.tsx @@ -1,4 +1,7 @@ import type { Decorator } from '@storybook/react' +import { useActions } from 'kea' +import { useEffect } from 'react' +import { userLogic } from 'scenes/userLogic' /** Global story decorator that is used by the theming control to * switch between themes. @@ -6,8 +9,12 @@ import type { Decorator } from '@storybook/react' export const withTheme: Decorator = (Story, context) => { const theme = context.globals.theme - // set the theme - document.body.setAttribute('theme', theme === 'dark' ? 'dark' : 'light') + const { __testOnlyOverrideThemeFromCookie } = useActions(userLogic) + + useEffect(() => { + document.body.setAttribute('theme', theme) + __testOnlyOverrideThemeFromCookie(theme) + }, [theme]) return } diff --git a/.storybook/test-runner.ts b/.storybook/test-runner.ts index 97cd99d515dd0..59aca268fd713 100644 --- a/.storybook/test-runner.ts +++ b/.storybook/test-runner.ts @@ -3,10 +3,10 @@ import { getStoryContext, TestRunnerConfig, TestContext, waitForPageReady } from import type { Locator, Page, LocatorScreenshotOptions } from '@playwright/test' import type { Mocks } from '~/mocks/utils' import { StoryContext } from '@storybook/csf' +import { UserTheme } from '~/types' // 'firefox' is technically supported too, but as of June 2023 it has memory usage issues that make is unusable type SupportedBrowserName = 'chromium' | 'webkit' -type SnapshotTheme = 'light' | 'dark' // Extend Storybook interface `Parameters` with Chromatic parameters declare module '@storybook/types' { @@ -44,7 +44,7 @@ declare module '@storybook/types' { } interface Globals { - theme: SnapshotTheme + theme: UserTheme } } @@ -116,7 +116,7 @@ async function expectStoryToMatchSnapshot( page: Page, context: TestContext, browser: SupportedBrowserName, - theme: SnapshotTheme, + theme: UserTheme, targetSelector?: string ) => Promise if (storyContext.parameters?.layout === 'fullscreen') { @@ -129,7 +129,8 @@ async function expectStoryToMatchSnapshot( check = expectStoryToMatchComponentSnapshot } - await waitForPageReady(page) + await waitForPageReady(page) + await page.evaluate((layout: string) => { // Stop all animations for consistent snapshots, and adjust other styles document.body.classList.add('storybook-test-runner') @@ -152,18 +153,18 @@ async function expectStoryToMatchSnapshot( Array.from(document.querySelectorAll('img')).every((i: HTMLImageElement) => i.complete) ) - // snapshot light theme + // Light theme snapshot await page.evaluate(() => { document.body.setAttribute('theme', 'light') + window.__testOnlyOverrideThemeFromCookie('light') }) - await check(page, context, browser, 'light', storyContext.parameters?.testOptions?.snapshotTargetSelector) - // snapshot dark theme - await page.evaluate(() => { + // Dark theme snapshot + await page.evaluate(() => { document.body.setAttribute('theme', 'dark') + window.__testOnlyOverrideThemeFromCookie('dark') }) - await check(page, context, browser, 'dark', storyContext.parameters?.testOptions?.snapshotTargetSelector) } @@ -171,7 +172,7 @@ async function expectStoryToMatchViewportSnapshot( page: Page, context: TestContext, browser: SupportedBrowserName, - theme: SnapshotTheme + theme: UserTheme ): Promise { await expectLocatorToMatchStorySnapshot(page, context, browser, theme) } @@ -180,7 +181,7 @@ async function expectStoryToMatchSceneSnapshot( page: Page, context: TestContext, browser: SupportedBrowserName, - theme: SnapshotTheme + theme: UserTheme ): Promise { // If the `main` element isn't present, let's use `body` - this is needed in logged-out screens. // We use .last(), because the order of selector matches is based on the order of elements in the DOM, @@ -192,7 +193,7 @@ async function expectStoryToMatchComponentSnapshot( page: Page, context: TestContext, browser: SupportedBrowserName, - theme: SnapshotTheme, + theme: UserTheme, targetSelector: string = '#storybook-root' ): Promise { await page.evaluate(() => { @@ -228,7 +229,7 @@ async function expectLocatorToMatchStorySnapshot( locator: Locator | Page, context: TestContext, browser: SupportedBrowserName, - theme: SnapshotTheme, + theme: UserTheme, options?: LocatorScreenshotOptions ): Promise { const image = await locator.screenshot({ ...options }) diff --git a/frontend/__snapshots__/components-sharing--dashboard-sharing--dark.png b/frontend/__snapshots__/components-sharing--dashboard-sharing--dark.png index e28cfee483210..2415e83315de9 100644 Binary files a/frontend/__snapshots__/components-sharing--dashboard-sharing--dark.png and b/frontend/__snapshots__/components-sharing--dashboard-sharing--dark.png differ diff --git a/frontend/__snapshots__/components-sharing--dashboard-sharing-licensed--dark.png b/frontend/__snapshots__/components-sharing--dashboard-sharing-licensed--dark.png index 2eeea5c642cd0..167bfe31a1c82 100644 Binary files a/frontend/__snapshots__/components-sharing--dashboard-sharing-licensed--dark.png and b/frontend/__snapshots__/components-sharing--dashboard-sharing-licensed--dark.png differ diff --git a/frontend/__snapshots__/components-sharing--recording-sharing-licensed--dark.png b/frontend/__snapshots__/components-sharing--recording-sharing-licensed--dark.png index f4714b9592759..64bb36752e860 100644 Binary files a/frontend/__snapshots__/components-sharing--recording-sharing-licensed--dark.png and b/frontend/__snapshots__/components-sharing--recording-sharing-licensed--dark.png differ diff --git a/frontend/__snapshots__/exporter-exporter--funnel-left-to-right-breakdown-insight--dark.png b/frontend/__snapshots__/exporter-exporter--funnel-left-to-right-breakdown-insight--dark.png index cceadf532f62a..fa1cb156ea73a 100644 Binary files a/frontend/__snapshots__/exporter-exporter--funnel-left-to-right-breakdown-insight--dark.png and b/frontend/__snapshots__/exporter-exporter--funnel-left-to-right-breakdown-insight--dark.png differ diff --git a/frontend/__snapshots__/exporter-exporter--funnel-left-to-right-insight--dark.png b/frontend/__snapshots__/exporter-exporter--funnel-left-to-right-insight--dark.png index b71791b88a566..6e64d78e48d24 100644 Binary files a/frontend/__snapshots__/exporter-exporter--funnel-left-to-right-insight--dark.png and b/frontend/__snapshots__/exporter-exporter--funnel-left-to-right-insight--dark.png differ diff --git a/frontend/__snapshots__/exporter-exporter--funnel-time-to-convert-insight--dark.png b/frontend/__snapshots__/exporter-exporter--funnel-time-to-convert-insight--dark.png index d89e15a5f127f..df7bedc152696 100644 Binary files a/frontend/__snapshots__/exporter-exporter--funnel-time-to-convert-insight--dark.png and b/frontend/__snapshots__/exporter-exporter--funnel-time-to-convert-insight--dark.png differ diff --git a/frontend/__snapshots__/exporter-exporter--trends-pie-breakdown-insight--dark.png b/frontend/__snapshots__/exporter-exporter--trends-pie-breakdown-insight--dark.png index fa1f7a89fb302..d812f48961260 100644 Binary files a/frontend/__snapshots__/exporter-exporter--trends-pie-breakdown-insight--dark.png and b/frontend/__snapshots__/exporter-exporter--trends-pie-breakdown-insight--dark.png differ diff --git a/frontend/__snapshots__/exporter-exporter--trends-pie-insight--dark.png b/frontend/__snapshots__/exporter-exporter--trends-pie-insight--dark.png index 877c3efc21c12..85295b8a8a985 100644 Binary files a/frontend/__snapshots__/exporter-exporter--trends-pie-insight--dark.png and b/frontend/__snapshots__/exporter-exporter--trends-pie-insight--dark.png differ diff --git a/frontend/__snapshots__/exporter-exporter--user-paths-insight--dark.png b/frontend/__snapshots__/exporter-exporter--user-paths-insight--dark.png index 74824563c8f49..cbf19dfa4784a 100644 Binary files a/frontend/__snapshots__/exporter-exporter--user-paths-insight--dark.png and b/frontend/__snapshots__/exporter-exporter--user-paths-insight--dark.png differ diff --git a/frontend/__snapshots__/lemon-ui-code-snippet--java-script--dark.png b/frontend/__snapshots__/lemon-ui-code-snippet--java-script--dark.png index f843eec37c314..4eb159ae8f991 100644 Binary files a/frontend/__snapshots__/lemon-ui-code-snippet--java-script--dark.png and b/frontend/__snapshots__/lemon-ui-code-snippet--java-script--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-dashboards--create-template--dark.png b/frontend/__snapshots__/scenes-app-dashboards--create-template--dark.png index ed2947ef9fdf3..42f7d49320c01 100644 Binary files a/frontend/__snapshots__/scenes-app-dashboards--create-template--dark.png and b/frontend/__snapshots__/scenes-app-dashboards--create-template--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-dashboards--edit-template--dark.png b/frontend/__snapshots__/scenes-app-dashboards--edit-template--dark.png index 0ff80daf82147..ed8ba8602cbb0 100644 Binary files a/frontend/__snapshots__/scenes-app-dashboards--edit-template--dark.png and b/frontend/__snapshots__/scenes-app-dashboards--edit-template--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-feature-flags--edit-feature-flag--dark.png b/frontend/__snapshots__/scenes-app-feature-flags--edit-feature-flag--dark.png index 7e63dcc4450bd..389219e24968c 100644 Binary files a/frontend/__snapshots__/scenes-app-feature-flags--edit-feature-flag--dark.png and b/frontend/__snapshots__/scenes-app-feature-flags--edit-feature-flag--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-feature-flags--edit-multi-variate-feature-flag--dark.png b/frontend/__snapshots__/scenes-app-feature-flags--edit-multi-variate-feature-flag--dark.png index 97fb2a7698f4c..e079df046a30f 100644 Binary files a/frontend/__snapshots__/scenes-app-feature-flags--edit-multi-variate-feature-flag--dark.png and b/frontend/__snapshots__/scenes-app-feature-flags--edit-multi-variate-feature-flag--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-feature-flags--new-feature-flag--dark.png b/frontend/__snapshots__/scenes-app-feature-flags--new-feature-flag--dark.png index 1e918ce2709b2..f92d6dcb4f274 100644 Binary files a/frontend/__snapshots__/scenes-app-feature-flags--new-feature-flag--dark.png and b/frontend/__snapshots__/scenes-app-feature-flags--new-feature-flag--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-node-with-group-multivariate-flag-local-evaluation--dark.png b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-node-with-group-multivariate-flag-local-evaluation--dark.png index 008f01bad3350..c3b916663eab5 100644 Binary files a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-node-with-group-multivariate-flag-local-evaluation--dark.png and b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-node-with-group-multivariate-flag-local-evaluation--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-overview--dark.png b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-overview--dark.png index 23529892be689..274fc8bbbc7af 100644 Binary files a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-overview--dark.png and b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-overview--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-python-with-local-evaluation--dark.png b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-python-with-local-evaluation--dark.png index 1d24134e02a19..4e7a2b39e444a 100644 Binary files a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-python-with-local-evaluation--dark.png and b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-python-with-local-evaluation--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-react-native-with-bootstrap--dark.png b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-react-native-with-bootstrap--dark.png index 2a6a6a4fa1fb3..29e2b2e1902b9 100644 Binary files a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-react-native-with-bootstrap--dark.png and b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-react-native-with-bootstrap--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-ruby-with-group-flag-local-evaluation--dark.png b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-ruby-with-group-flag-local-evaluation--dark.png index d72e22cc40466..4552751d6f790 100644 Binary files a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-ruby-with-group-flag-local-evaluation--dark.png and b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructions-ruby-with-group-flag-local-evaluation--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructionsi-os-with-multivariate-flag--dark.png b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructionsi-os-with-multivariate-flag--dark.png index 8725f1bae561c..c95aaee04fcce 100644 Binary files a/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructionsi-os-with-multivariate-flag--dark.png and b/frontend/__snapshots__/scenes-app-feature-flags-code-examples--code-instructionsi-os-with-multivariate-flag--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-docs--dark.png b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-docs--dark.png index 43adc29eb00ce..25cc925f67086 100644 Binary files a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-docs--dark.png and b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-docs--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--dark.png b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--dark.png index ef042d71c7de9..704c3a0e0fb25 100644 Binary files a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--dark.png and b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-invitesignup--cloud--dark.png b/frontend/__snapshots__/scenes-other-invitesignup--cloud--dark.png index 4946aedfeb38a..648d271e81937 100644 Binary files a/frontend/__snapshots__/scenes-other-invitesignup--cloud--dark.png and b/frontend/__snapshots__/scenes-other-invitesignup--cloud--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-invitesignup--cloud-eu--dark.png b/frontend/__snapshots__/scenes-other-invitesignup--cloud-eu--dark.png index 6767462f173e0..55eaa233d847f 100644 Binary files a/frontend/__snapshots__/scenes-other-invitesignup--cloud-eu--dark.png and b/frontend/__snapshots__/scenes-other-invitesignup--cloud-eu--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-invitesignup--invalid-link--dark.png b/frontend/__snapshots__/scenes-other-invitesignup--invalid-link--dark.png index 605ac3e495e9c..fd7088f0aa58d 100644 Binary files a/frontend/__snapshots__/scenes-other-invitesignup--invalid-link--dark.png and b/frontend/__snapshots__/scenes-other-invitesignup--invalid-link--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-invitesignup--logged-in--dark.png b/frontend/__snapshots__/scenes-other-invitesignup--logged-in--dark.png index fc126241a2102..60468bb5bce41 100644 Binary files a/frontend/__snapshots__/scenes-other-invitesignup--logged-in--dark.png and b/frontend/__snapshots__/scenes-other-invitesignup--logged-in--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-invitesignup--logged-in-wrong-user--dark.png b/frontend/__snapshots__/scenes-other-invitesignup--logged-in-wrong-user--dark.png index 06d405fe4af12..33e12077bd073 100644 Binary files a/frontend/__snapshots__/scenes-other-invitesignup--logged-in-wrong-user--dark.png and b/frontend/__snapshots__/scenes-other-invitesignup--logged-in-wrong-user--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-invitesignup--self-hosted--dark.png b/frontend/__snapshots__/scenes-other-invitesignup--self-hosted--dark.png index 1aa1af55b6ba0..0be14d0ec729f 100644 Binary files a/frontend/__snapshots__/scenes-other-invitesignup--self-hosted--dark.png and b/frontend/__snapshots__/scenes-other-invitesignup--self-hosted--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-login--cloud--dark.png b/frontend/__snapshots__/scenes-other-login--cloud--dark.png index 7a14791959cef..72f4e2e7467b7 100644 Binary files a/frontend/__snapshots__/scenes-other-login--cloud--dark.png and b/frontend/__snapshots__/scenes-other-login--cloud--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-login--cloud-eu--dark.png b/frontend/__snapshots__/scenes-other-login--cloud-eu--dark.png index 1708f185a9db4..a5c5ad78458d5 100644 Binary files a/frontend/__snapshots__/scenes-other-login--cloud-eu--dark.png and b/frontend/__snapshots__/scenes-other-login--cloud-eu--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-login--cloud-with-google-login-enforcement--dark.png b/frontend/__snapshots__/scenes-other-login--cloud-with-google-login-enforcement--dark.png index d0e0904bb1796..859fa7dac3faa 100644 Binary files a/frontend/__snapshots__/scenes-other-login--cloud-with-google-login-enforcement--dark.png and b/frontend/__snapshots__/scenes-other-login--cloud-with-google-login-enforcement--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-login--second-factor--dark.png b/frontend/__snapshots__/scenes-other-login--second-factor--dark.png index 442c6d925ac8f..5c847d97b9536 100644 Binary files a/frontend/__snapshots__/scenes-other-login--second-factor--dark.png and b/frontend/__snapshots__/scenes-other-login--second-factor--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-login--self-hosted--dark.png b/frontend/__snapshots__/scenes-other-login--self-hosted--dark.png index 00219a94898ad..5b093b371c9e0 100644 Binary files a/frontend/__snapshots__/scenes-other-login--self-hosted--dark.png and b/frontend/__snapshots__/scenes-other-login--self-hosted--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-login--self-hosted-with-saml--dark.png b/frontend/__snapshots__/scenes-other-login--self-hosted-with-saml--dark.png index 752d4e4ee3c7d..a01832684ba38 100644 Binary files a/frontend/__snapshots__/scenes-other-login--self-hosted-with-saml--dark.png and b/frontend/__snapshots__/scenes-other-login--self-hosted-with-saml--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-login--sso-error--dark.png b/frontend/__snapshots__/scenes-other-login--sso-error--dark.png index d3e245bf489c0..e0c894adcd6ce 100644 Binary files a/frontend/__snapshots__/scenes-other-login--sso-error--dark.png and b/frontend/__snapshots__/scenes-other-login--sso-error--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-onboarding--onboarding-sd-ks--dark.png b/frontend/__snapshots__/scenes-other-onboarding--onboarding-sd-ks--dark.png index 3b025adbf1e77..035c0f872e30f 100644 Binary files a/frontend/__snapshots__/scenes-other-onboarding--onboarding-sd-ks--dark.png and b/frontend/__snapshots__/scenes-other-onboarding--onboarding-sd-ks--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-password-reset--initial--dark.png b/frontend/__snapshots__/scenes-other-password-reset--initial--dark.png index 6cb6eb6d746fc..f4f5542081cad 100644 Binary files a/frontend/__snapshots__/scenes-other-password-reset--initial--dark.png and b/frontend/__snapshots__/scenes-other-password-reset--initial--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-password-reset--no-smtp--dark.png b/frontend/__snapshots__/scenes-other-password-reset--no-smtp--dark.png index 89642680118fe..69abb12ca5c30 100644 Binary files a/frontend/__snapshots__/scenes-other-password-reset--no-smtp--dark.png and b/frontend/__snapshots__/scenes-other-password-reset--no-smtp--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-password-reset--success--dark.png b/frontend/__snapshots__/scenes-other-password-reset--success--dark.png index 4bfe10a123e4f..b7c5a43b6d76c 100644 Binary files a/frontend/__snapshots__/scenes-other-password-reset--success--dark.png and b/frontend/__snapshots__/scenes-other-password-reset--success--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-password-reset--throttled--dark.png b/frontend/__snapshots__/scenes-other-password-reset--throttled--dark.png index bb0239106bde1..a1d1a33c15a0c 100644 Binary files a/frontend/__snapshots__/scenes-other-password-reset--throttled--dark.png and b/frontend/__snapshots__/scenes-other-password-reset--throttled--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-password-reset-complete--default--dark.png b/frontend/__snapshots__/scenes-other-password-reset-complete--default--dark.png index 81780bef94ddb..a8967c8a64ca9 100644 Binary files a/frontend/__snapshots__/scenes-other-password-reset-complete--default--dark.png and b/frontend/__snapshots__/scenes-other-password-reset-complete--default--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-password-reset-complete--invalid-link--dark.png b/frontend/__snapshots__/scenes-other-password-reset-complete--invalid-link--dark.png index 94d798172a128..455e2416bceb8 100644 Binary files a/frontend/__snapshots__/scenes-other-password-reset-complete--invalid-link--dark.png and b/frontend/__snapshots__/scenes-other-password-reset-complete--invalid-link--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-preflight--preflight--dark.png b/frontend/__snapshots__/scenes-other-preflight--preflight--dark.png index da76826c30718..ef7659b15919b 100644 Binary files a/frontend/__snapshots__/scenes-other-preflight--preflight--dark.png and b/frontend/__snapshots__/scenes-other-preflight--preflight--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-signup--cloud--dark.png b/frontend/__snapshots__/scenes-other-signup--cloud--dark.png index 3812da12f2360..7f2340752e207 100644 Binary files a/frontend/__snapshots__/scenes-other-signup--cloud--dark.png and b/frontend/__snapshots__/scenes-other-signup--cloud--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-signup--cloud--light.png b/frontend/__snapshots__/scenes-other-signup--cloud--light.png index 06af20259734b..51e0d39b9ee49 100644 Binary files a/frontend/__snapshots__/scenes-other-signup--cloud--light.png and b/frontend/__snapshots__/scenes-other-signup--cloud--light.png differ diff --git a/frontend/__snapshots__/scenes-other-signup--self-hosted--dark.png b/frontend/__snapshots__/scenes-other-signup--self-hosted--dark.png index 4070b44e89d74..36d7947663671 100644 Binary files a/frontend/__snapshots__/scenes-other-signup--self-hosted--dark.png and b/frontend/__snapshots__/scenes-other-signup--self-hosted--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-signup--self-hosted--light.png b/frontend/__snapshots__/scenes-other-signup--self-hosted--light.png index cf918675e9bfe..6c1cf0fe8915e 100644 Binary files a/frontend/__snapshots__/scenes-other-signup--self-hosted--light.png and b/frontend/__snapshots__/scenes-other-signup--self-hosted--light.png differ diff --git a/frontend/__snapshots__/scenes-other-signup--self-hosted-sso--dark.png b/frontend/__snapshots__/scenes-other-signup--self-hosted-sso--dark.png index cdb034b88aba3..ca190c1a587b8 100644 Binary files a/frontend/__snapshots__/scenes-other-signup--self-hosted-sso--dark.png and b/frontend/__snapshots__/scenes-other-signup--self-hosted-sso--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-signup--self-hosted-sso--light.png b/frontend/__snapshots__/scenes-other-signup--self-hosted-sso--light.png index 51591a33cb059..b69a17b8ee1f3 100644 Binary files a/frontend/__snapshots__/scenes-other-signup--self-hosted-sso--light.png and b/frontend/__snapshots__/scenes-other-signup--self-hosted-sso--light.png differ diff --git a/frontend/__snapshots__/scenes-other-unsubscribe--unsubscribe-scene--dark.png b/frontend/__snapshots__/scenes-other-unsubscribe--unsubscribe-scene--dark.png index 9602bbe205787..466abc0c89adb 100644 Binary files a/frontend/__snapshots__/scenes-other-unsubscribe--unsubscribe-scene--dark.png and b/frontend/__snapshots__/scenes-other-unsubscribe--unsubscribe-scene--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-verify-email--verify-email-invalid--dark.png b/frontend/__snapshots__/scenes-other-verify-email--verify-email-invalid--dark.png index dd975c4acc401..779dc036e8db5 100644 Binary files a/frontend/__snapshots__/scenes-other-verify-email--verify-email-invalid--dark.png and b/frontend/__snapshots__/scenes-other-verify-email--verify-email-invalid--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-verify-email--verify-email-pending--dark.png b/frontend/__snapshots__/scenes-other-verify-email--verify-email-pending--dark.png index 0d23b6e09b819..012f3a5047c47 100644 Binary files a/frontend/__snapshots__/scenes-other-verify-email--verify-email-pending--dark.png and b/frontend/__snapshots__/scenes-other-verify-email--verify-email-pending--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-verify-email--verify-email-success--dark.png b/frontend/__snapshots__/scenes-other-verify-email--verify-email-success--dark.png index 2bf2567a3e6db..f72c87002d8f9 100644 Binary files a/frontend/__snapshots__/scenes-other-verify-email--verify-email-success--dark.png and b/frontend/__snapshots__/scenes-other-verify-email--verify-email-success--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-verify-email--verifying-email--dark.png b/frontend/__snapshots__/scenes-other-verify-email--verifying-email--dark.png index c970e47f22a45..4ee3879c0defb 100644 Binary files a/frontend/__snapshots__/scenes-other-verify-email--verifying-email--dark.png and b/frontend/__snapshots__/scenes-other-verify-email--verifying-email--dark.png differ diff --git a/frontend/public/posthog-logo-cloud-dark.svg b/frontend/public/posthog-logo-cloud-dark.svg new file mode 100644 index 0000000000000..31fb389a4fc7f --- /dev/null +++ b/frontend/public/posthog-logo-cloud-dark.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/public/posthog-logo-cloud.svg b/frontend/public/posthog-logo-cloud-light.svg similarity index 100% rename from frontend/public/posthog-logo-cloud.svg rename to frontend/public/posthog-logo-cloud-light.svg diff --git a/frontend/public/posthog-logo-dark.svg b/frontend/public/posthog-logo-dark.svg new file mode 100644 index 0000000000000..7b0bbe4491448 --- /dev/null +++ b/frontend/public/posthog-logo-dark.svg @@ -0,0 +1 @@ + diff --git a/frontend/public/posthog-logo-demo-dark.svg b/frontend/public/posthog-logo-demo-dark.svg new file mode 100644 index 0000000000000..69ea55688b5fb --- /dev/null +++ b/frontend/public/posthog-logo-demo-dark.svg @@ -0,0 +1 @@ + diff --git a/frontend/public/posthog-logo-demo.svg b/frontend/public/posthog-logo-demo-light.svg similarity index 99% rename from frontend/public/posthog-logo-demo.svg rename to frontend/public/posthog-logo-demo-light.svg index 4bc9394e3b971..96e8adf4da8d5 100644 --- a/frontend/public/posthog-logo-demo.svg +++ b/frontend/public/posthog-logo-demo-light.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/frontend/public/posthog-logo.svg b/frontend/public/posthog-logo-light.svg similarity index 100% rename from frontend/public/posthog-logo.svg rename to frontend/public/posthog-logo-light.svg diff --git a/frontend/src/layout/navigation-3000/themeLogic.ts b/frontend/src/layout/navigation-3000/themeLogic.ts index 95ed6f56a16d6..005f05b3977e4 100644 --- a/frontend/src/layout/navigation-3000/themeLogic.ts +++ b/frontend/src/layout/navigation-3000/themeLogic.ts @@ -1,5 +1,5 @@ import { actions, connect, events, kea, path, reducers, selectors } from 'kea' -import { sceneLogic } from 'scenes/sceneLogic' +import { subscriptions } from 'kea-subscriptions' import { userLogic } from 'scenes/userLogic' import type { themeLogicType } from './themeLogicType' @@ -7,7 +7,7 @@ import type { themeLogicType } from './themeLogicType' export const themeLogic = kea([ path(['layout', 'navigation-3000', 'themeLogic']), connect({ - values: [userLogic, ['themeMode']], + values: [userLogic, ['userThemeMode']], }), actions({ syncDarkModePreference: (darkModePreference: boolean) => ({ darkModePreference }), @@ -22,21 +22,17 @@ export const themeLogic = kea([ }), selectors({ isDarkModeOn: [ - (s) => [s.themeMode, s.darkModeSystemPreference, sceneLogic.selectors.sceneConfig], - (themeMode, darkModeSystemPreference, sceneConfig) => { - // NOTE: Unauthenticated users always get the light mode until we have full support across onboarding flows - if ( - sceneConfig?.layout === 'plain' || - sceneConfig?.allowUnauthenticated || - sceneConfig?.onlyUnauthenticated - ) { - return false - } - - return themeMode === 'system' ? darkModeSystemPreference : themeMode === 'dark' + (s) => [s.userThemeMode, s.darkModeSystemPreference], + (userThemeMode, darkModeSystemPreference) => { + return userThemeMode === 'system' ? darkModeSystemPreference : userThemeMode === 'dark' }, ], }), + subscriptions({ + isDarkModeOn: (isDarkModeOn) => { + document.cookie = `theme=${isDarkModeOn ? 'dark' : 'light'}; Path=/; Domain=posthog.com` + }, + }), events(({ cache, actions }) => ({ afterMount() { cache.prefersColorSchemeMedia = window.matchMedia('(prefers-color-scheme: dark)') diff --git a/frontend/src/lib/components/BridgePage/BridgePage.scss b/frontend/src/lib/components/BridgePage/BridgePage.scss index cbaa3daa9631c..3bf3a960d581d 100644 --- a/frontend/src/lib/components/BridgePage/BridgePage.scss +++ b/frontend/src/lib/components/BridgePage/BridgePage.scss @@ -7,7 +7,6 @@ flex-direction: column; height: 100vh; overflow: scroll; - background-color: var(--bg-bridge); -ms-overflow-style: none; &::-webkit-scrollbar { @@ -46,7 +45,7 @@ position: relative; width: 100%; padding: 2rem; - background-color: white; + background-color: var(--bg-light); border-radius: var(--radius); box-shadow: var(--shadow-elevation); @@ -87,8 +86,8 @@ padding: 0.5rem 0.75rem; font-size: 0.8em; font-weight: 600; - color: #fff; - background-color: var(--default); + color: var(--bg-light); + background-color: var(--text-3000); border-radius: 0.75rem; opacity: 0; transition-timing-function: cubic-bezier(0.455, 0.03, 0.31, 1.585); diff --git a/frontend/src/scenes/authentication/Login2FA.tsx b/frontend/src/scenes/authentication/Login2FA.tsx index f620856bf4541..ec196e8715b66 100644 --- a/frontend/src/scenes/authentication/Login2FA.tsx +++ b/frontend/src/scenes/authentication/Login2FA.tsx @@ -24,7 +24,7 @@ export function Login2FA(): JSX.Element { } > - Two-Factor Authentication + Two-factor authentication Enter a token from your authenticator app. diff --git a/frontend/src/scenes/authentication/WelcomeLogo.tsx b/frontend/src/scenes/authentication/WelcomeLogo.tsx index 74f86005ab386..ce5126f38c339 100644 --- a/frontend/src/scenes/authentication/WelcomeLogo.tsx +++ b/frontend/src/scenes/authentication/WelcomeLogo.tsx @@ -1,21 +1,33 @@ import { Link } from '@posthog/lemon-ui' import { useValues } from 'kea' -import defaultLogo from 'public/posthog-logo.svg' -import cloudLogo from 'public/posthog-logo-cloud.svg' -import demoLogo from 'public/posthog-logo-demo.svg' +import cloudLogoDark from 'public/posthog-logo-cloud-dark.svg' +import cloudLogoLight from 'public/posthog-logo-cloud-light.svg' +import defaultLogoDark from 'public/posthog-logo-dark.svg' +import demoLogoDark from 'public/posthog-logo-demo-dark.svg' +import demoLogoLight from 'public/posthog-logo-demo-light.svg' +import defaultLogoLight from 'public/posthog-logo-light.svg' import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic' +import { themeLogic } from '~/layout/navigation-3000/themeLogic' + export function WelcomeLogo({ view }: { view?: string }): JSX.Element { const UTM_TAGS = `utm_campaign=in-product&utm_tag=${view || 'welcome'}-header` const { preflight } = useValues(preflightLogic) + const { isDarkModeOn } = useValues(themeLogic) + + let logoSrc: any + if (preflight?.demo) { + logoSrc = isDarkModeOn ? demoLogoDark : demoLogoLight + } else if (preflight?.cloud) { + logoSrc = isDarkModeOn ? cloudLogoDark : cloudLogoLight + } else { + logoSrc = isDarkModeOn ? defaultLogoDark : defaultLogoLight + } return ( - + ) diff --git a/frontend/src/scenes/authentication/signup/SignupContainer.tsx b/frontend/src/scenes/authentication/signup/SignupContainer.tsx index 0544f035d60a1..c4cd3961c5990 100644 --- a/frontend/src/scenes/authentication/signup/SignupContainer.tsx +++ b/frontend/src/scenes/authentication/signup/SignupContainer.tsx @@ -160,11 +160,11 @@ export function SignupLeftContainer(): JSX.Element { {' '} You can use our{' '} - {Region.EU} cloud + PostHog Cloud EU {' '} or{' '} - {Region.US} cloud + Posthog Cloud US {' '} and we'll take care of the hosting for you. diff --git a/frontend/src/scenes/settings/user/ThemeSwitcher.tsx b/frontend/src/scenes/settings/user/ThemeSwitcher.tsx index 5dd8b1c3bf3f5..c4fed69ae1291 100644 --- a/frontend/src/scenes/settings/user/ThemeSwitcher.tsx +++ b/frontend/src/scenes/settings/user/ThemeSwitcher.tsx @@ -7,7 +7,7 @@ export function ThemeSwitcher({ onlyLabel, ...props }: Partial> & { onlyLabel?: boolean }): JSX.Element { - const { themeMode } = useValues(userLogic) + const { userThemeMode } = useValues(userLogic) const { updateUser } = useActions(userLogic) return ( @@ -17,7 +17,7 @@ export function ThemeSwitcher({ { icon: , value: 'dark', label: 'Dark mode' }, { icon: , value: 'system', label: `Sync with system` }, ]} - value={themeMode} + value={userThemeMode} renderButtonContent={(leaf) => { const labelText = leaf ? leaf.label : 'Sync with system' return onlyLabel ? ( diff --git a/frontend/src/scenes/userLogic.ts b/frontend/src/scenes/userLogic.ts index 1dfd3390dc87f..ffbcfbce5f683 100644 --- a/frontend/src/scenes/userLogic.ts +++ b/frontend/src/scenes/userLogic.ts @@ -2,7 +2,7 @@ import { actions, afterMount, kea, listeners, path, reducers, selectors } from ' import { forms } from 'kea-forms' import { loaders } from 'kea-loaders' import { urlToAction } from 'kea-router' -import api from 'lib/api' +import api, { getCookie } from 'lib/api' import { DashboardCompatibleScenes } from 'lib/components/SceneDashboardChoice/sceneDashboardChoiceModalLogic' import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast' import { getAppContext } from 'lib/utils/getAppContext' @@ -28,6 +28,7 @@ export const userLogic = kea([ setUserScenePersonalisation: (scene: DashboardCompatibleScenes, dashboard: number) => ({ scene, dashboard }), updateHasSeenProductIntroFor: (productKey: ProductKey, value: boolean) => ({ productKey, value }), switchTeam: (teamId: string | number) => ({ teamId }), + __testOnlyOverrideThemeFromCookie: (theme: UserTheme | null) => ({ theme }), })), forms(({ actions }) => ({ userDetails: { @@ -106,6 +107,12 @@ export const userLogic = kea([ }), }, ], + themeFromCookie: [ + getCookie('theme') as UserTheme | null, + { + __testOnlyOverrideThemeFromCookie: (_, { theme }) => theme, + }, + ], }), listeners(({ actions, values }) => ({ logout: () => { @@ -241,10 +248,10 @@ export const userLogic = kea([ : [], ], - themeMode: [ - (s) => [s.user], - (user): UserTheme => { - return user?.theme_mode || 'light' + userThemeMode: [ + (s) => [s.user, s.themeFromCookie], + (user, themeFromCookie): UserTheme => { + return user?.theme_mode || themeFromCookie || 'light' }, ], }), @@ -268,4 +275,16 @@ export const userLogic = kea([ } }, })), + afterMount(({ actions }) => { + // This is needed to toggle the theme + window.__testOnlyOverrideThemeFromCookie = (theme: UserTheme | null) => + actions.__testOnlyOverrideThemeFromCookie(theme) + }), ]) + +declare global { + interface Window { + /** This is needed to change the theme from outside the React tree. */ + __testOnlyOverrideThemeFromCookie: (theme: UserTheme | null) => void + } +}
Enter a token from your authenticator app.