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

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

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

import * as Slider from '@radix-ui/react-slider'
import { css } from '@styled/css'
import { stack } from '@styled/patterns'
import { useWorksheetConfig } from '../WorksheetConfigContext'
import { useTheme } from '@/contexts/ThemeContext'

export function RegroupingFrequencyPanel() {
  const { formState, onChange } = useWorksheetConfig()
  const { resolvedTheme } = useTheme()
  const isDark = resolvedTheme === 'dark'
  return (
    <div
      data-section="regrouping"
      className={css({
        bg: isDark ? 'gray.800' : 'gray.50',
        border: '1px solid',
        borderColor: isDark ? 'gray.600' : 'gray.200',
        rounded: 'xl',
        p: '3',
      })}
    >
      <div className={stack({ gap: '2.5' })}>
        <div
          className={css({
            fontSize: 'xs',
            fontWeight: 'semibold',
            color: isDark ? 'gray.400' : 'gray.500',
            textTransform: 'uppercase',
            letterSpacing: 'wider',
          })}
        >
          Regrouping Frequency
        </div>

        {/* Current values display */}
        <div
          className={css({
            display: 'flex',
            justifyContent: 'space-between',
            fontSize: 'xs',
            color: isDark ? 'gray.400' : 'gray.600',
          })}
        >
          <div>
            Both:{' '}
            <span
              className={css({
                color: 'brand.600',
                fontWeight: 'semibold',
              })}
            >
              {Math.round((formState.pAllStart || 0) * 100)}%
            </span>
          </div>
          <div>
            Any:{' '}
            <span
              className={css({
                color: 'brand.600',
                fontWeight: 'semibold',
              })}
            >
              {Math.round((formState.pAnyStart || 0.25) * 100)}%
            </span>
          </div>
        </div>

        {/* Double-thumbed range slider */}
        <Slider.Root
          className={css({
            position: 'relative',
            display: 'flex',
            alignItems: 'center',
            userSelect: 'none',
            touchAction: 'none',
            width: 'full',
            height: '6',
          })}
          value={[(formState.pAllStart || 0) * 100, (formState.pAnyStart || 0.25) * 100]}
          onValueChange={(values) => {
            onChange({
              pAllStart: values[0] / 100,
              pAnyStart: values[1] / 100,
            })
          }}
          min={0}
          max={100}
          step={5}
          minStepsBetweenThumbs={0}
        >
          <Slider.Track
            className={css({
              position: 'relative',
              flexGrow: 1,
              bg: isDark ? 'gray.600' : 'gray.200',
              rounded: 'full',
              height: '1.5',
            })}
          >
            <Slider.Range
              className={css({
                position: 'absolute',
                bg: 'brand.500',
                rounded: 'full',
                height: 'full',
              })}
            />
          </Slider.Track>
          <Slider.Thumb
            className={css({
              display: 'block',
              width: '3.5',
              height: '3.5',
              bg: 'white',
              boxShadow: '0 2px 4px rgba(0,0,0,0.15)',
              rounded: 'full',
              border: '2px solid',
              borderColor: 'brand.500',
              cursor: 'pointer',
              _hover: { transform: 'scale(1.1)' },
              _focus: {
                outline: 'none',
                boxShadow: '0 0 0 3px rgba(59, 130, 246, 0.3)',
              },
            })}
          />
          <Slider.Thumb
            className={css({
              display: 'block',
              width: '3.5',
              height: '3.5',
              bg: 'white',
              boxShadow: '0 2px 4px rgba(0,0,0,0.15)',
              rounded: 'full',
              border: '2px solid',
              borderColor: 'brand.600',
              cursor: 'pointer',
              _hover: { transform: 'scale(1.1)' },
              _focus: {
                outline: 'none',
                boxShadow: '0 0 0 3px rgba(59, 130, 246, 0.3)',
              },
            })}
          />
        </Slider.Root>

        <div
          className={css({
            fontSize: '2xs',
            color: isDark ? 'gray.400' : 'gray.500',
            lineHeight: '1.3',
          })}
        >
          Regrouping difficulty at worksheet start (Both = all columns regroup, Any = at least one
          column regroups)
        </div>
      </div>
    </div>
  )
}