@@ -2,11 +2,13 @@ import { memo, useCallback, useState } from "react";
2
2
import { RectangleHorizontal } from "lucide-react" ;
3
3
import { default as isEqual } from "lodash/isEqual" ;
4
4
import { twMerge } from "tailwind-merge" ;
5
+ import { useShapes } from "@/hooks" ;
6
+ import { getMergedShapes } from "@/hooks/shapes" ;
5
7
import { store } from "@/store" ;
6
8
import { setCursor } from "@/store/reducers/editor" ;
9
+ import { ISTKProps } from "@/types" ;
7
10
import { fallible } from "@/utils" ;
8
11
import { resizableRectangle , shapeSize , shapeStrokeWidth } from "../../workspace/elements/shape" ;
9
- import { shapeList } from "./shape-list" ;
10
12
11
13
const CursorShape = ( Shape ) => {
12
14
const icon = ( props ) => (
@@ -25,7 +27,7 @@ const CursorShape = (Shape) => {
25
27
return icon ;
26
28
} ;
27
29
28
- const Controls = ( ) => {
30
+ const Controls = ( { options } : Pick < ISTKProps , "options" > ) => {
29
31
const [ selectedIndex , setSelectedIndex ] = useState ( 0 ) ;
30
32
31
33
const onShapeClick = useCallback ( ( shape , i ) => {
@@ -35,9 +37,11 @@ const Controls = () => {
35
37
} ) ;
36
38
} , [ ] ) ;
37
39
40
+ const shapes = useShapes ( { options } ) ;
41
+
38
42
return (
39
43
< div className = "w-full grid grid-cols-5 gap-4" >
40
- { shapeList . map ( ( Shape , i ) => (
44
+ { shapes . map ( ( Shape , i ) => (
41
45
< div
42
46
key = { i }
43
47
className = { twMerge (
@@ -53,9 +57,9 @@ const Controls = () => {
53
57
) ;
54
58
} ;
55
59
56
- export const selectFirstShape = ( ) =>
60
+ export const selectFirstShape = ( { options } : Pick < ISTKProps , "options" > ) =>
57
61
fallible ( ( ) => {
58
- store . dispatch ( setCursor ( CursorShape ( shapeList [ 0 ] ) ) ) ;
62
+ store . dispatch ( setCursor ( CursorShape ( getMergedShapes ( options ) [ 0 ] ) ) ) ;
59
63
} ) ;
60
64
61
65
const ShapeControls = memo ( Controls , isEqual ) ;
0 commit comments