@@ -18,7 +18,7 @@ import Module from '@app/homeV3/module/Module';
18
18
const Wrapper = styled . div `
19
19
display: flex;
20
20
flex-direction: column;
21
- gap: ${ spacing . md } ;
21
+ gap: ${ spacing . xsm } ;
22
22
` ;
23
23
24
24
// Additional margin to have width of content excluding side buttons
@@ -27,37 +27,15 @@ const StyledAddModulesButton = styled(AddModuleButton)<{ $hasRows?: boolean }>`
27
27
` ;
28
28
29
29
const NewRowDropZone = styled . div < { $isOver ?: boolean } > `
30
- min-height: 60px;
31
- border-radius: 8px;
32
- margin: 0 48px;
33
- display: flex;
34
- align-items: center;
35
- justify-content: center;
36
30
transition: all 0.2s ease;
37
- border: 2px dashed transparent;
38
31
39
32
${ ( { $isOver } ) =>
40
33
$isOver &&
41
34
`
42
- background-color: rgba(59, 130, 246, 0.1);
43
- border-color: #3b82f6;
44
- min-height: 80px;
35
+ border: 2px solid #CAC3F1;
45
36
` }
46
37
` ;
47
38
48
- const NewRowDropText = styled . div < { $isOver ?: boolean } > `
49
- color: #6b7280;
50
- font-size: 14px;
51
- text-align: center;
52
- transition: all 0.2s ease;
53
-
54
- ${ ( { $isOver } ) =>
55
- $isOver &&
56
- `
57
- color: #3b82f6;
58
- font-weight: 500;
59
- ` }
60
- ` ;
61
39
62
40
// Styled wrapper for drag overlay to make it look like it's floating
63
41
const DragOverlayWrapper = styled . div `
@@ -75,24 +53,27 @@ interface Props {
75
53
}
76
54
77
55
// Memoized new row drop zone component
78
- const NewRowDropZoneComponent = memo ( function NewRowDropZoneComponent ( { rowIndex } : { rowIndex : number } ) {
56
+ const NewRowDropZoneComponent = memo ( function NewRowDropZoneComponent ( {
57
+ rowIndex,
58
+ insertNewRow = false
59
+ } : {
60
+ rowIndex : number ;
61
+ insertNewRow ?: boolean ;
62
+ } ) {
79
63
const {
80
64
isOver,
81
65
setNodeRef,
82
66
} = useDroppable ( {
83
- id : `new-row-drop-zone-${ rowIndex } ` ,
67
+ id : `new-row-drop-zone-${ rowIndex } ${ insertNewRow ? '-insert' : '' } ` ,
84
68
data : {
85
69
rowIndex,
86
70
moduleIndex : 0 , // First position in new row
71
+ insertNewRow, // Flag to indicate this should create a new row at this position
87
72
} ,
88
73
} ) ;
89
74
90
75
return (
91
- < NewRowDropZone ref = { setNodeRef } $isOver = { isOver } >
92
- < NewRowDropText $isOver = { isOver } >
93
- { isOver ? 'Drop here to create a new row' : 'Drop a module here to create a new row' }
94
- </ NewRowDropText >
95
- </ NewRowDropZone >
76
+ < NewRowDropZone ref = { setNodeRef } $isOver = { isOver } />
96
77
) ;
97
78
} ) ;
98
79
@@ -130,18 +111,44 @@ function Template({ className }: Props) {
130
111
handleDragEnd ( event ) ;
131
112
} , [ handleDragEnd ] ) ;
132
113
133
- // Memoize the template rows to prevent unnecessary re-renders
134
- const templateRows = useMemo ( ( ) =>
135
- wrappedRows . map ( ( row , i ) => (
136
- < TemplateRow
137
- key = { `templateRow-${ i } ` }
138
- row = { row }
139
- rowIndex = { i }
140
- modulesAvailableToAdd = { modulesAvailableToAdd }
141
- />
142
- ) ) ,
143
- [ wrappedRows , modulesAvailableToAdd ]
144
- ) ;
114
+ // Memoize the template rows with drop zones between them
115
+ const templateRowsWithDropZones = useMemo ( ( ) => {
116
+ const result : React . ReactElement [ ] = [ ] ;
117
+
118
+ wrappedRows . forEach ( ( row , i ) => {
119
+ // Add drop zone before the first row (for inserting at beginning)
120
+ if ( i === 0 ) {
121
+ result . push (
122
+ < NewRowDropZoneComponent
123
+ key = { `drop-zone-before-${ i } ` }
124
+ rowIndex = { i }
125
+ insertNewRow = { true }
126
+ />
127
+ ) ;
128
+ }
129
+
130
+ // Add the actual row
131
+ result . push (
132
+ < TemplateRow
133
+ key = { `templateRow-${ i } ` }
134
+ row = { row }
135
+ rowIndex = { i }
136
+ modulesAvailableToAdd = { modulesAvailableToAdd }
137
+ />
138
+ ) ;
139
+
140
+ // Add drop zone after each row (for inserting between/after rows)
141
+ result . push (
142
+ < NewRowDropZoneComponent
143
+ key = { `drop-zone-after-${ i } ` }
144
+ rowIndex = { i + 1 }
145
+ insertNewRow = { true }
146
+ />
147
+ ) ;
148
+ } ) ;
149
+
150
+ return result ;
151
+ } , [ wrappedRows , modulesAvailableToAdd ] ) ;
145
152
146
153
return (
147
154
< Wrapper className = { className } >
@@ -150,10 +157,7 @@ function Template({ className }: Props) {
150
157
onDragStart = { handleDragStart }
151
158
onDragEnd = { handleDragEndWithCleanup }
152
159
>
153
- { templateRows }
154
-
155
- { /* Drop zone for creating new rows */ }
156
- < NewRowDropZoneComponent rowIndex = { wrappedRows . length } />
160
+ { templateRowsWithDropZones }
157
161
158
162
< DragOverlay >
159
163
{ activeModule && (
0 commit comments