All files / web/src/components/practice PracticeHelpOverlay.stories.tsx

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

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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213                                                                                                                                                                                                                                                                                                                                                                                                                                         
import type { Meta, StoryObj } from '@storybook/react'
import { useCallback, useState } from 'react'
import { css } from '../../../styled-system/css'
import { PracticeHelpOverlay } from './PracticeHelpOverlay'

const meta: Meta<typeof PracticeHelpOverlay> = {
  title: 'Practice/PracticeHelpOverlay',
  component: PracticeHelpOverlay,
  parameters: {
    layout: 'centered',
  },
  tags: ['autodocs'],
}

export default meta
type Story = StoryObj<typeof PracticeHelpOverlay>

/**
 * Interactive demo showing the help overlay with time-based escalation
 */
function InteractiveDemo() {
  const [currentValue, setCurrentValue] = useState(13)
  const [targetValue] = useState(33) // 13 + 20
  const [completed, setCompleted] = useState(false)

  const handleTargetReached = useCallback(() => {
    setCompleted(true)
    console.log('Target reached!')
    // After celebration, could reset or advance
    setTimeout(() => {
      setCompleted(false)
      setCurrentValue(33)
    }, 1000)
  }, [])

  return (
    <div
      className={css({
        display: 'flex',
        flexDirection: 'column',
        alignItems: 'center',
        gap: '1rem',
        padding: '2rem',
        maxWidth: '500px',
      })}
    >
      <div
        className={css({
          textAlign: 'center',
          marginBottom: '1rem',
        })}
      >
        <h3
          className={css({
            fontSize: '1.25rem',
            fontWeight: 'bold',
            marginBottom: '0.5rem',
          })}
        >
          Progressive Help Overlay Demo
        </h3>
        <p className={css({ fontSize: '0.875rem', color: 'gray.500' })}>
          Just the abacus with arrows. Bead tooltip appears after 3s (debug timing).
        </p>
        <p className={css({ fontSize: '0.75rem', color: 'gray.400' })}>
          Tooltip uses same system as TutorialPlayer.
        </p>
      </div>

      {/* Simulating how it appears in ActiveSession - with "Adding: +20" badge above */}
      <div
        className={css({
          display: 'flex',
          flexDirection: 'column',
          alignItems: 'center',
          gap: '0.5rem',
        })}
      >
        <div
          className={css({
            display: 'inline-flex',
            alignItems: 'center',
            gap: '0.5rem',
            padding: '0.25rem 0.75rem',
            backgroundColor: 'purple.100',
            borderRadius: '20px',
            fontSize: '0.875rem',
            fontWeight: 'bold',
            color: 'purple.700',
          })}
        >
          <span>Adding:</span>
          <span className={css({ fontFamily: 'monospace', fontSize: '1rem' })}>+20</span>
        </div>

        {!completed && (
          <PracticeHelpOverlay
            currentValue={currentValue}
            targetValue={targetValue}
            columns={3}
            onTargetReached={handleTargetReached}
            debugTiming={true}
          />
        )}
      </div>

      {completed && (
        <div
          className={css({
            padding: '2rem',
            backgroundColor: 'green.100',
            borderRadius: '12px',
            textAlign: 'center',
          })}
        >
          <span className={css({ fontSize: '2rem' })}>🎉</span>
          <p
            className={css({
              fontSize: '1rem',
              color: 'green.700',
              fontWeight: 'bold',
            })}
          >
            Target Reached!
          </p>
        </div>
      )}
    </div>
  )
}

export const Interactive: Story = {
  render: () => <InteractiveDemo />,
}

/**
 * Shows just the abacus overlay without any surrounding UI
 */
function MinimalDemo() {
  return (
    <div
      className={css({
        display: 'flex',
        flexDirection: 'column',
        gap: '2rem',
        padding: '2rem',
      })}
    >
      <div className={css({ textAlign: 'center' })}>
        <h3
          className={css({
            fontSize: '0.875rem',
            fontWeight: 'bold',
            color: 'gray.500',
            marginBottom: '0.5rem',
          })}
        >
          Minimal: Just the Abacus
        </h3>
        <PracticeHelpOverlay currentValue={0} targetValue={23} columns={3} debugTiming={true} />
      </div>
    </div>
  )
}

export const Minimal: Story = {
  render: () => <MinimalDemo />,
}

// Static examples
export const Simple: Story = {
  args: {
    currentValue: 0,
    targetValue: 5,
    columns: 3,
    debugTiming: true,
  },
}

export const TwoDigit: Story = {
  args: {
    currentValue: 23,
    targetValue: 68,
    columns: 3,
    debugTiming: true,
  },
}

export const ThreeDigit: Story = {
  args: {
    currentValue: 123,
    targetValue: 456,
    columns: 3,
    debugTiming: true,
  },
}

export const ProductionTiming: Story = {
  args: {
    currentValue: 13,
    targetValue: 33,
    columns: 3,
    debugTiming: false, // Use production timing (10s for tooltip)
  },
  parameters: {
    docs: {
      description: {
        story: 'Uses production timing: Bead tooltip at 10s',
      },
    },
  },
}