Squares = ({ width, height, values, event, easement, duration }) => {
const svg = d3.create("svg").attr("width", width).attr("height", height);
const node = svg.node();
const elements = svg
.selectAll("rect")
.data(values)
.join("rect")
.attr("x", (d) => d.x)
.attr("y", (d) => d.x)
.attr("height", (d) => d.s)
.attr("width", (d) => d.s)
.attr("fill", (d) => d.fill)
.on("click", () => set(node, update(node.values)));
const animate = animator({ elements, duration, easement });
return Object.defineProperty(node, "values", {
get: () => values,
set: (newValues) => animate((values = newValues))
});
}