inspector/clients/web/.storybook/preview.tsx
cliffhall fb4ca78726 fix lint error, build error, and apply formatting across components
Suppress react-refresh lint rule in Storybook preview config, fix
LogLevel type annotation in LoggingScreen stories, and apply consistent
formatting and layout improvements across multiple components.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 10:30:43 -04:00

69 lines
1.7 KiB
TypeScript

import type { Preview } from '@storybook/react-vite'
import { MantineProvider, useMantineColorScheme } from '@mantine/core'
import { Notifications } from '@mantine/notifications'
import '@mantine/core/styles.css'
import '@mantine/notifications/styles.css'
import '../src/App.css'
import { theme } from '../src/theme/theme'
import { useEffect } from 'react'
// eslint-disable-next-line react-refresh/only-export-components
function ColorSchemeWrapper({
colorScheme,
children,
}: {
colorScheme: 'light' | 'dark'
children: React.ReactNode
}) {
const { setColorScheme } = useMantineColorScheme()
useEffect(() => {
setColorScheme(colorScheme)
}, [colorScheme, setColorScheme])
return <>{children}</>
}
const preview: Preview = {
globalTypes: {
colorScheme: {
description: 'Mantine color scheme',
toolbar: {
title: 'Color Scheme',
icon: 'mirror',
items: [
{ value: 'light', title: 'Light', icon: 'sun' },
{ value: 'dark', title: 'Dark', icon: 'moon' },
],
dynamicTitle: true,
},
},
},
initialGlobals: {
colorScheme: 'light',
},
decorators: [
(Story, context) => (
<MantineProvider theme={theme} defaultColorScheme="light">
<ColorSchemeWrapper colorScheme={context.globals.colorScheme ?? 'light'}>
<Notifications position="top-right" />
<Story />
</ColorSchemeWrapper>
</MantineProvider>
),
],
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
a11y: {
test: 'todo',
},
layout: 'centered',
},
}
export default preview