All files / src/app/settings/sections AppearanceSettingsSection.tsx

100% Statements 80/80
100% Branches 2/2
100% Functions 2/2
100% Lines 80/80

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 811x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x  
/**
 * @file AppearanceSettingsSection.tsx
 * @module app/settings/sections/AppearanceSettingsSection
 *
 * @summary
 * Appearance settings section component.
 * Manages table density preferences with radio button group.
 *
 * @enterprise
 * - Focused on single concern: table density management
 * - Type-safe density selection
 * - i18n support for labels and descriptions
 * - Consistent styling with settings form design
 * - Full TypeDoc coverage for appearance settings
 */
 
import {
  FormControl,
  FormLabel,
  RadioGroup,
  FormControlLabel,
  Radio,
} from '@mui/material';
import { useTranslation } from 'react-i18next';
import type { TableDensity } from '../../../context/settings';
 
interface AppearanceSettingsSectionProps {
  /** Current table density value */
  tableDensity: TableDensity;
 
  /** Callback when table density changes */
  onTableDensityChange: (density: TableDensity) => void;
}
 
/**
 * Appearance settings section component.
 *
 * Provides table density selector with comfortable and compact options.
 * Isolated from other settings for independent testing and reuse.
 *
 * @param props - Component props
 * @returns JSX element rendering appearance settings controls
 *
 * @example
 * ```tsx
 * <AppearanceSettingsSection
 *   tableDensity="comfortable"
 *   onTableDensityChange={handleDensityChange}
 * />
 * ```
 */
export default function AppearanceSettingsSection({
  tableDensity,
  onTableDensityChange,
}: AppearanceSettingsSectionProps) {
  const { t } = useTranslation(['common']);
 
  return (
    <FormControl>
      <FormLabel sx={{ fontWeight: 600, mb: 1 }}>
        {t('settings.tableDensity', 'Table Density')}
      </FormLabel>
      <RadioGroup
        value={tableDensity}
        onChange={(e) => onTableDensityChange(e.target.value as TableDensity)}
      >
        <FormControlLabel
          value="comfortable"
          control={<Radio size="small" />}
          label={t('settings.tableDensity.comfortable', 'Comfortable')}
        />
        <FormControlLabel
          value="compact"
          control={<Radio size="small" />}
          label={t('settings.tableDensity.compact', 'Compact')}
        />
      </RadioGroup>
    </FormControl>
  );
}