-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2492 from adevinta/SPA-359
feat: extend dark mode to entire Storybook UI
- Loading branch information
Showing
10 changed files
with
210 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { memo, useEffect } from "react" | ||
|
||
import { useGlobals } from "@storybook/manager-api" | ||
|
||
export const SkinlessThemeSwitcherHandler = memo(function SkinlessThemeSwitcherHandler() { | ||
const [globals] = useGlobals() | ||
const theme = globals?.theme | ||
|
||
useEffect(() => { | ||
if (!theme) return | ||
|
||
const htmlElement = document.querySelector("html") | ||
if (htmlElement) { | ||
htmlElement.setAttribute("data-theme", theme) | ||
} | ||
|
||
const iframe = document.querySelector("#storybook-preview-iframe") | ||
if (iframe) { | ||
const iframeHtmlElement = iframe.contentDocument?.documentElement | ||
iframeHtmlElement.setAttribute("data-theme", theme) | ||
} | ||
}, [theme]) | ||
|
||
return null | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<style> | ||
body { | ||
color: var(--colors-on-background) !important; | ||
} | ||
|
||
html[data-theme='light'] { | ||
--colors-background: #ffffff; | ||
--colors-on-background: #152233; | ||
--colors-surface-inverse: #2b3441; | ||
--colors-on-surface-inverse: #ffffff; | ||
--colors-neutral-container: #f0f2f5; | ||
--colors-on-neutral-container: #3a4757; | ||
--colors-main: #ec5a13; | ||
--colors-support: #094171; | ||
--colors-on-support: #ffffff; | ||
} | ||
|
||
html[data-theme='dark'] { | ||
--colors-background: #202730; | ||
--colors-on-background: #f6f8f9; | ||
--colors-surface-inverse: #f6f8f9; | ||
--colors-on-surface-inverse: #2b3441; | ||
--colors-neutral-container: #3a4757; | ||
--colors-on-neutral-container: #f6f8f9; | ||
--colors-main: #f07b42; | ||
--colors-support: #c2e0fa; | ||
--colors-on-support: #152233; | ||
} | ||
|
||
/* === LEFT SIDEBAR === */ | ||
#storybook-explorer-tree .sidebar-item { | ||
color: var(--colors-on-background) !important; | ||
} | ||
|
||
#storybook-explorer-tree .sidebar-item[data-selected='true'] { | ||
background: var(--colors-support) !important; | ||
color: var(--colors-on-support) !important; | ||
} | ||
|
||
nav.sidebar-container { | ||
background: var(--colors-background) !important; | ||
} | ||
|
||
nav.sidebar-container input { | ||
background-color: var(--colors-neutral-container) !important; | ||
color: var(--colors-on-neutral-container) !important; | ||
} | ||
|
||
nav.sidebar-container input:focus { | ||
background-color: var(--colors-neutral-container) !important; | ||
} | ||
|
||
nav.sidebar-container [role='combobox'] svg { | ||
stroke: var(--colors-on-background) !important; | ||
} | ||
|
||
nav.sidebar-container ol[role='listbox'] mark { | ||
color: var(--colors-main) !important; | ||
} | ||
|
||
nav.sidebar-container .sidebar-subheading { | ||
color: var(--colors-on-background) !important; | ||
} | ||
|
||
/* === TOP STICKY BAR === */ | ||
.sb-bar { | ||
background: var(--colors-background) !important; | ||
color: var(--colors-on-background) !important; | ||
} | ||
|
||
.sb-bar button { | ||
background-color: var(--colors-surface-inverse) !important; | ||
color: var(--colors-on-surface-inverse) !important; | ||
} | ||
|
||
/* === THEME PICKER WIDGET (INSIDE TOP STICKY BAR) === */ | ||
[data-testid='tooltip'] { | ||
background-color: var(--colors-surface-inverse) !important; | ||
color: var(--colors-on-surface-inverse) !important; | ||
} | ||
|
||
[data-testid='tooltip'] span { | ||
color: var(--colors-on-surface-inverse) !important; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.