All files / web/src/app/abacus-test page.tsx

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

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                                                                                                                                                                                                                     
'use client'

import { AbacusReact } from '@soroban/abacus-react'
import { useState } from 'react'
import { css } from '../../../styled-system/css'

export default function AbacusTestPage() {
  const [value, setValue] = useState(0)
  const [debugInfo, setDebugInfo] = useState<string>('')

  const handleValueChange = (newValue: number | bigint) => {
    setValue(Number(newValue))
    setDebugInfo(`Value changed to: ${newValue}`)
    console.log('Abacus value:', newValue)
  }

  return (
    <div
      className={css({
        position: 'fixed',
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
        bg: 'gray.50',
        display: 'flex',
        flexDirection: 'column',
        alignItems: 'center',
        justifyContent: 'center',
        padding: '4',
      })}
    >
      {/* Debug info */}
      <div
        className={css({
          position: 'absolute',
          top: '4',
          left: '4',
          bg: 'white',
          p: '3',
          rounded: 'md',
          border: '1px solid',
          borderColor: 'gray.300',
          fontSize: 'sm',
          fontFamily: 'mono',
        })}
      >
        <div>Current Value: {value}</div>
        <div>{debugInfo}</div>
        <button
          onClick={() => setValue(0)}
          className={css({
            mt: '2',
            px: '2',
            py: '1',
            bg: 'blue.500',
            color: 'white',
            rounded: 'sm',
            fontSize: 'xs',
            cursor: 'pointer',
          })}
        >
          Reset to 0
        </button>
        <button
          onClick={() => setValue(12345)}
          className={css({
            mt: '1',
            px: '2',
            py: '1',
            bg: 'green.500',
            color: 'white',
            rounded: 'sm',
            fontSize: 'xs',
            cursor: 'pointer',
          })}
        >
          Set to 12345
        </button>
      </div>

      <div
        style={{
          width: '100%',
          height: '100%',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
        }}
      >
        <AbacusReact
          value={value}
          columns={5}
          beadShape="diamond"
          colorScheme="place-value"
          hideInactiveBeads={false}
          scaleFactor={3.0}
          interactive={true}
          showNumbers={true}
          animated={true}
          onValueChange={handleValueChange}
        />
      </div>
    </div>
  )
}