Skip to content

Commit 658eaba

Browse files
committed
[test] Fix Dev Overlay Storybook
1 parent ee94be9 commit 658eaba

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import type { Preview } from '@storybook/react'
2+
import { useInsertionEffect } from 'react'
3+
4+
function CreatePortalNode() {
5+
useInsertionEffect(() => {
6+
const portalNode = document.createElement('nextjs-portal')
7+
portalNode.setAttribute('data-testid', 'nextjs-portal')
8+
document.body.appendChild(portalNode)
9+
10+
return () => {
11+
document.body.removeChild(portalNode)
12+
}
13+
})
14+
15+
return null
16+
}
17+
18+
const preview: Preview = {
19+
parameters: {
20+
a11y: {
21+
element: 'nextjs-portal',
22+
},
23+
controls: {
24+
matchers: {
25+
color: /(background|color)$/i,
26+
date: /Date$/i,
27+
},
28+
},
29+
backgrounds: {
30+
values: [
31+
{ name: 'backdrop', value: 'rgba(250, 250, 250, 0.80)' },
32+
{ name: 'background-100-light', value: '#ffffff' },
33+
{ name: 'background-200-light', value: '#fafafa' },
34+
{ name: 'background-100-dark', value: '#0a0a0a' },
35+
{ name: 'background-200-dark', value: '#000000' },
36+
],
37+
default: 'backdrop',
38+
},
39+
},
40+
globals: {
41+
a11y: {
42+
// Optional flag to prevent the automatic check
43+
manual: true,
44+
},
45+
},
46+
decorators: [
47+
(Story) => (
48+
<>
49+
<CreatePortalNode />
50+
<Story />
51+
</>
52+
),
53+
],
54+
}
55+
56+
export default preview

0 commit comments

Comments
 (0)