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 | 13x 29x 29x 29x 29x 13x 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;
/** ARIA role for semantic HTML (default: "region") */
readonly ariaRole?: "region" | "article" | "complementary" | "navigation" | "main";
/** ARIA label for accessibility */
readonly ariaLabel?: string;
/** ARIA described by ID for additional context */
readonly ariaDescribedBy?: string;
}
/**
* BasePanel Component
*
* Enhanced Korean-themed panel with common functionality extracted.
* Uses useKoreanTheme hook for consistent styling.
*
* WCAG 2.1 AA Accessibility Features:
* - Proper ARIA roles for semantic HTML
* - ARIA labels for screen reader context
* - Responsive padding for touch targets
*
* Optimized with React.memo for performance
*
* @example
* ```tsx
* <BasePanel
* variant="bordered"
* padding={20}
* ariaRole="region"
* ariaLabel="Combat statistics panel"
* >
* <h1>Panel Content</h1>
* </BasePanel>
* ```
*/
const BasePanelComponent: React.FC<BasePanelProps> = ({
children,
position = [0, 0, 0],
width = "auto",
height = "auto",
padding = 16,
variant = "default",
testId,
isMobile = false,
ariaRole = "region",
ariaLabel,
ariaDescribedBy,
}) => {
// 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"}
role={ariaRole}
aria-label={ariaLabel}
aria-describedby={ariaDescribedBy}
>
{children}
</div>
</Html>
);
};
// Export memoized component for performance optimization
export const BasePanel = React.memo(BasePanelComponent);
BasePanel.displayName = "BasePanel";
|