All files / components/ui KoreanHeaderHTML.tsx

100% Statements 7/7
59.25% Branches 16/27
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 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                                      1x                 5x 5x     5x     5x                 5x                                                                                                                                                                                                                                                                                                                                                                                                                                                                
import React, { useMemo } from "react";
import type { KoreanText } from "../../types/common";
import { FONT_FAMILY, KOREAN_COLORS } from "../../types/constants";
import { hexToRgbaString } from "../../utils/colorUtils";
import "./KoreanHeaderHTML.css";
 
export interface KoreanHeaderHTMLProps {
  readonly title: KoreanText;
  readonly subtitle?: KoreanText;
  readonly size?: "small" | "medium" | "large";
  readonly alignment?: "left" | "center" | "right";
  readonly showUnderline?: boolean;
  readonly animated?: boolean;
  readonly glowIntensity?: number;
}
 
/**
 * HTML-based KoreanHeader component for Three.js integration
 */
export const KoreanHeaderHTML: React.FC<KoreanHeaderHTMLProps> = ({
  title,
  subtitle,
  size = "medium",
  alignment = "center",
  showUnderline = true,
  animated = true,
  glowIntensity = 1.0,
}) => {
  const titleSize = size === "large" ? 32 : size === "medium" ? 24 : 18;
  const subtitleSize = titleSize * 0.7;
 
  const alignmentStyle =
    alignment === "center" ? "center" : alignment === "right" ? "flex-end" : "flex-start";
 
  // Memoize RGBA color calculations with glowIntensity
  const colors = useMemo(() => ({
    titleTextShadow: `0 3px 8px ${hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.6 * glowIntensity)}, 0 0 40px ${hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.4 * glowIntensity)}`,
    titleStroke: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_DARK, 0.8),
    subtitleTextShadow: `0 2px 4px ${hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN, 0.4 * glowIntensity)}`,
    subtitleSectionTextShadow: `0 1px 4px ${hexToRgbaString(KOREAN_COLORS.TEXT_SECONDARY, 0.3 * glowIntensity)}`,
    svgCircleFill: hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.3),
    svgCircleCenterFill: hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.6),
  }), [glowIntensity]);
 
  return (
    <div
      style={{
        display: "flex",
        flexDirection: "column",
        alignItems: alignmentStyle,
        gap: "8px",
        position: "relative",
      }}
      data-testid="korean-header"
    >
      {/* Main Korean title */}
      <div
        style={{
          fontFamily: FONT_FAMILY.KOREAN,
          fontSize: `${titleSize}px`,
          color: `#${KOREAN_COLORS.ACCENT_GOLD.toString(16).padStart(6, "0")}`,
          fontWeight: "bold",
          textAlign: alignment,
          textShadow: colors.titleTextShadow,
          animation: animated ? "pulse 2s ease-in-out infinite" : "none",
          WebkitTextStroke: `1px ${colors.titleStroke}`,
        }}
      >
        {title.korean}
      </div>
 
      {/* English subtitle */}
      <div
        style={{
          fontFamily: FONT_FAMILY.KOREAN,
          fontSize: `${titleSize * 0.6}px`,
          color: `#${KOREAN_COLORS.TEXT_TERTIARY.toString(16).padStart(6, "0")}`,
          fontStyle: "italic",
          textAlign: alignment,
          textShadow: colors.subtitleTextShadow,
          opacity: 0.9,
        }}
      >
        {title.english}
      </div>
 
      {/* Enhanced Korean traditional + cyberpunk underline */}
      {showUnderline && (
        <div
          style={{
            width: `${titleSize * 6}px`,
            height: "30px",
            position: "relative",
            marginTop: "10px",
          }}
        >
          {/* Traditional Korean curve (태극 inspired) */}
          <svg
            width={titleSize * 6}
            height={30}
            style={{
              position: "absolute",
              top: 0,
              left: 0,
            }}
          >
            {/* Main golden curve */}
            <path
              d={`M 0 8 Q ${titleSize * 1.5} 2, ${titleSize * 4.5} 14 T ${titleSize * 6} 8`}
              stroke={`#${KOREAN_COLORS.ACCENT_GOLD.toString(16).padStart(6, "0")}`}
              strokeWidth="3"
              fill="none"
              opacity="0.8"
              style={{
                animation: animated ? "glow 2s ease-in-out infinite" : "none",
              }}
            />
 
            {/* Secondary cyan accent line */}
            <path
              d={`M ${titleSize * 0.6} 11 Q ${titleSize * 1.8} 8, ${titleSize * 4.2} 17 T ${titleSize * 5.4} 11`}
              stroke={`#${KOREAN_COLORS.PRIMARY_CYAN.toString(16).padStart(6, "0")}`}
              strokeWidth="1.5"
              fill="none"
              opacity="0.6"
              style={{
                animation: animated ? "glow-alt 3s ease-in-out infinite" : "none",
              }}
            />
 
            {/* Left trigram (☰ - Heaven) */}
            <g opacity="0.4">
              <line
                x1={-8}
                y1={20}
                x2={-2}
                y2={20}
                stroke={`#${KOREAN_COLORS.ACCENT_GOLD.toString(16).padStart(6, "0")}`}
                strokeWidth="2"
              />
              <line
                x1={-8}
                y1={23}
                x2={-2}
                y2={23}
                stroke={`#${KOREAN_COLORS.ACCENT_GOLD.toString(16).padStart(6, "0")}`}
                strokeWidth="2"
              />
              <line
                x1={-8}
                y1={26}
                x2={-2}
                y2={26}
                stroke={`#${KOREAN_COLORS.ACCENT_GOLD.toString(16).padStart(6, "0")}`}
                strokeWidth="2"
              />
            </g>
 
            {/* Right trigram (☷ - Earth) - broken lines */}
            <g opacity="0.4">
              <line
                x1={titleSize * 6 + 2}
                y1={20}
                x2={titleSize * 6 + 4}
                y2={20}
                stroke={`#${KOREAN_COLORS.PRIMARY_CYAN.toString(16).padStart(6, "0")}`}
                strokeWidth="2"
              />
              <line
                x1={titleSize * 6 + 5}
                y1={20}
                x2={titleSize * 6 + 8}
                y2={20}
                stroke={`#${KOREAN_COLORS.PRIMARY_CYAN.toString(16).padStart(6, "0")}`}
                strokeWidth="2"
              />
 
              <line
                x1={titleSize * 6 + 2}
                y1={23}
                x2={titleSize * 6 + 4}
                y2={23}
                stroke={`#${KOREAN_COLORS.PRIMARY_CYAN.toString(16).padStart(6, "0")}`}
                strokeWidth="2"
              />
              <line
                x1={titleSize * 6 + 5}
                y1={23}
                x2={titleSize * 6 + 8}
                y2={23}
                stroke={`#${KOREAN_COLORS.PRIMARY_CYAN.toString(16).padStart(6, "0")}`}
                strokeWidth="2"
              />
 
              <line
                x1={titleSize * 6 + 2}
                y1={26}
                x2={titleSize * 6 + 4}
                y2={26}
                stroke={`#${KOREAN_COLORS.PRIMARY_CYAN.toString(16).padStart(6, "0")}`}
                strokeWidth="2"
              />
              <line
                x1={titleSize * 6 + 5}
                y1={26}
                x2={titleSize * 6 + 8}
                y2={26}
                stroke={`#${KOREAN_COLORS.PRIMARY_CYAN.toString(16).padStart(6, "0")}`}
                strokeWidth="2"
              />
            </g>
 
            {/* Central energy orb */}
            <circle
              cx={titleSize * 3}
              cy={14}
              r="6"
              fill={colors.svgCircleFill}
              style={{
                animation: animated ? "pulse 2.5s ease-in-out infinite" : "none",
              }}
            />
            <circle
              cx={titleSize * 3}
              cy={14}
              r="3"
              fill={colors.svgCircleCenterFill}
              style={{
                animation: animated ? "pulse 2.5s ease-in-out infinite" : "none",
              }}
            />
          </svg>
        </div>
      )}
 
      {/* Subtitle section with traditional spacing */}
      {subtitle && (
        <>
          <div
            style={{
              fontFamily: FONT_FAMILY.KOREAN,
              fontSize: `${subtitleSize}px`,
              color: `#${KOREAN_COLORS.TEXT_SECONDARY.toString(16).padStart(6, "0")}`,
              textAlign: alignment,
              textShadow: colors.subtitleSectionTextShadow,
              marginTop: "10px",
            }}
          >
            {subtitle.korean}
          </div>
          <div
            style={{
              fontFamily: FONT_FAMILY.KOREAN,
              fontSize: `${subtitleSize * 0.8}px`,
              color: `#${KOREAN_COLORS.TEXT_TERTIARY.toString(16).padStart(6, "0")}`,
              fontStyle: "italic",
              textAlign: alignment,
            }}
          >
            {subtitle.english}
          </div>
        </>
      )}
    </div>
  );
};
 
export default KoreanHeaderHTML;