Skip to content

Instantly share code, notes, and snippets.

@kitze
Created February 1, 2022 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitze/01f5c998bd09f325b20ae0f7c25ee2ee to your computer and use it in GitHub Desktop.
Save kitze/01f5c998bd09f325b20ae0f7c25ee2ee to your computer and use it in GitHub Desktop.
rectangles
const Rectangles = ({
cols,
defaultBackground,
defaultBackgroundEmoji,
paints,
rows,
paint
}) => {
return (
<L.Vertical>
{times(rows).map((r, rowIndex) => (
<L.Horizontal key={rowIndex}>
{times(cols).map((c, columnIndex) => {
const foundPaint = findPaint({ paints, rowIndex, columnIndex });
return (
<Rectangle
onRightClick={(e) => {
e.preventDefault();
paint({ rowIndex, columnIndex, paint: '' });
}}
key={columnIndex}
onClick={() => {
paint({ rowIndex, columnIndex });
}}
>
{renderRectangleContent({
foundPaint,
defaultBackground,
defaultBackgroundEmoji
})}
</Rectangle>
);
})}
</L.Horizontal>
))}
</L.Vertical>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment