All files / components/screens/philosophy/components PhilosophyNavigationOverlayHtml.tsx

100% Statements 6/6
100% Branches 25/25
100% Functions 3/3
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                                                                                  1x           19x           19x                                                     57x   57x                   4x                                                                                                                                                                  
import React from "react";
import { KOREAN_COLORS } from "../../../../types/constants/colors";
import { hexToRgbaString } from "../../../../utils/colorUtils";
import { BaseButtonOverlayHtml } from "../../../shared/base/BaseButtonOverlayHtml";
import type { PhilosophyTopic } from "../hooks/usePhilosophyState";
 
export interface PhilosophyNavigationProps {
  readonly currentTopic: PhilosophyTopic;
  readonly onTopicChange: (topic: PhilosophyTopic) => void;
  readonly onReturn: () => void;
  readonly isMobile?: boolean;
}
 
/**
 * Philosophy Navigation Component
 * 
 * **Korean**: 철학 네비게이션
 * 
 * Provides navigation controls for the Philosophy Screen:
 * - Topic selection (Trigrams, Values, Archetypes)
 * - Return to main menu button
 * - Keyboard shortcut hints
 * 
 * Features:
 * - Active topic highlighting
 * - Hover effects with Korean cyberpunk styling
 * - Responsive layout for mobile and desktop
 * - Accessibility with ARIA labels
 * 
 * @example
 * ```typescript
 * <PhilosophyNavigation
 *   currentTopic="trigrams"
 *   onTopicChange={(topic) => setTopic(topic)}
 *   onReturn={() => returnToMenu()}
 *   isMobile={false}
 * />
 * ```
 * 
 * @category Philosophy Components
 */
export const PhilosophyNavigation: React.FC<PhilosophyNavigationProps> = ({
  currentTopic,
  onTopicChange,
  onReturn,
  isMobile = false,
}) => {
  const topics: Array<{ id: PhilosophyTopic; korean: string; english: string }> = [
    { id: "trigrams", korean: "팔괘", english: "Trigrams" },
    { id: "values", korean: "가치관", english: "Values" },
    { id: "archetypes", korean: "무사 유형", english: "Archetypes" },
  ];
 
  return (
    <nav
      style={{
        display: "flex",
        flexDirection: isMobile ? "column" : "row",
        alignItems: "center",
        justifyContent: "space-between",
        gap: isMobile ? "15px" : "20px",
        padding: isMobile ? "15px" : "20px",
        background: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_DARK, 0.95),
        borderRadius: "10px",
        border: `2px solid ${hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.6)}`,
      }}
      role="navigation"
      aria-label="Philosophy section navigation"
      data-testid="philosophy-navigation"
    >
      {/* Topic selection buttons */}
      <div
        style={{
          display: "flex",
          flexWrap: "wrap",
          gap: "10px",
          justifyContent: isMobile ? "center" : "flex-start",
        }}
      >
        {topics.map((topic) => {
          const isActive = currentTopic === topic.id;
 
          return (
            <div
              key={topic.id}
              style={{
                position: "relative",
              }}
            >
              <BaseButtonOverlayHtml
                korean={topic.korean}
                english={topic.english}
                onClick={() => onTopicChange(topic.id)}
                variant={isActive ? "primary" : "secondary"}
                size={isMobile ? "sm" : "md"}
                isMobile={isMobile}
                testId={`topic-button-${topic.id}`}
                ariaLabel={`View ${topic.korean} ${topic.english} section`}
                ariaCurrent={isActive ? "page" : undefined}
                style={{
                  minWidth: isMobile ? "80px" : "100px",
                  boxShadow: isActive
                    ? `0 0 15px ${hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.4)}`
                    : undefined,
                }}
              />
            </div>
          );
        })}
      </div>
 
      {/* Return button and keyboard hints */}
      <div
        style={{
          display: "flex",
          flexDirection: isMobile ? "column" : "row",
          alignItems: "center",
          gap: "12px",
        }}
      >
        {/* Keyboard hints */}
        {!isMobile && (
          <div
            style={{
              display: "flex",
              gap: "8px",
              fontSize: "11px",
              color: `#${KOREAN_COLORS.TEXT_SECONDARY.toString(16).padStart(6, "0")}`,
            }}
            aria-label="Keyboard shortcuts"
          >
            <span
              style={{
                padding: "4px 8px",
                background: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_MEDIUM, 0.8),
                borderRadius: "4px",
                border: `1px solid ${hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN, 0.5)}`,
                fontWeight: "bold",
              }}
            >
              ESC
            </span>
            <span
              style={{
                padding: "4px 8px",
                background: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_MEDIUM, 0.8),
                borderRadius: "4px",
                border: `1px solid ${hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN, 0.5)}`,
                fontWeight: "bold",
              }}
            >
              M
            </span>
          </div>
        )}
 
        {/* Return button */}
        <BaseButtonOverlayHtml
          korean="돌아가기"
          english="Return"
          onClick={onReturn}
          variant="danger"
          size={isMobile ? "sm" : "md"}
          isMobile={isMobile}
          testId="return-button"
          ariaLabel="Return to main menu"
        />
      </div>
    </nav>
  );
};
 
export default PhilosophyNavigation;