Skip to content

Commit

Permalink
fix: Storybook viewMode
Browse files Browse the repository at this point in the history
Use the Storybook API and make sure TS knows about DOM
  • Loading branch information
matijs authored and Robbert committed Dec 18, 2024
1 parent d0896ee commit 2684fbb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/storybook-shared/src/StoryRootDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const StoryRootDecorator: Decorator = (Story, context) => {
//
// - Page title: https://nldesignsystem.nl/wcag/2.4.2
// - Language of the page: https://nldesignsystem.nl/wcag/3.1.1
const viewMode = typeof location !== 'undefined' ? new URLSearchParams(location.search).get('viewMode') : '';
const { viewMode } = context;

useEffect(() => {
if (viewMode === 'story' && typeof document !== 'undefined') {
if (viewMode === 'story') {
document.title = title || context.name;
document.documentElement.lang = lang;
document.documentElement.dir = dir || '';
Expand Down
1 change: 1 addition & 0 deletions packages/storybook-shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "@nl-design-system/tsconfig",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"lib": ["DOM"],
"module": "esnext",
"moduleResolution": "bundler"
}
Expand Down

0 comments on commit 2684fbb

Please sign in to comment.