All files / web/src/app/create/worksheets/components/config-panel SkillConfigurationModal.stories.tsx

0% Statements 0/143
0% Branches 0/1
0% Functions 0/1
0% Lines 0/143

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                                                                                                                                                                                                                                                                                               
import type { Meta, StoryObj } from '@storybook/react'
import { useState } from 'react'
import { SkillConfigurationModal } from './SkillConfigurationModal'
import { DIFFICULTY_PROFILES } from '../../difficultyProfiles'

const meta = {
  title: 'Worksheets/Config Panel/SkillConfigurationModal',
  component: SkillConfigurationModal,
  parameters: {
    layout: 'centered',
  },
  tags: ['autodocs'],
} satisfies Meta<typeof SkillConfigurationModal>

export default meta
type Story = StoryObj<typeof meta>

// Wrapper component to manage modal state
function ModalWrapper(args: React.ComponentProps<typeof SkillConfigurationModal>) {
  const [open, setOpen] = useState(true)

  return (
    <>
      <button
        type="button"
        onClick={() => setOpen(true)}
        style={{
          padding: '12px 24px',
          background: '#3b82f6',
          color: 'white',
          border: 'none',
          borderRadius: '6px',
          cursor: 'pointer',
          fontSize: '14px',
          fontWeight: '500',
        }}
      >
        Open Modal
      </button>
      <SkillConfigurationModal {...args} open={open} onClose={() => setOpen(false)} />
    </>
  )
}

export const CreateMode: Story = {
  render: (args) => <ModalWrapper {...args} />,
  args: {
    open: true,
    mode: 'create',
    operator: 'addition',
    onSave: (config) => {
      console.log('Created skill:', config)
    },
  },
}

export const EditModeEarlyLearner: Story = {
  render: (args) => <ModalWrapper {...args} />,
  args: {
    open: true,
    mode: 'edit',
    operator: 'addition',
    existingConfig: {
      name: 'Early Learner Addition',
      description: 'Simple addition with lots of scaffolding',
      digitRange: { min: 2, max: 2 },
      regroupingConfig: DIFFICULTY_PROFILES.earlyLearner.regrouping,
      displayRules: DIFFICULTY_PROFILES.earlyLearner.displayRules,
    },
    onSave: (config) => {
      console.log('Updated skill:', config)
    },
  },
}

export const EditModeIntermediate: Story = {
  render: (args) => <ModalWrapper {...args} />,
  args: {
    open: true,
    mode: 'edit',
    operator: 'addition',
    existingConfig: {
      name: 'Intermediate Addition',
      description: 'Moderate difficulty with some scaffolding',
      digitRange: { min: 2, max: 3 },
      regroupingConfig: DIFFICULTY_PROFILES.intermediate.regrouping,
      displayRules: DIFFICULTY_PROFILES.intermediate.displayRules,
    },
    onSave: (config) => {
      console.log('Updated skill:', config)
    },
  },
}

export const EditModeExpert: Story = {
  render: (args) => <ModalWrapper {...args} />,
  args: {
    open: true,
    mode: 'edit',
    operator: 'subtraction',
    existingConfig: {
      name: 'Expert Subtraction',
      description: 'Advanced subtraction with minimal support',
      digitRange: { min: 3, max: 4 },
      regroupingConfig: DIFFICULTY_PROFILES.expert.regrouping,
      displayRules: DIFFICULTY_PROFILES.expert.displayRules,
    },
    onSave: (config) => {
      console.log('Updated skill:', config)
    },
  },
}

export const CustomConfiguration: Story = {
  render: (args) => <ModalWrapper {...args} />,
  args: {
    open: true,
    mode: 'edit',
    operator: 'addition',
    existingConfig: {
      name: 'Custom Skill',
      description: 'My customized difficulty settings',
      digitRange: { min: 2, max: 4 },
      regroupingConfig: {
        pAnyStart: 0.5,
        pAllStart: 0.1,
      },
      displayRules: {
        carryBoxes: 'whenRegrouping',
        answerBoxes: 'always',
        placeValueColors: 'whenRegrouping',
        tenFrames: 'never',
        problemNumbers: 'always',
        cellBorders: 'always',
        borrowNotation: 'never',
        borrowingHints: 'never',
      },
    },
    onSave: (config) => {
      console.log('Updated custom skill:', config)
    },
  },
}