Skip to content

Commit

Permalink
fix(storybook): body classes for story and docs pages (#2617)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdt2 authored and rise-erpelding committed May 7, 2024
1 parent 4b56bc1 commit 450ef0d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .storybook/decorators/contextsWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const withContextWrapper = makeDecorator({
name: "withContextWrapper",
parameterName: "context",
wrapper: (StoryFn, context) => {
const { args, argTypes, viewMode, id } = context;
const { args, argTypes, id, viewMode } = context;

const getDefaultValue = (type) => {
if (!type) return null;
Expand All @@ -32,6 +32,14 @@ export const withContextWrapper = makeDecorator({

useEffect(() => {
let containers = [document.body];
const container =
viewMode === "docs" &&
!window.isChromatic() &&
!id.includes("foundation")
? document.querySelector("#root-inner") ?? document.body
: document.body;

container.classList.toggle("spectrum", true);

const roots = [
...document.querySelectorAll(`#story--${id}`),
Expand Down Expand Up @@ -60,7 +68,8 @@ export const withContextWrapper = makeDecorator({
if (hasStaticElement) {
if (container.querySelector(`.${args.rootClass}--staticBlack`)) {
container.style.background = "rgb(181, 209, 211)";
} else if (container.querySelector(`.${args.rootClass}--staticWhite, .${args.rootClass}--overBackground`)) {
}
else if (container.querySelector(`.${args.rootClass}--staticWhite, .${args.rootClass}--overBackground`)) {
container.style.background = "rgb(15, 121, 125)";
}
}
Expand Down

0 comments on commit 450ef0d

Please sign in to comment.