All files / components/shared/base BasePanel.tsx

100% Statements 6/6
100% Branches 8/8
100% Functions 2/2
100% Lines 6/6

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                                                                                13x                     12x           12x 12x                       12x                 13x  
/**
 * BasePanel - Enhanced panel component with Korean theming
 * 
 * Builds on existing KoreanPanel with extracted common logic
 * Provides consistent panel styling across the application
 * 
 * @module components/base
 */
 
import { Html } from "@react-three/drei";
import React, { useMemo } from "react";
import { useKoreanTheme } from "./useKoreanTheme";
 
/**
 * Props for BasePanel component
 */
export interface BasePanelProps {
  readonly children: React.ReactNode;
  readonly position?: [number, number, number];
  readonly width?: number | string;
  readonly height?: number | string;
  readonly padding?: number;
  readonly variant?: "default" | "bordered" | "elevated";
  readonly testId?: string;
  readonly isMobile?: boolean;
}
 
/**
 * BasePanel Component
 * 
 * Enhanced Korean-themed panel with common functionality extracted.
 * Uses useKoreanTheme hook for consistent styling.
 * 
 * @example
 * ```tsx
 * <BasePanel variant="bordered" padding={20}>
 *   <h1>Panel Content</h1>
 * </BasePanel>
 * ```
 */
export const BasePanel: React.FC<BasePanelProps> = ({
  children,
  position = [0, 0, 0],
  width = "auto",
  height = "auto",
  padding = 16,
  variant = "default",
  testId,
  isMobile = false,
}) => {
  // Use Korean theme hook for consistent styling
  const { panelVariant, fontFamily } = useKoreanTheme({
    variant,
    isMobile,
  });
 
  // Memoize panel styles for performance
  const panelStyle = useMemo<React.CSSProperties>(() => {
    return {
      width,
      height,
      padding: `${padding}px`,
      borderRadius: "8px",
      fontFamily: fontFamily.KOREAN,
      background: panelVariant.background,
      border: panelVariant.border,
      boxShadow: panelVariant.boxShadow,
    };
  }, [width, height, padding, panelVariant, fontFamily]);
 
  return (
    <Html position={position} center>
      <div style={panelStyle} data-testid={testId ?? "base-panel"}>
        {children}
      </div>
    </Html>
  );
};
 
BasePanel.displayName = "BasePanel";