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 | 1x 15x 15x 15x 120x 120x 120x 6x 4x 4x 4x 4x 1x 1x 1x 1x | import React from "react";
import { TRIGRAM_DATA, TRIGRAM_STANCES_ORDER } from "../../../../systems/trigram/types";
import { TrigramStance } from "../../../../types";
import { KOREAN_COLORS } from "../../../../types/constants/colors";
import { hexToRgbaString } from "../../../../utils/colorUtils";
export interface InteractiveTrigramGridProps {
readonly selectedTrigram: TrigramStance | null;
readonly onTrigramSelect: (stance: TrigramStance) => void;
readonly isMobile?: boolean;
}
/**
* Interactive Trigram Grid Component
*
* **Korean**: 인터랙티브 트라이그램 그리드
*
* Displays a clickable grid of all eight trigrams with:
* - 2x4 or 4x2 responsive grid layout
* - Visual selection indicators
* - Hover effects with Korean cyberpunk styling
* - Bilingual labels (Korean | English)
* - Accessible keyboard navigation
*
* Features:
* - Theme colors from TRIGRAM_DATA
* - Smooth transitions and animations
* - Touch-friendly for mobile devices
* - ARIA labels for screen readers
*
* @example
* ```typescript
* <InteractiveTrigramGrid
* selectedTrigram={selectedTrigram}
* onTrigramSelect={(stance) => handleSelect(stance)}
* isMobile={false}
* />
* ```
*
* @public
* @category Philosophy Components
*/
export const InteractiveTrigramGrid: React.FC<
InteractiveTrigramGridProps
> = ({ selectedTrigram, onTrigramSelect, isMobile = false }) => {
// Use canonical trigram ordering from shared constants
const trigrams = TRIGRAM_STANCES_ORDER;
// Grid configuration based on device
const columns = isMobile ? 2 : 4;
return (
<div
style={{
display: "grid",
gridTemplateColumns: `repeat(${columns}, 1fr)`,
gap: isMobile ? "10px" : "15px",
padding: isMobile ? "15px" : "20px",
background: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_DARK, 0.9),
borderRadius: "12px",
border: `2px solid ${hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.6)}`,
}}
aria-label="Trigram selection grid"
data-testid="trigram-grid"
>
{trigrams.map((stance) => {
const trigram = TRIGRAM_DATA[stance];
const isSelected = selectedTrigram === stance;
return (
<button
key={stance}
onClick={() => onTrigramSelect(stance)}
style={{
background: isSelected
? hexToRgbaString(trigram.theme.primary, 0.3)
: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_LIGHT, 0.6),
border: `2px solid ${
isSelected
? `#${trigram.theme.primary.toString(16).padStart(6, "0")}`
: hexToRgbaString(trigram.theme.primary, 0.4)
}`,
borderRadius: "8px",
padding: isMobile ? "12px" : "15px",
cursor: "pointer",
transition: "all 0.3s ease",
display: "flex",
flexDirection: "column",
alignItems: "center",
gap: "8px",
position: "relative",
overflow: "hidden",
}}
onMouseEnter={(e) => {
Eif (!isSelected) {
e.currentTarget.style.background = hexToRgbaString(
trigram.theme.primary,
0.2
);
e.currentTarget.style.transform = "scale(1.05)";
e.currentTarget.style.boxShadow = `0 0 20px ${hexToRgbaString(
trigram.theme.primary,
0.5
)}`;
}
}}
onMouseLeave={(e) => {
Eif (!isSelected) {
e.currentTarget.style.background = hexToRgbaString(
KOREAN_COLORS.UI_BACKGROUND_LIGHT,
0.6
);
e.currentTarget.style.transform = "scale(1)";
e.currentTarget.style.boxShadow = "none";
}
}}
aria-label={`${trigram.name.korean} ${trigram.name.english} trigram`}
aria-pressed={isSelected}
data-testid={`trigram-grid-button-${stance}`}
>
{/* Glow effect when selected */}
{isSelected && (
<div
style={{
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
background: `radial-gradient(circle, ${hexToRgbaString(
trigram.theme.primary,
0.2
)} 0%, transparent 70%)`,
animation: "philosophyPulse 2s ease-in-out infinite",
pointerEvents: "none",
}}
/>
)}
{/* Trigram symbol */}
<div
style={{
fontSize: isMobile ? "36px" : "48px",
color: `#${trigram.theme.primary.toString(16).padStart(6, "0")}`,
textShadow: isSelected
? `0 0 20px ${hexToRgbaString(trigram.theme.primary, 0.8)}`
: "none",
fontWeight: "bold",
transition: "all 0.3s ease",
}}
>
{trigram.symbol}
</div>
{/* Korean name */}
<div
style={{
fontSize: isMobile ? "14px" : "16px",
fontWeight: "bold",
color: isSelected
? `#${KOREAN_COLORS.ACCENT_GOLD.toString(16).padStart(6, "0")}`
: `#${KOREAN_COLORS.TEXT_PRIMARY.toString(16).padStart(6, "0")}`,
transition: "all 0.3s ease",
}}
>
{trigram.name.korean}
</div>
{/* English name */}
<div
style={{
fontSize: isMobile ? "11px" : "13px",
color: isSelected
? `#${KOREAN_COLORS.TEXT_SECONDARY.toString(16).padStart(6, "0")}`
: `#${KOREAN_COLORS.TEXT_TERTIARY.toString(16).padStart(6, "0")}`,
transition: "all 0.3s ease",
}}
>
{trigram.name.english}
</div>
{/* Chinese character */}
<div
style={{
fontSize: isMobile ? "12px" : "14px",
color: `#${KOREAN_COLORS.PRIMARY_CYAN.toString(16).padStart(6, "0")}`,
fontWeight: "bold",
transition: "all 0.3s ease",
}}
>
{trigram.chinese}
</div>
</button>
);
})}
{/* Pulse animation for selected state */}
<style>
{`
@keyframes philosophyPulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.6;
}
}
`}
</style>
</div>
);
};
export default InteractiveTrigramGrid;
|