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 | 2x 85x 85x 85x 85x 85x 85x 85x 61x 85x 85x 85x 50x 2x | /**
* TrainingControlsOverlayHtml - Html overlay for training controls
*
* Displays start/stop button and training status with consistent Korean theming.
* Uses KOREAN_COLORS constants and bilingual formatting.
*
* @module components/screens/training
* @category Training UI
* @korean 훈련제어오버레이
*/
import React from "react";
import {
FONT_FAMILY,
KOREAN_COLORS,
} from "../../../../types/constants";
import { SPACING } from "../../../../types/constants/ui";
import { hexToRgbaString } from "../../../../utils/colorUtils";
import {
formatBilingualText,
getEnhancedKoreanOverlayStyles,
getKoreanButtonWithGlow,
getResponsiveSpacing,
} from "../../../../utils/koreanThemeHelpers";
import {
getNeonTextShadow,
getSmoothTransition,
} from "../../../../utils/visualEffects";
import "../training.css";
/**
* Props for TrainingControlsOverlayHtml component
*/
export interface TrainingControlsOverlayHtmlProps {
/** Whether training is currently active */
readonly isTraining: boolean;
/** Callback to start training */
readonly onStartTraining: () => void;
/** Callback to stop training */
readonly onStopTraining: () => void;
/** Whether on mobile device */
readonly isMobile: boolean;
}
/**
* TrainingControlsOverlayHtml Component
*
* Html overlay showing training status and start/stop controls with Korean theming.
* All colors use KOREAN_COLORS constants for consistency.
*
* Optimized with React.memo for 60fps performance:
* - Prevents re-renders when isTraining state hasn't changed
* - Callbacks expected to be stable (parent should use useCallback)
*
* @example
* ```tsx
* <TrainingControlsOverlayHtml
* isTraining={true}
* onStartTraining={() => console.log('start')}
* onStopTraining={() => console.log('stop')}
* isMobile={false}
* />
* ```
*
* @korean 훈련제어오버레이컴포넌트
*/
export const TrainingControlsOverlayHtml = React.memo<TrainingControlsOverlayHtmlProps>(
({
isTraining,
onStartTraining,
onStopTraining,
isMobile,
}) => {
const panelWidth = isMobile ? 200 : 220;
const panelHeight = isMobile ? 90 : 100;
const padding = getResponsiveSpacing("sm", isMobile);
// Use Korean colors for border based on training state
const stateColor = isTraining ? KOREAN_COLORS.ACCENT_GREEN : KOREAN_COLORS.ACCENT_RED;
const borderColor = hexToRgbaString(stateColor, 0.9);
// Enhanced panel styles with neon glow
const panelStyle: React.CSSProperties = {
...getEnhancedKoreanOverlayStyles({
opacity: 0.88,
glowIntensity: isTraining ? "medium" : "subtle",
includeGradient: false,
includeBackdropBlur: true,
depthLayers: 2,
}),
width: `${panelWidth}px`,
height: `${panelHeight}px`,
padding: `${padding}px`,
border: `2px solid ${borderColor}`,
position: "relative",
};
// Enhanced button styles (memoized, interaction states handled internally by getKoreanButtonWithGlow)
const buttonStyles = React.useMemo(
() =>
getKoreanButtonWithGlow({
variant: isTraining ? "danger" : "success",
glowIntensity: "strong",
hoverAnimation: "combined",
}),
[isTraining]
);
const titleFontSize = isMobile ? 13 : 14;
const infoFontSize = isMobile ? 9 : 10;
return (
<div style={panelStyle} data-testid="training-controls-html">
{/* Header with bilingual status */}
<div style={{ marginBottom: `${SPACING.SM}px` }}>
<div
style={{
fontSize: `${titleFontSize}px`,
fontWeight: "bold",
color: hexToRgbaString(stateColor),
fontFamily: FONT_FAMILY.KOREAN,
textShadow: getNeonTextShadow(stateColor, isTraining ? "medium" : "subtle"),
transition: getSmoothTransition("all", "normal"),
}}
>
{formatBilingualText(
isTraining ? "훈련 진행중" : "훈련 대기",
isTraining ? "Training Active" : "Training Stopped",
"pipe"
)}
</div>
</div>
{/* Status Indicator with CSS animation */}
<div
className={`status-indicator ${isTraining ? "active" : "inactive"}`}
style={{
position: "absolute",
top: "12px",
right: "12px",
}}
/>
{/* Start/Stop Button with Korean theming */}
<button
onClick={isTraining ? onStopTraining : onStartTraining}
className={`training-button ${isTraining ? "training-button-stop" : "training-button-start"}`}
style={{
...buttonStyles,
// Note: fontSize from buttonStyles is intentionally overridden with titleFontSize
// to maintain consistent sizing with the training header/title typography
fontSize: `${titleFontSize}px`,
height: "35px",
}}
data-testid="training-toggle-button"
data-training-state={isTraining ? "active" : "inactive"}
>
<span>{isTraining ? "⏹" : "▶"}</span>
<span>
{formatBilingualText(
isTraining ? "중지" : "시작",
isTraining ? "Stop" : "Start",
"pipe"
)}
</span>
</button>
{/* Info text about auto-restart with Korean colors */}
{!isTraining && (
<div
style={{
fontSize: `${infoFontSize}px`,
color: hexToRgbaString(KOREAN_COLORS.TEXT_TERTIARY),
textAlign: "center",
marginTop: `${SPACING.XS}px`,
fontFamily: FONT_FAMILY.KOREAN,
lineHeight: "1.4",
}}
>
<div>모드 변경시 자동 재시작</div>
<div>Auto-restarts on mode change</div>
</div>
)}
</div>
);
},
(prevProps, nextProps) => {
// Re-render when training state, mobile state, or callbacks change
// Including callback props here avoids stale-closure issues where the
// component would keep calling outdated handlers that reference old state.
return (
prevProps.isTraining === nextProps.isTraining &&
prevProps.isMobile === nextProps.isMobile &&
prevProps.onStartTraining === nextProps.onStartTraining &&
prevProps.onStopTraining === nextProps.onStopTraining
);
},
);
TrainingControlsOverlayHtml.displayName = "TrainingControlsOverlayHtml";
export default TrainingControlsOverlayHtml;
|