Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | import type { Meta, StoryObj } from '@storybook/react' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { ThemeProvider } from '@/contexts/ThemeContext' import type { SessionMode } from '@/lib/curriculum/session-mode' import { billingKeys } from '@/lib/queryKeys' import { TIER_LIMITS, type TierName } from '@/lib/tier-limits' import type { EffectiveTierResponse } from '@/hooks/useTier' import { css } from '../../../../styled-system/css' import { StartPracticeModalProvider } from '../StartPracticeModalContext' import { PlanIndicator } from './PlanIndicator' const STUDENT_ID = 'test-student-1' function tierResponse( tier: TierName, providedBy: { name: string } | null = null ): EffectiveTierResponse { const limits = TIER_LIMITS[tier] return { tier, limits: { maxPracticeStudents: limits.maxPracticeStudents === Infinity ? null : limits.maxPracticeStudents, maxSessionMinutes: limits.maxSessionMinutes, maxSessionsPerWeek: limits.maxSessionsPerWeek === Infinity ? null : limits.maxSessionsPerWeek, maxOfflineParsingPerMonth: limits.maxOfflineParsingPerMonth, }, providedBy, } } function createSeededQueryClient(tier: TierName, providedBy: { name: string } | null = null) { const qc = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } }, }) qc.setQueryData(billingKeys.effectiveTier(STUDENT_ID), tierResponse(tier, providedBy)) return qc } const defaultSessionMode: SessionMode = { type: 'maintenance', focusDescription: 'Mixed practice', skillCount: 8, } function Wrapper({ children, tier, providedBy = null, theme = 'light', }: { children: React.ReactNode tier: TierName providedBy?: { name: string } | null theme?: 'light' | 'dark' }) { const qc = createSeededQueryClient(tier, providedBy) return ( <QueryClientProvider client={qc}> <ThemeProvider> <StartPracticeModalProvider studentId={STUDENT_ID} studentName="Sonia" focusDescription="Mixed practice" sessionMode={defaultSessionMode} secondsPerTerm={4} > <div className={css({ padding: '2rem', maxWidth: '360px' })} style={{ background: theme === 'dark' ? 'linear-gradient(150deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%)' : 'linear-gradient(150deg, #ffffff 0%, #f8fafc 60%, #f0f9ff 100%)', }} > {children} </div> </StartPracticeModalProvider> </ThemeProvider> </QueryClientProvider> ) } const meta: Meta<typeof PlanIndicator> = { title: 'Practice/StartPracticeModal/PlanIndicator', component: PlanIndicator, parameters: { layout: 'centered', nextjs: { appDirectory: true }, }, tags: ['autodocs'], } export default meta type Story = StoryObj<typeof PlanIndicator> /** * Own Family Plan — user is the subscriber. * Shows "Family Plan" badge in blue. */ export const OwnFamilyPlan: Story = { render: () => ( <Wrapper tier="family"> <PlanIndicator /> </Wrapper> ), } /** * Inherited Family Plan — another parent provides the subscription. * Shows "Using Mom's Family Plan" in blue. */ export const InheritedFamilyPlan: Story = { render: () => ( <Wrapper tier="family" providedBy={{ name: 'Mom' }}> <PlanIndicator /> </Wrapper> ), } /** * Free tier — shows limits summary + Upgrade link. */ export const FreePlan: Story = { render: () => ( <Wrapper tier="free"> <PlanIndicator /> </Wrapper> ), } /** * Guest tier — anonymous user, no upgrade link. */ export const GuestTier: Story = { render: () => ( <Wrapper tier="guest"> <PlanIndicator /> </Wrapper> ), } /** * Own Family Plan — dark mode. */ export const OwnFamilyPlanDark: Story = { render: () => ( <Wrapper tier="family" theme="dark"> <div data-theme="dark"> <PlanIndicator /> </div> </Wrapper> ), } /** * Inherited Family Plan — dark mode. */ export const InheritedFamilyPlanDark: Story = { render: () => ( <Wrapper tier="family" providedBy={{ name: 'Mom' }} theme="dark"> <div data-theme="dark"> <PlanIndicator /> </div> </Wrapper> ), } /** * Free tier — dark mode. */ export const FreePlanDark: Story = { render: () => ( <Wrapper tier="free" theme="dark"> <div data-theme="dark"> <PlanIndicator /> </div> </Wrapper> ), } |