FarmBot/Farmbot-Web-App

View on GitHub
frontend/farm_designer/map/layers/tool_slots/tool_slot_layer.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import React from "react";
import { SlotWithTool, UUID } from "../../../../resources/interfaces";
import { ToolSlotPoint } from "./tool_slot_point";
import { MapTransformProps } from "../../interfaces";

export interface ToolSlotLayerProps {
  visible: boolean;
  slots: SlotWithTool[];
  botPositionX: number | undefined;
  mapTransformProps: MapTransformProps;
  dispatch: Function;
  hoveredToolSlot: UUID | undefined;
  interactions: boolean;
  currentPoint: UUID | undefined;
  animate: boolean;
}

export function ToolSlotLayer(props: ToolSlotLayerProps) {
  const { slots, visible, mapTransformProps } = props;

  return <g
    id="toolslot-layer"
    style={props.interactions
      ? { cursor: "pointer" }
      : { pointerEvents: "none" }}>
    {visible &&
      slots.map(slot =>
        <ToolSlotPoint
          key={slot.toolSlot.uuid}
          slot={slot}
          hoveredToolSlot={props.hoveredToolSlot}
          current={slot.toolSlot.uuid === props.currentPoint}
          animate={props.animate}
          dispatch={props.dispatch}
          botPositionX={props.botPositionX}
          mapTransformProps={mapTransformProps} />)}
  </g>;
}