-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpreview.tsx
More file actions
41 lines (36 loc) · 1.14 KB
/
preview.tsx
File metadata and controls
41 lines (36 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, { useEffect } from "react"
import "@fontsource/charis-sil/400.css"
import "@fontsource/charis-sil/700.css"
import "@fontsource/quattrocento-sans/latin.css"
import "normalize.css"
import "src/style/global.css"
import { themeClass } from "../src/theme.css"
import { createClient, Provider } from "urql"
import { never } from "wonka"
import type { Preview } from "@storybook/react-vite"
const mockClient = createClient({
url: "http://localhost/graphql",
exchanges: [],
})
mockClient.executeQuery = (() => never) as any
mockClient.executeMutation = (() => never) as any
mockClient.executeSubscription = (() => never) as any
// Apply themeClass to document.body so Reakit portals (Dialog, etc.)
// also inherit CSS custom properties from the theme contract.
const WithTheme = (Story: React.FC) => {
useEffect(() => {
document.body.classList.add(themeClass)
return () => { document.body.classList.remove(themeClass) }
}, [])
return (
<Provider value={mockClient}>
<div className={themeClass}>
<Story />
</div>
</Provider>
)
}
const preview: Preview = {
decorators: [WithTheme],
};
export default preview