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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | 2x 2x 86x 86x 4x 86x 86x 86x 86x 344x 344x 344x 344x 344x 344x 344x 344x 4x 48x 2x | /**
* AnatomyControlsOverlayHtml - Html UI for toggling anatomy visualization layers
*
* Provides buttons to toggle skeleton, nerves, vascular, and surface layers
* with consistent Korean martial arts cyberpunk theming.
*
* @module components/screens/training/components/AnatomyControlsOverlayHtml
* @category Training UI
* @korean 해부학제어오버레이
*/
import React, { useCallback, useState } from "react";
import type { AnatomyLayer } from "./AnatomyOverlay3D";
import { FONT_FAMILY, KOREAN_COLORS } from "../../../../types/constants";
import { SPACING } from "../../../../types/constants/ui";
import { hexToRgbaString } from "../../../../utils/colorUtils";
import {
formatBilingualText,
getEnhancedKoreanOverlayStyles,
getResponsiveSpacing,
} from "../../../../utils/koreanThemeHelpers";
import {
getNeonTextShadow,
getSmoothTransition,
getNeonGlowEffect,
} from "../../../../utils/visualEffects";
import "../training.css";
/**
* Props for AnatomyControlsOverlayHtml component
*/
export interface AnatomyControlsOverlayHtmlProps {
/** Currently visible anatomy layers */
readonly visibleLayers: readonly AnatomyLayer[];
/** Callback when layer visibility changes */
readonly onLayerToggle: (layer: AnatomyLayer) => void;
/** Whether on mobile device */
readonly isMobile?: boolean;
}
/**
* Layer button configuration with Korean colors
*
* @korean 레이어설정
*/
interface LayerConfig {
readonly id: AnatomyLayer;
readonly korean: string;
readonly english: string;
readonly icon: string;
readonly color: number; // Numeric hex color from KOREAN_COLORS
}
const LAYER_CONFIGS: readonly LayerConfig[] = [
{
id: "skeleton",
korean: "골격",
english: "Skeleton",
icon: "🦴",
color: KOREAN_COLORS.TEXT_PRIMARY,
},
{
id: "nerves",
korean: "신경",
english: "Nerves",
icon: "⚡",
color: KOREAN_COLORS.ACCENT_GOLD,
},
{
id: "vascular",
korean: "혈관",
english: "Vascular",
icon: "❤️",
color: KOREAN_COLORS.ACCENT_RED,
},
{
id: "surface",
korean: "표면",
english: "Surface",
icon: "👤",
color: KOREAN_COLORS.PRIMARY_CYAN,
},
];
/**
* AnatomyControlsOverlayHtml Component
* UI controls for anatomy layer visibility
*/
export const AnatomyControlsOverlayHtml = React.memo<AnatomyControlsOverlayHtmlProps>(
({
visibleLayers,
onLayerToggle,
isMobile = false,
}) => {
// State for hover effects
const [hoveredLayer, setHoveredLayer] = useState<AnatomyLayer | null>(null);
const handleToggle = useCallback(
(layer: AnatomyLayer) => {
onLayerToggle(layer);
},
[onLayerToggle]
);
const panelWidth = isMobile ? 220 : 260;
const padding = getResponsiveSpacing("md", isMobile);
// Enhanced panel styles with neon glow
const panelStyle: React.CSSProperties = {
...getEnhancedKoreanOverlayStyles({
opacity: 0.88,
glowIntensity: "medium",
includeGradient: false,
includeBackdropBlur: true,
depthLayers: 3,
}),
width: `${panelWidth}px`,
padding: `${padding}px`,
};
return (
<div
style={panelStyle}
data-testid="anatomy-controls-html"
>
{/* Header with bilingual text */}
<div style={{ marginBottom: `${SPACING.MD}px` }}>
<div
style={{
fontSize: isMobile ? "14px" : "16px",
fontWeight: "bold",
color: hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN),
textShadow: getNeonTextShadow(KOREAN_COLORS.PRIMARY_CYAN, "medium"),
transition: getSmoothTransition("all", "normal"),
}}
>
{formatBilingualText("해부학 표시", "Anatomy Display", "pipe")}
</div>
</div>
{/* Layer toggle buttons */}
<div
style={{
display: "flex",
flexDirection: "column",
gap: `${SPACING.SM}px`,
}}
>
{LAYER_CONFIGS.map((config) => {
const isActive = visibleLayers.includes(config.id);
const isHovered = hoveredLayer === config.id;
const layerColor = hexToRgbaString(config.color);
const activeBackground = hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN, 0.2);
const inactiveBackground = hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_MEDIUM, 0.6);
const inactiveBorder = hexToRgbaString(KOREAN_COLORS.TEXT_TERTIARY, 0.2);
// Enhanced glow effect for active/hovered states
const glowEffect = (isActive || isHovered)
? getNeonGlowEffect(config.color, isActive ? "strong" : "medium", true)
: undefined;
return (
<button
key={config.id}
onClick={() => handleToggle(config.id)}
style={{
display: "flex",
alignItems: "center",
gap: `${SPACING.SM}px`,
background: isActive ? activeBackground : inactiveBackground,
border: `2px solid ${isActive ? layerColor : inactiveBorder}`,
borderRadius: `${SPACING.SM}px`,
padding: isMobile ? `${SPACING.SM}px ${SPACING.SM}px` : `${SPACING.SM}px ${SPACING.MD}px`,
cursor: "pointer",
transition: getSmoothTransition("all", "normal"),
fontFamily: FONT_FAMILY.KOREAN,
color: hexToRgbaString(KOREAN_COLORS.TEXT_PRIMARY),
width: "100%",
transform: isHovered ? "scale(1.03)" : "scale(1)",
boxShadow: glowEffect,
}}
onMouseEnter={() => setHoveredLayer(config.id)}
onMouseLeave={() => setHoveredLayer(null)}
data-testid={`anatomy-layer-${config.id}`}
aria-label={`Toggle ${config.english} layer`}
aria-pressed={isActive}
>
{/* Icon */}
<span
style={{
fontSize: isMobile ? "18px" : "20px",
filter: isActive ? "none" : "grayscale(100%)",
opacity: isActive ? 1 : 0.5,
}}
>
{config.icon}
</span>
{/* Labels */}
<div
style={{
flex: 1,
textAlign: "left",
}}
>
<div
style={{
fontSize: isMobile ? "12px" : "13px",
fontWeight: "bold",
color: isActive ? layerColor : hexToRgbaString(KOREAN_COLORS.TEXT_TERTIARY),
}}
>
{config.korean}
</div>
<div
style={{
fontSize: isMobile ? "9px" : "10px",
color: isActive
? hexToRgbaString(KOREAN_COLORS.TEXT_SECONDARY)
: hexToRgbaString(KOREAN_COLORS.TEXT_TERTIARY, 0.6),
}}
>
{config.english}
</div>
</div>
{/* Active indicator */}
<div
style={{
width: isMobile ? "8px" : "10px",
height: isMobile ? "8px" : "10px",
borderRadius: "50%",
background: isActive ? layerColor : hexToRgbaString(KOREAN_COLORS.TEXT_TERTIARY, 0.2),
boxShadow: isActive ? `0 0 10px ${layerColor}` : "none",
}}
/>
</button>
);
})}
</div>
{/* Info text */}
<div
style={{
marginTop: `${SPACING.MD}px`,
paddingTop: `${SPACING.MD}px`,
borderTop: `1px solid ${hexToRgbaString(KOREAN_COLORS.TEXT_TERTIARY, 0.1)}`,
fontSize: isMobile ? "9px" : "10px",
color: hexToRgbaString(KOREAN_COLORS.TEXT_TERTIARY),
textAlign: "center",
lineHeight: "1.4",
fontFamily: FONT_FAMILY.KOREAN,
}}
>
{formatBilingualText("클릭하여 표시/숨김", "Click to show/hide", "pipe")}
</div>
</div>
);
},
(prevProps, nextProps) => {
// Re-render when visible layers or callback changes
// Including callback prop prevents stale closures when parent provides
// a new function that captures updated state.
return (
prevProps.visibleLayers === nextProps.visibleLayers &&
prevProps.isMobile === nextProps.isMobile &&
prevProps.onLayerToggle === nextProps.onLayerToggle
);
});
AnatomyControlsOverlayHtml.displayName = "AnatomyControlsOverlayHtml";
export default AnatomyControlsOverlayHtml;
|