Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ playwright/.auth

*storybook.log
storybook-static

# Tamagui compiler cache
.tamagui
10 changes: 9 additions & 1 deletion frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ const config: StorybookConfig = {
'@storybook/addon-vitest'
],
framework: '@storybook/react-vite',
viteFinal: async (config) => {
viteFinal: async (config, options) => {
// Only the static build (deployed to GitHub Pages under the repo name)
// needs this subpath base. Dev server and @storybook/addon-vitest's
// browser test runner both reuse this same viteFinal, and serving them
// under a non-root base breaks the vitest browser client's handshake
// with the page (it times out with "Failed to connect to the browser
// session"), so leave base untouched outside of production builds.
if (options.configType === 'PRODUCTION') {
config.base = '/ProgressRPG/storybook/';
}
return config;
}
};
Expand Down
34 changes: 29 additions & 5 deletions frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
import type { Preview } from '@storybook/react-vite';
import { TamaguiProvider } from 'tamagui';
import tamaguiConfig from '../tamagui.config';
import '../src/styles/main.scss';
import { withQueryClient } from './decorators/withQueryClient';
import { TooltipProvider } from '../src/components/Tooltip/Tooltip';

const preview: Preview = {
// Global so any component that calls a TanStack Query hook - directly or
// transitively (e.g. `useFeatureFlag` -> `useAppConfig`) - doesn't crash
// for lack of a QueryClientProvider ancestor. See withQueryClient's
// comment for how a story seeds its own query data.
decorators: [withQueryClient],
decorators: [
// Global so any component that calls a TanStack Query hook - directly or
// transitively (e.g. `useFeatureFlag` -> `useAppConfig`) - doesn't crash
// for lack of a QueryClientProvider ancestor. See withQueryClient's
// comment for how a story seeds its own query data.
withQueryClient,
// Mirrors the app root (src/main.tsx) so components adopting Tamagui
// primitives (starting with ProgressBar, #580) render correctly here too,
// rather than every future story needing its own wrap.
(Story) => (
<TamaguiProvider config={tamaguiConfig} defaultTheme="light">
<Story />
</TamaguiProvider>
),
// Global (rather than living on Tooltip.stories.tsx's meta.decorators)
// so it also covers the autodocs-generated Docs page, which renders the
// component through its own preview pathway and doesn't reliably pick up
// meta-level decorators - without this, Tooltip's Radix primitives throw
// "must be used within TooltipProvider" there even though every actual
// story works fine.
(Story) => (
<TooltipProvider>
<Story />
</TooltipProvider>
),
],
parameters: {
controls: {
matchers: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { defineConfig, globalIgnores } from 'eslint/config'
import tseslint from 'typescript-eslint'

export default defineConfig([
globalIgnores(['dist', 'storybook-static', 'tests/', 'src/pages/RegisterPage/RegisterPage.backup.jsx']),
globalIgnores(['dist', 'storybook-static', 'tests/', 'src/pages/RegisterPage/RegisterPage.backup.jsx', '.tamagui']),
{
files: ['**/*.{js,jsx}'],
extends: [
Expand Down
Loading
Loading