slanted-gamedev-toolz
Version:
A slanted mix of tools for your brilliant ideas in game design.
39 lines (38 loc) • 1.36 kB
JavaScript
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { useMemo } from "react";
export const Dpad = ({ size = 170 }) => {
const style = {
border: "1px solid rgb(0,0,0,0.2)",
borderRadius: "10px",
height: size,
width: size,
position: "absolute",
bottom: 20,
left: 20,
display: "grid",
gridTemplateColumns: "repeat(3, 1fr)",
gridTemplateRows: "repeat(3, 1fr)",
};
const Buttons = useMemo(() => {
const buttonStyle = {
width: "100%",
height: "100%",
position: "relative",
borderRadius: "50%",
display: "flex",
alignItems: "center",
justifyContent: "center",
fontSize: "2em",
border: "none",
background: "none",
};
const buttons = [];
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 3; col++) {
buttons.push(_jsxs("button", { style: buttonStyle, children: [row === 0 && col === 1 ? "🔼" : null, row === 1 && col === 0 ? "◀️" : null, row === 1 && col === 2 ? "▶️" : null, row === 2 && col === 1 ? "🔽" : null] }, `${row}-${col}`));
}
}
return buttons;
}, []);
return _jsx("div", { style: style, children: Buttons });
};