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 | 22x 491x 491x 491x 491x 46x 46x 46x 491x 19x 19x 19x 19x 491x 2x 2x 491x 23x 23x 491x 23x 491x 424x 424x 491x 22x | /**
* BaseButtonOverlayHtml - HTML button component with Korean theming (non-Three.js)
*
* A version of BaseButton that doesn't require Three.js/Canvas context
* Can be used in regular DOM components
*
* @module components/base
*/
import React, { useCallback, useMemo, useState } from "react";
import { getKoreanButtonWithGlow } from "../../../utils/koreanThemeHelpers";
import { useKoreanTheme } from "./useKoreanTheme";
import { UIHaptics } from "../../../utils/hapticFeedback";
/**
* Props for BaseButtonOverlayHtml component
*/
export interface BaseButtonOverlayHtmlProps {
readonly korean: string;
readonly english: string;
readonly onClick: () => void;
readonly onMouseEnter?: () => void;
readonly disabled?: boolean;
readonly variant?: "primary" | "secondary" | "danger";
readonly size?: "sm" | "md" | "lg";
readonly fullWidth?: boolean;
readonly testId?: string;
readonly isMobile?: boolean;
readonly className?: string;
readonly style?: React.CSSProperties;
readonly autoFocus?: boolean;
readonly ariaLabel?: string;
readonly ariaCurrent?: React.AriaAttributes["aria-current"];
}
/**
* BaseButtonOverlayHtml Component
*
* HTML button with Korean theming (no Three.js dependency).
* Uses useKoreanTheme hook for consistent styling.
*
* Optimized with React.memo for 60fps performance:
* - Prevents re-renders when props haven't changed
* - Event handlers already use useCallback internally
*
* @example
* ```tsx
* <BaseButtonOverlayHtml
* korean="확인"
* english="Confirm"
* onClick={() => handleConfirm()}
* variant="primary"
* size="md"
* />
* ```
*/
export const BaseButtonOverlayHtml = React.memo<BaseButtonOverlayHtmlProps>(
({
korean,
english,
onClick,
onMouseEnter,
disabled = false,
variant = "primary",
size = "md",
fullWidth = false,
testId,
isMobile = false,
className,
style: customStyle,
autoFocus = false,
ariaLabel,
ariaCurrent,
}) => {
const [isHovered, setIsHovered] = useState(false);
const [isPressed, setIsPressed] = useState(false);
const { buttonSize } = useKoreanTheme({
variant,
size,
disabled,
isMobile,
});
const handleClick = useCallback(() => {
Eif (!disabled) {
UIHaptics.buttonTap(); // Add haptic feedback
onClick();
}
}, [onClick, disabled]);
const handleMouseEnterInternal = useCallback(() => {
Eif (!disabled) {
UIHaptics.menuHover(); // Add haptic feedback
setIsHovered(true);
onMouseEnter?.();
}
}, [disabled, onMouseEnter]);
const handleMouseLeave = useCallback(() => {
setIsHovered(false);
setIsPressed(false);
}, []);
const handleMouseDown = useCallback(() => {
Eif (!disabled) {
setIsPressed(true);
}
}, [disabled]);
const handleMouseUp = useCallback(() => {
setIsPressed(false);
}, []);
const buttonStyle = useMemo<React.CSSProperties>(() => {
const enhancedStyles = getKoreanButtonWithGlow({
variant,
isHovered: isHovered && !disabled,
isPressed: isPressed && !disabled,
isFocused: false,
glowIntensity: "medium",
hoverAnimation: "combined",
});
return {
...enhancedStyles,
padding: buttonSize.padding,
fontSize: buttonSize.fontSize, // Override for size consistency
cursor: disabled ? "not-allowed" : "pointer",
opacity: disabled ? 0.5 : 1,
borderRadius: "4px",
textAlign: "center" as const,
userSelect: "none" as const,
WebkitUserSelect: "none" as const,
width: fullWidth ? "100%" : "auto",
...customStyle,
};
}, [
variant,
buttonSize,
disabled,
fullWidth,
isHovered,
isPressed,
customStyle,
]);
return (
<button
onClick={handleClick}
onMouseEnter={handleMouseEnterInternal}
onMouseLeave={handleMouseLeave}
onMouseDown={handleMouseDown}
onMouseUp={handleMouseUp}
disabled={disabled}
style={buttonStyle}
className={className}
data-testid={testId ?? "base-button-html"}
autoFocus={autoFocus}
aria-label={ariaLabel ?? `${korean} | ${english}`}
aria-current={ariaCurrent}
>
<div style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
gap: "2px"
}}>
<span style={{ fontSize: "1em" }}>{korean}</span>
<span style={{
fontSize: "0.75em",
opacity: 0.8,
fontStyle: "italic"
}}>
{english}
</span>
</div>
</button>
);
});
BaseButtonOverlayHtml.displayName = "BaseButtonOverlayHtml";
|