@@ -2,11 +2,13 @@ import { memo, useCallback, useState } from "react";
22import { RectangleHorizontal } from "lucide-react" ;
33import { default as isEqual } from "lodash/isEqual" ;
44import { twMerge } from "tailwind-merge" ;
5+ import { useShapes } from "@/hooks" ;
6+ import { getMergedShapes } from "@/hooks/shapes" ;
57import { store } from "@/store" ;
68import { setCursor } from "@/store/reducers/editor" ;
9+ import { ISTKProps } from "@/types" ;
710import { fallible } from "@/utils" ;
811import { resizableRectangle , shapeSize , shapeStrokeWidth } from "../../workspace/elements/shape" ;
9- import { shapeList } from "./shape-list" ;
1012
1113const CursorShape = ( Shape ) => {
1214 const icon = ( props ) => (
@@ -25,7 +27,7 @@ const CursorShape = (Shape) => {
2527 return icon ;
2628} ;
2729
28- const Controls = ( ) => {
30+ const Controls = ( { options } : Pick < ISTKProps , "options" > ) => {
2931 const [ selectedIndex , setSelectedIndex ] = useState ( 0 ) ;
3032
3133 const onShapeClick = useCallback ( ( shape , i ) => {
@@ -35,9 +37,11 @@ const Controls = () => {
3537 } ) ;
3638 } , [ ] ) ;
3739
40+ const shapes = useShapes ( { options } ) ;
41+
3842 return (
3943 < div className = "w-full grid grid-cols-5 gap-4" >
40- { shapeList . map ( ( Shape , i ) => (
44+ { shapes . map ( ( Shape , i ) => (
4145 < div
4246 key = { i }
4347 className = { twMerge (
@@ -53,9 +57,9 @@ const Controls = () => {
5357 ) ;
5458} ;
5559
56- export const selectFirstShape = ( ) =>
60+ export const selectFirstShape = ( { options } : Pick < ISTKProps , "options" > ) =>
5761 fallible ( ( ) => {
58- store . dispatch ( setCursor ( CursorShape ( shapeList [ 0 ] ) ) ) ;
62+ store . dispatch ( setCursor ( CursorShape ( getMergedShapes ( options ) [ 0 ] ) ) ) ;
5963 } ) ;
6064
6165const ShapeControls = memo ( Controls , isEqual ) ;
0 commit comments