Skip to content

Commit dcb8ca6

Browse files
authored
fix(editor): scope inline css properly (#4634)
Fixes FER-7503 ## Short description of the changes made - adds scoping to inline css ## What was the motivation & context behind this PR? - inline CSS styling was "leaking" to other parts of the app due to incorrect scoping into preview container ## How has this PR been tested? - tested locally
1 parent 07dc963 commit dcb8ca6

File tree

2 files changed

+10
-2
lines changed
  • packages
    • fern-dashboard/src/app/[orgName]/(visual-editor)/editor/[docsUrl]/[branch]/[...slug]
    • fern-docs/components/src/theming

2 files changed

+10
-2
lines changed

packages/fern-dashboard/src/app/[orgName]/(visual-editor)/editor/[docsUrl]/[branch]/[...slug]/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export default async function VisualEditorPreviewLayout({
103103
light={colors.light}
104104
dark={colors.dark}
105105
inlineCss={config.css?.inline}
106+
inlineCssScopeSelector="#preview-container, [data-testid=product-dropdown-content], [data-testid=version-dropdown-content]"
106107
scopeSelector="#preview-container @theme"
107108
lightSelector=".light #preview-container"
108109
darkSelector=".dark #preview-container"

packages/fern-docs/components/src/theming/global-styles.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function GlobalStyles({
1515
dark,
1616
fonts,
1717
inlineCss = [],
18+
inlineCssScopeSelector,
1819
scopeSelector = ":root",
1920
lightSelector = ".light, :root",
2021
darkSelector = ".dark"
@@ -25,6 +26,7 @@ export function GlobalStyles({
2526
dark?: FernColorTheme;
2627
fonts: FernFonts;
2728
inlineCss?: string[];
29+
inlineCssScopeSelector?: string;
2830
scopeSelector?: string;
2931
lightSelector?: string;
3032
darkSelector?: string;
@@ -269,8 +271,13 @@ export function GlobalStyles({
269271
270272
${fonts.additionalCss}
271273
272-
${inlineCss.join("\n")}
273-
`}
274+
${
275+
inlineCssScopeSelector
276+
? `${inlineCssScopeSelector} {
277+
${inlineCss.join("\n")}
278+
}`
279+
: `${inlineCss.join("\n")}`
280+
} `}
274281
</style>
275282
);
276283
}

0 commit comments

Comments
 (0)