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 | 1x 1x 9x 9x 1x 9x 2x 9x 9x 1x 1x 9x 9x 9x | /**
* ErrorModal - Korean-themed error dialog component
* Provides user-friendly error recovery with retry functionality
* Follows Korean cyberpunk aesthetic and accessibility best practices
*
* Now uses BaseButtonHTML for consistent Korean theming
*/
import React, { useCallback, useEffect, useRef } from "react";
import { KOREAN_COLORS, FONT_FAMILY } from "../../../types/constants";
import { toHex } from "../../../utils/colorUtils";
import { BaseButtonHTML } from "../base";
interface ErrorModalProps {
readonly message: string;
readonly onRetry: () => void;
readonly onContinue: () => void;
}
// Pre-compute hex colors from Korean color constants
const HEX_COLORS = {
PRIMARY_CYAN: toHex(KOREAN_COLORS.PRIMARY_CYAN),
ACCENT_GOLD: toHex(KOREAN_COLORS.ACCENT_GOLD),
UI_BACKGROUND_DARK: toHex(KOREAN_COLORS.UI_BACKGROUND_DARK),
TEXT_ERROR: toHex(KOREAN_COLORS.TEXT_ERROR),
} as const;
/**
* Error modal component with Korean cyberpunk styling
* Provides retry and continue options for graceful error recovery
* Includes keyboard navigation
*/
export const ErrorModal: React.FC<ErrorModalProps> = ({
message,
onRetry,
onContinue,
}) => {
const containerRef = useRef<HTMLDivElement>(null);
const handleRetry = useCallback(() => {
onRetry();
}, [onRetry]);
const handleContinue = useCallback(() => {
onContinue();
}, [onContinue]);
// Handle keyboard events (Escape key to close)
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
Eif (e.key === 'Escape') {
handleContinue();
}
};
document.addEventListener('keydown', handleKeyDown);
return () => document.removeEventListener('keydown', handleKeyDown);
}, [handleContinue]);
return (
<div
role="alertdialog"
aria-labelledby="error-modal-title"
aria-describedby="error-modal-description"
style={{
position: "fixed",
top: 0,
left: 0,
width: "100%",
height: "100%",
backgroundColor: "rgba(0, 0, 0, 0.8)",
display: "flex",
alignItems: "center",
justifyContent: "center",
zIndex: 9999,
fontFamily: FONT_FAMILY.CYBER,
}}
data-testid="error-modal"
>
<div
style={{
backgroundColor: `#${HEX_COLORS.UI_BACKGROUND_DARK}`,
border: `2px solid #${HEX_COLORS.TEXT_ERROR}`,
borderRadius: "8px",
padding: "32px",
maxWidth: "500px",
boxShadow: `0 8px 32px #${HEX_COLORS.TEXT_ERROR}40`,
}}
>
{/* Error Icon */}
<div
style={{
textAlign: "center",
fontSize: "48px",
marginBottom: "16px",
}}
aria-hidden="true"
>
⚠️
</div>
{/* Title */}
<h2
id="error-modal-title"
style={{
color: `#${HEX_COLORS.TEXT_ERROR}`,
fontSize: "24px",
fontWeight: "bold",
textAlign: "center",
marginBottom: "16px",
}}
>
오류 발생 | Error Occurred
</h2>
{/* Message */}
<p
id="error-modal-description"
style={{
color: `#${HEX_COLORS.PRIMARY_CYAN}`,
fontSize: "16px",
textAlign: "center",
marginBottom: "32px",
lineHeight: "1.5",
}}
>
{message}
</p>
{/* Action Buttons - Now using BaseButtonHTML */}
<div
ref={containerRef}
style={{
display: "flex",
gap: "16px",
justifyContent: "center",
}}
>
<BaseButtonHTML
korean="재시도"
english="Retry"
onClick={handleRetry}
variant="primary"
size="md"
testId="error-modal-retry"
autoFocus={true}
/>
<BaseButtonHTML
korean="무음으로 계속"
english="Continue Without Sound"
onClick={handleContinue}
variant="secondary"
size="md"
testId="error-modal-continue"
/>
</div>
</div>
</div>
);
};
export default ErrorModal;
|