@@ -2,29 +2,26 @@ import { ActiveElement } from "@/types";
22
33export const COLORS = [ "#DC2626" , "#D97706" , "#059669" , "#7C3AED" , "#DB2777" ] ;
44
5- type TElement =
6- | {
7- icon : string ;
8- name : string ;
9- value : string | TElement [ ] ;
10- }
11- | {
12- icon : string ;
13- label : string ;
14- value : string ;
15- }
16- | {
17- label : string ;
18- value : string ;
19- } ;
5+ type TElement = {
6+ name : string ;
7+ icon : string ;
8+ value : string ;
9+ label : string ;
10+ } ;
11+
12+ type TBaseElement = Pick < TElement , "value" | "label" > ;
13+ type TOptionElement = TBaseElement & { icon : string } ;
14+ type TNavElement = Omit < TElement , "label" | "value" > & {
15+ value : string | ActiveElement [ ] ;
16+ } ;
2017
2118type TShortcut = {
2219 key : string ;
2320 name : string ;
2421 shortcut : string ;
2522} ;
2623
27- export const shapeElements : TElement [ ] = [
24+ export const shapeElements : ActiveElement [ ] = [
2825 {
2926 icon : "/assets/rectangle.svg" ,
3027 name : "Rectangle" ,
@@ -57,7 +54,7 @@ export const shapeElements: TElement[] = [
5754 } ,
5855] ;
5956
60- export const navElements : TElement [ ] = [
57+ export const navElements : TNavElement [ ] = [
6158 {
6259 icon : "/assets/select.svg" ,
6360 name : "Select" ,
@@ -96,19 +93,19 @@ export const defaultNavElement: ActiveElement = {
9693 value : "select" ,
9794} ;
9895
99- export const directionOptions : TElement [ ] = [
96+ export const directionOptions : TOptionElement [ ] = [
10097 { label : "Bring to Front" , value : "front" , icon : "/assets/front.svg" } ,
10198 { label : "Send to Back" , value : "back" , icon : "/assets/back.svg" } ,
10299] ;
103100
104- export const fontFamilyOptions : TElement [ ] = [
101+ export const fontFamilyOptions : TBaseElement [ ] = [
105102 { value : "Helvetica" , label : "Helvetica" } ,
106103 { value : "Times New Roman" , label : "Times New Roman" } ,
107104 { value : "Comic Sans MS" , label : "Comic Sans MS" } ,
108105 { value : "Brush Script MT" , label : "Brush Script MT" } ,
109106] ;
110107
111- export const fontSizeOptions : TElement [ ] = [
108+ export const fontSizeOptions : TBaseElement [ ] = [
112109 {
113110 value : "10" ,
114111 label : "10" ,
@@ -167,7 +164,7 @@ export const fontSizeOptions: TElement[] = [
167164 } ,
168165] ;
169166
170- export const fontWeightOptions : TElement [ ] = [
167+ export const fontWeightOptions : TBaseElement [ ] = [
171168 {
172169 value : "400" ,
173170 label : "Normal" ,
@@ -182,7 +179,7 @@ export const fontWeightOptions: TElement[] = [
182179 } ,
183180] ;
184181
185- export const alignmentOptions : TElement [ ] = [
182+ export const alignmentOptions : TOptionElement [ ] = [
186183 { value : "left" , label : "Align Left" , icon : "/assets/align-left.svg" } ,
187184 {
188185 value : "horizontalCenter" ,
0 commit comments