reactbits-mcp-server
Version:
MCP Server for React Bits - Access 99+ React components with animations, backgrounds, and UI elements
56 lines (51 loc) • 1.4 kB
JSX
import "./GlareHover.css";
const GlareHover = ({
width = "500px",
height = "500px",
background = "#000",
borderRadius = "10px",
borderColor = "#333",
children,
glareColor = "#ffffff",
glareOpacity = 0.5,
glareAngle = -45,
glareSize = 250,
transitionDuration = 650,
playOnce = false,
className = "",
style = {},
}) => {
const hex = glareColor.replace("#", "");
let rgba = glareColor;
if (/^[0-9A-Fa-f]{6}$/.test(hex)) {
const r = parseInt(hex.slice(0, 2), 16);
const g = parseInt(hex.slice(2, 4), 16);
const b = parseInt(hex.slice(4, 6), 16);
rgba = `rgba(${r}, ${g}, ${b}, ${glareOpacity})`;
} else if (/^[0-9A-Fa-f]{3}$/.test(hex)) {
const r = parseInt(hex[0] + hex[0], 16);
const g = parseInt(hex[1] + hex[1], 16);
const b = parseInt(hex[2] + hex[2], 16);
rgba = `rgba(${r}, ${g}, ${b}, ${glareOpacity})`;
}
const vars = {
"--gh-width": width,
"--gh-height": height,
"--gh-bg": background,
"--gh-br": borderRadius,
"--gh-angle": `${glareAngle}deg`,
"--gh-duration": `${transitionDuration}ms`,
"--gh-size": `${glareSize}%`,
"--gh-rgba": rgba,
"--gh-border": borderColor,
};
return (
<div
className={`glare-hover ${playOnce ? 'glare-hover--play-once' : ''} ${className}`}
style={{ ...vars, ...style }}
>
{children}
</div>
);
};
export default GlareHover;