Skip to content
Open
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
1 change: 1 addition & 0 deletions examples/storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const preview: Preview = {
layout: 'centered',
controls: {
expanded: true,
disableSaveFromUI: true,
},
options: {
storySort: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Canvas, Meta } from '@storybook/blocks';
import { Canvas, Meta, Source } from '@storybook/blocks';
import * as ShowcaseStories from './CitizenClaimWidgetShowcase.stories';
import { DocsCallout, DocsCard, DocsGrid, DocsPage, DocsSection } from '../docs/DocsLayout';

Expand All @@ -11,11 +11,35 @@ import { DocsCallout, DocsCard, DocsGrid, DocsPage, DocsSection } from '../docs/
>
<DocsSection
title="Manual wallet showcase"
description="Use this story when reviewing the widget in a browser that has an injected wallet available."
description="Use this story when reviewing the widget in a browser that has an injected wallet available. Use the Controls panel below the canvas to preview `defaultTheme` and a sample `themeOverrides` brand preset."
>
<Canvas of={ShowcaseStories.InjectedWallet} />
</DocsSection>

<DocsSection
title="How to mount it"
description="Keep the host contract narrow. The widget expects a provider and optional theming inputs."
>
<Source
dark
language="tsx"
code={`import { CitizenClaimWidget } from '@goodwidget/citizen-claim-widget'
import { MiniAppShell } from '@goodwidget/ui'

export function ClaimPanel({ provider }: { provider?: unknown }) {
return (
<MiniAppShell title="GoodDollar">
<CitizenClaimWidget
provider={provider}
environment="production"
defaultTheme="dark"
/>
</MiniAppShell>
)
}`}
/>
</DocsSection>

<DocsSection
title="QA coverage"
description="Use the QA demo when you need reproducible custodial state, Playwright screenshots, or fixture-driven debugging. Keep this page focused on the product-facing integration flow."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
import type { Meta, StoryObj } from '@storybook/react'
import { CitizenClaimWidget } from '@goodwidget/citizen-claim-widget'
import { CustodialLocalFixtureStory } from '../helpers/citizenClaimWidgetStories'
import { BRAND_PRESET_OPTIONS, brandPresetOverrides, type BrandPreset } from '../helpers/themeOverridePresets'

const meta: Meta<typeof CitizenClaimWidget> = {
interface CitizenClaimWidgetQAArgs {
defaultTheme: 'light' | 'dark'
brandPreset: BrandPreset
}

const meta: Meta<CitizenClaimWidgetQAArgs> = {
title: 'QA/CitizenClaimWidget/Runtime Fixtures',
component: CitizenClaimWidget,
tags: ['autodocs', 'qa'],
parameters: { layout: 'padded' },
argTypes: {
defaultTheme: {
control: 'radio',
options: ['dark', 'light'],
description: 'Base theme applied via the widget’s own defaultTheme prop.',
},
brandPreset: {
control: 'select',
options: BRAND_PRESET_OPTIONS,
description: 'Sample host-branding themeOverrides preset.',
},
},
args: {
defaultTheme: 'dark',
brandPreset: 'None',
},
}

export default meta
type Story = StoryObj<typeof meta>
type Story = StoryObj<CitizenClaimWidgetQAArgs>

export const CustodialLocalFixture: Story = {
render: () => <CustodialLocalFixtureStory />,
render: ({ defaultTheme, brandPreset }) => (
<CustodialLocalFixtureStory defaultTheme={defaultTheme} themeOverrides={brandPresetOverrides(brandPreset)} />
),
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
import type { Meta, StoryObj } from '@storybook/react'
import { CitizenClaimWidget } from '@goodwidget/citizen-claim-widget'
import { InjectedWalletStory } from '../helpers/citizenClaimWidgetStories'
import { BRAND_PRESET_OPTIONS, brandPresetOverrides, type BrandPreset } from '../helpers/themeOverridePresets'

const meta: Meta<typeof CitizenClaimWidget> = {
interface CitizenClaimWidgetStoryArgs {
defaultTheme: 'light' | 'dark'
brandPreset: BrandPreset
}

const meta: Meta<CitizenClaimWidgetStoryArgs> = {
title: 'Widgets/CitizenClaimWidget/Showcase',
component: CitizenClaimWidget,
tags: ['integrator', 'manual', 'showcase'],
parameters: { layout: 'padded' },
argTypes: {
defaultTheme: {
control: 'radio',
options: ['dark', 'light'],
description: 'Base theme applied via the widget’s own defaultTheme prop.',
},
brandPreset: {
control: 'select',
options: BRAND_PRESET_OPTIONS,
description: 'Sample host-branding themeOverrides preset.',
},
},
args: {
defaultTheme: 'dark',
brandPreset: 'None',
},
}

export default meta
type Story = StoryObj<typeof meta>
type Story = StoryObj<CitizenClaimWidgetStoryArgs>

export const InjectedWallet: Story = {
render: () => <InjectedWalletStory />,
render: ({ defaultTheme, brandPreset }) => (
<InjectedWalletStory defaultTheme={defaultTheme} themeOverrides={brandPresetOverrides(brandPreset)} />
),
}
8 changes: 8 additions & 0 deletions examples/storybook/src/stories/claim-widget/ClaimWidget.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Canvas, Meta, Source } from '@storybook/blocks';
import * as ClaimWidgetStories from './ClaimWidget.stories';
import * as ThemeOverridesStories from './ClaimWidgetThemeOverrides.stories';
import { DocsCallout, DocsCard, DocsGrid, DocsList, DocsPage, DocsSection } from '../docs/DocsLayout';

<Meta of={ClaimWidgetStories} />
Expand Down Expand Up @@ -36,6 +37,13 @@ import { DocsCallout, DocsCard, DocsGrid, DocsList, DocsPage, DocsSection } from
</DocsCallout>
</DocsSection>

<DocsSection
title="Theme overrides"
description="Play around with some of the theme overrides using the controls below (you may have to activate Controls in the addons panel, top-right). The code here can be copied and used directly in your own dapp — it always matches what's rendered. See the callout below the code for additional overridable styles not wired to a control."
>
<Canvas of={ThemeOverridesStories.Playground} />
</DocsSection>

<DocsSection
title="How to mount it"
description="Keep the host contract narrow. The widget expects a provider and optional theming inputs."
Expand Down
60 changes: 44 additions & 16 deletions examples/storybook/src/stories/claim-widget/ClaimWidget.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,76 @@
*/
import type { Meta, StoryObj } from '@storybook/react'
import { ClaimWidget } from '@goodwidget/claim-widget-theme-demo'
import {
ClaimWidgetStoryCanvas,
cobaltOverrides,
tealOverrides,
} from '../helpers/claimWidgetStories'
import { ClaimWidgetStoryCanvas } from '../helpers/claimWidgetStories'
import { BRAND_PRESET_OPTIONS, brandPresetOverrides, type BrandPreset } from '../helpers/themeOverridePresets'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goodWidgetProvider here sits at the top level of meta, but the decorator in .storybook/preview.tsx reads context.parameters.goodWidgetProvider, so disableProvider: true, useShell: false never actually applies to these stories. Moving it inside parameters (as every other story file does) makes it functional and also clears the TS2353 error on this file.

const meta: Meta<typeof ClaimWidget> = {
interface ClaimWidgetStoryArgs {
defaultTheme: 'light' | 'dark'
brandPreset: BrandPreset
}

const meta: Meta<ClaimWidgetStoryArgs> = {
title: 'Widgets/ClaimWidget Theme Demo/Showcase',
component: ClaimWidget,
tags: ['integrator', 'showcase'],
parameters: { layout: 'padded' },
goodWidgetProvider: {
disableProvider: true,
useShell: false,
argTypes: {
defaultTheme: {
control: 'radio',
options: ['dark', 'light'],
description: 'Base theme applied via the widget’s own defaultTheme prop.',
},
brandPreset: {
control: 'select',
options: BRAND_PRESET_OPTIONS,
description: 'Sample host-branding themeOverrides preset.',
},
},
}
export default meta

type Story = StoryObj<typeof ClaimWidget>
type Story = StoryObj<ClaimWidgetStoryArgs>

export const Default: Story = {
render: () => <ClaimWidgetStoryCanvas dataTestId="ClaimWidget-default" />,
args: { defaultTheme: 'dark', brandPreset: 'None' },
render: ({ defaultTheme, brandPreset }) => (
<ClaimWidgetStoryCanvas
dataTestId="ClaimWidget-default"
defaultTheme={defaultTheme}
themeOverrides={brandPresetOverrides(brandPreset)}
/>
),
}

export const LightTheme: Story = {
render: () => <ClaimWidgetStoryCanvas dataTestId="ClaimWidget-light" defaultTheme="light" />,
args: { defaultTheme: 'light', brandPreset: 'None' },
render: ({ defaultTheme, brandPreset }) => (
<ClaimWidgetStoryCanvas
dataTestId="ClaimWidget-light"
defaultTheme={defaultTheme}
themeOverrides={brandPresetOverrides(brandPreset)}
/>
),
}

export const CobaltBrand: Story = {
render: () => (
args: { defaultTheme: 'dark', brandPreset: 'Cobalt' },
render: ({ defaultTheme, brandPreset }) => (
<ClaimWidgetStoryCanvas
dataTestId="ClaimWidget-cobalt"
themeOverrides={cobaltOverrides}
defaultTheme={defaultTheme}
themeOverrides={brandPresetOverrides(brandPreset)}
/>
),
}

export const TealBrand: Story = {
render: () => (
args: { defaultTheme: 'dark', brandPreset: 'Teal' },
render: ({ defaultTheme, brandPreset }) => (
<ClaimWidgetStoryCanvas
dataTestId="ClaimWidget-teal"
themeOverrides={tealOverrides}
defaultTheme={defaultTheme}
themeOverrides={brandPresetOverrides(brandPreset)}
/>
),
}
Loading