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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | import type { Meta, StoryObj } from '@storybook/react' import { useState } from 'react' import { RuleDropdown } from './RuleDropdown' import type { RuleMode } from '../../displayRules' const meta = { title: 'Worksheets/Config Panel/RuleDropdown', component: RuleDropdown, parameters: { layout: 'padded', }, tags: ['autodocs'], } satisfies Meta<typeof RuleDropdown> export default meta type Story = StoryObj<typeof meta> // Wrapper to handle state function DropdownWrapper( args: Omit<React.ComponentProps<typeof RuleDropdown>, 'onChange'> & { onChange?: (value: RuleMode) => void } ) { const [value, setValue] = useState<RuleMode>(args.value) return <RuleDropdown {...args} value={value} onChange={setValue} /> } export const AlwaysSelectedLight: Story = { render: (args) => <DropdownWrapper {...args} />, args: { label: 'Ten-Frame Diagrams', description: 'When should ten-frame visual aids be displayed?', value: 'always', isDark: false, }, } export const NeverSelectedLight: Story = { render: (args) => <DropdownWrapper {...args} />, args: { label: 'Carry Notation Boxes', description: 'When should carry notation be shown?', value: 'never', isDark: false, }, } export const WhenRegroupingLight: Story = { render: (args) => <DropdownWrapper {...args} />, args: { label: 'Place Value Colors', description: 'When should color-coding be applied?', value: 'whenRegrouping', isDark: false, }, } export const AlwaysSelectedDark: Story = { render: (args) => <DropdownWrapper {...args} />, args: { label: 'Ten-Frame Diagrams', description: 'When should ten-frame visual aids be displayed?', value: 'always', isDark: true, }, parameters: { backgrounds: { default: 'dark' }, }, } export const NeverSelectedDark: Story = { render: (args) => <DropdownWrapper {...args} />, args: { label: 'Carry Notation Boxes', description: 'When should carry notation be shown?', value: 'never', isDark: true, }, parameters: { backgrounds: { default: 'dark' }, }, } export const MultipleDropdowns: Story = { args: { label: 'Display Rules', description: 'Multiple dropdowns', value: 'always' }, render: () => { const [rules, setRules] = useState({ tenFrames: 'always' as RuleMode, carryBoxes: 'whenRegrouping' as RuleMode, placeValueColors: 'never' as RuleMode, answerBoxes: 'always' as RuleMode, }) return ( <div style={{ display: 'flex', flexDirection: 'column', gap: '16px', maxWidth: '400px', }} > <h3 style={{ margin: 0, fontSize: '14px', fontWeight: 600 }}>Display Rules</h3> <RuleDropdown label="Ten-Frame Diagrams" description="Visual representations using ten-frames" value={rules.tenFrames} onChange={(value) => setRules({ ...rules, tenFrames: value })} /> <RuleDropdown label="Carry Notation Boxes" description="Small boxes above columns for carrying" value={rules.carryBoxes} onChange={(value) => setRules({ ...rules, carryBoxes: value })} /> <RuleDropdown label="Place Value Colors" description="Color-code digits by place value (ones, tens, hundreds)" value={rules.placeValueColors} onChange={(value) => setRules({ ...rules, placeValueColors: value })} /> <RuleDropdown label="Answer Entry Boxes" description="Boxes for students to write answers" value={rules.answerBoxes} onChange={(value) => setRules({ ...rules, answerBoxes: value })} /> <div style={{ marginTop: '8px', padding: '12px', background: '#f3f4f6', borderRadius: '6px', fontSize: '12px', }} > <strong>Current Configuration:</strong> <pre style={{ margin: '8px 0 0 0', fontSize: '10px', whiteSpace: 'pre-wrap', }} > {JSON.stringify(rules, null, 2)} </pre> </div> </div> ) }, } export const AllOptions: Story = { args: { label: 'All Options', description: 'All rule modes', value: 'always' }, render: () => { const options: Array<{ value: RuleMode; label: string }> = [ { value: 'always', label: 'Always' }, { value: 'never', label: 'Never' }, { value: 'whenRegrouping', label: 'When Regrouping' }, { value: 'whenMultipleRegroups', label: 'Multiple Regroups' }, { value: 'when3PlusDigits', label: '3+ Digits' }, ] return ( <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '16px', maxWidth: '800px', }} > {options.map((option) => ( <DropdownWrapper key={option.value} label={`${option.label} Example`} description={`This dropdown is set to "${option.label}"`} value={option.value} /> ))} </div> ) }, } export const LongLabel: Story = { render: (args) => <DropdownWrapper {...args} />, args: { label: 'Ten-Frame Diagrams for Visual Number Representation', description: 'Determine when ten-frame visual aids should be displayed to help students understand number composition and place value. Ten-frames are particularly effective for students in early elementary grades.', value: 'always', isDark: false, }, } |