Improves outlines

This commit is contained in:
Steve Ruiz 2021-05-12 12:27:33 +01:00
parent b746601de7
commit addf4185f0
13 changed files with 184 additions and 78 deletions

View file

@ -1,5 +1,5 @@
import { useSelector } from "state"
import { RectangleShape, ShapeProps } from "types"
import { HoverIndicator, Indicator } from "./indicator"
import ShapeGroup from "./shape-g"
function BaseRectangle({
@ -9,26 +9,38 @@ function BaseRectangle({
strokeWidth = 0,
}: ShapeProps<RectangleShape>) {
return (
<rect
x={strokeWidth}
y={strokeWidth}
width={size[0] - strokeWidth * 2}
height={size[1] - strokeWidth * 2}
fill={fill}
stroke={stroke}
strokeWidth={strokeWidth}
/>
<>
<HoverIndicator
as="rect"
x={1}
y={1}
width={size[0] - 2}
height={size[1] - 2}
/>
<rect
x={strokeWidth / 2}
y={strokeWidth / 2}
width={size[0] - strokeWidth}
height={size[1] - strokeWidth}
fill={fill}
stroke={stroke}
strokeWidth={strokeWidth}
/>
<Indicator
as="rect"
x={1}
y={1}
width={size[0] - 2}
height={size[1] - 2}
/>
</>
)
}
export default function Rectangle({ id, point, size }: RectangleShape) {
const isSelected = useSelector((state) => state.values.selectedIds.has(id))
return (
<ShapeGroup id={id} point={point}>
<BaseRectangle size={size} />
{isSelected && (
<BaseRectangle size={size} fill="none" stroke="blue" strokeWidth={1} />
)}
</ShapeGroup>
)
}