@@ -4,7 +4,7 @@ import { X, Check, AlertCircle, Plus, Trash2 } from "lucide-react";
44/**
55 * AddRecordDrawer
66 * A slide-over drawer component for adding/editing records.
7- * Supports nested Object, Array, and Ref field types.
7+ * Supports nested Object, Array, and Ref field types with compact UI and theme safety .
88 */
99export default function AddRecordDrawer ( {
1010 isOpen,
@@ -66,8 +66,6 @@ export default function AddRecordDrawer({
6666 if ( field . type === "Date" && val ) {
6767 formattedData [ field . key ] = new Date ( val ) . toISOString ( ) ;
6868 }
69-
70- // Object and Array are set directly by their sub-components
7169 } ) ;
7270
7371 if ( Object . keys ( newErrors ) . length > 0 ) {
@@ -90,50 +88,51 @@ export default function AddRecordDrawer({
9088 onClick = { onClose }
9189 style = { {
9290 position : "fixed" , inset : 0 ,
93- background : "rgba(0,0,0,0.5)" , backdropFilter : "blur(4px )",
94- zIndex : 999 , animation : "fadeIn 0.2s ease-out"
91+ background : "var(--color-overlay )" ,
92+ zIndex : 999 , animation : "fadeIn 0.15s ease-out"
9593 } }
9694 />
9795
9896 { /* Drawer Panel */ }
9997 < div
100- className = "drawer-panel glass-panel "
98+ className = "drawer-panel"
10199 style = { {
102100 position : "fixed" , top : 0 , right : 0 , bottom : 0 ,
103- width : isWideForm ? "600px " : "500px " , maxWidth : "100%" ,
101+ width : isWideForm ? "520px " : "420px " , maxWidth : "100%" ,
104102 zIndex : 1000 , display : "flex" , flexDirection : "column" ,
105103 transform : isOpen ? "translateX(0)" : "translateX(100%)" ,
106- animation : "slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1)" ,
104+ animation : "slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1)" ,
107105 borderLeft : "1px solid var(--color-border)" ,
108106 background : "var(--color-bg-card)" ,
109- boxShadow : "-10px 0 30px rgba(0,0,0,0.3 )"
107+ boxShadow : "-8px 0 24px rgba(0,0,0,0.25 )"
110108 } }
111109 >
112110 { /* Header */ }
113111 < div style = { {
114- padding : "1.5rem" , borderBottom : "1px solid var(--color-border)" ,
115- display : "flex" , justifyContent : "space-between" , alignItems : "center"
112+ padding : "0.85rem 1.15rem" , borderBottom : "1px solid var(--color-border)" ,
113+ display : "flex" , justifyContent : "space-between" , alignItems : "center" ,
114+ background : "var(--color-bg-card)" , flexShrink : 0
116115 } } >
117116 < div >
118- < h2 style = { { fontSize : "1.25rem " , fontWeight : 600 , margin : 0 } } >
117+ < h2 style = { { fontSize : "1rem " , fontWeight : 700 , margin : 0 , color : "var(--color-text-main)" } } >
119118 { initialData ? "Edit Record" : "Add New Record" }
120119 </ h2 >
121- < p style = { { fontSize : "0.85rem " , color : "var(--color-text-muted)" , margin : "4px 0 0 0" } } >
120+ < p style = { { fontSize : "0.75rem " , color : "var(--color-text-muted)" , margin : "2px 0 0 0" } } >
122121 { initialData ? "Update the details for this document." : "Fill in the details for the new document." }
123122 </ p >
124123 </ div >
125- < button onClick = { onClose } className = "btn-icon" style = { { color : "var(--color-text-muted)" } } >
126- < X size = { 20 } />
124+ < button onClick = { onClose } className = "btn-icon" style = { { color : "var(--color-text-muted)" , padding : "4px" } } >
125+ < X size = { 16 } />
127126 </ button >
128127 </ div >
129128
130129 { /* Body */ }
131- < div style = { { flex : 1 , overflowY : "auto" , padding : "1.5rem " } } >
130+ < div className = "custom-scrollbar" style = { { flex : 1 , overflowY : "auto" , padding : "1rem 1.15rem " } } >
132131 < form id = "add-record-form" onSubmit = { handleSubmit } >
133132 < div style = { {
134133 display : "grid" ,
135134 gridTemplateColumns : isWideForm ? "repeat(2, 1fr)" : "1fr" ,
136- gap : "1.25rem " ,
135+ gap : "0.85rem " ,
137136 } } >
138137 { fields . map ( ( field ) => (
139138 < div
@@ -145,27 +144,27 @@ export default function AddRecordDrawer({
145144 >
146145 < label className = "form-label" style = { {
147146 display : "flex" , justifyContent : "space-between" ,
148- marginBottom : "0.5rem " , fontSize : "0.9rem" ,
149- color : "var(--color-text-secondary) "
147+ marginBottom : "0.3rem " , fontSize : "0.75rem" , fontWeight : 600 ,
148+ color : "var(--color-text-muted)" , textTransform : "uppercase" , letterSpacing : "0.03em "
150149 } } >
151150 < span >
152151 { field . key }
153- { field . required && < span className = "text- danger" style = { { marginLeft : "4px " } } > *</ span > }
152+ { field . required && < span style = { { color : "var(--color- danger)" , marginLeft : "2px " } } > *</ span > }
154153 </ span >
155154 < span style = { {
156- fontSize : "0.7rem " , color : "var(--color-text-muted)" ,
157- background : "rgba(255,255,255,0.05 )" , padding : "2px 6px " , borderRadius : "4px "
155+ fontSize : "0.65rem " , color : "var(--color-text-muted)" ,
156+ background : "var(--color-bg-input )" , padding : "1px 5px " , borderRadius : "3px" , border : "1px solid var(--color-border) "
158157 } } > { field . type } { field . type === 'Ref' && field . ref ? ` → ${ field . ref } ` : '' } </ span >
159158 </ label >
160159
161160 { renderInput ( field , formData [ field . key ] , handleChange , errors [ field . key ] ) }
162161
163162 { errors [ field . key ] && (
164163 < div style = { {
165- color : "#ef4444 " , fontSize : "0.8rem " , marginTop : "6px " ,
164+ color : "var(--color-danger) " , fontSize : "0.75rem " , marginTop : "4px " ,
166165 display : "flex" , alignItems : "center" , gap : "4px"
167166 } } >
168- < AlertCircle size = { 12 } />
167+ < AlertCircle size = { 11 } />
169168 { errors [ field . key ] }
170169 </ div >
171170 ) }
@@ -177,20 +176,20 @@ export default function AddRecordDrawer({
177176
178177 { /* Footer */ }
179178 < div style = { {
180- padding : "1.25rem 1.5rem " , borderTop : "1px solid var(--color-border)" ,
181- display : "flex" , justifyContent : "flex-end" , gap : "1rem " ,
182- background : "rgba(0,0,0,0.2)"
179+ padding : "0.75rem 1.15rem " , borderTop : "1px solid var(--color-border)" ,
180+ display : "flex" , justifyContent : "flex-end" , gap : "0.65rem " ,
181+ background : "var(--color-bg-card)" , flexShrink : 0
183182 } } >
184- < button type = "button" onClick = { onClose } className = "btn btn-ghost" disabled = { isSubmitting } >
183+ < button type = "button" onClick = { onClose } className = "btn btn-ghost" disabled = { isSubmitting } style = { { height : "30px" , fontSize : "0.75rem" } } >
185184 Cancel
186185 </ button >
187186 < button type = "submit" form = "add-record-form" className = "btn btn-primary"
188- disabled = { isSubmitting } style = { { minWidth : "120px" } } >
187+ disabled = { isSubmitting } style = { { minWidth : "100px" , height : "30px" , fontSize : "0.75rem" , fontWeight : 600 } } >
189188 { isSubmitting ? (
190- < span className = "animate-spin " style = { { display : "inline-block" , border : "2px solid transparent" , borderTopColor : "currentColor" , borderRadius : "50%" , width : "16px " , height : "16px " } } > </ span >
189+ < span className = "spinner-small " style = { { width : "12px " , height : "12px " } } > </ span >
191190 ) : (
192191 < >
193- < Check size = { 18 } />
192+ < Check size = { 14 } />
194193 < span > { initialData ? "Update" : "Save Record" } </ span >
195194 </ >
196195 ) }
@@ -209,45 +208,45 @@ export default function AddRecordDrawer({
209208 }
210209 .form-input {
211210 width: 100%;
212- background: rgba(0, 0, 0, 0.2 );
211+ background: var(--color-bg-input );
213212 border: 1px solid var(--color-border);
214- padding: 10px 12px ;
215- border-radius: 6px ;
213+ padding: 5px 8px ;
214+ border-radius: 5px ;
216215 color: var(--color-text-main);
217- font-size: 0.95rem;
218- transition: all 0.2s;
216+ font-size: 0.8125rem;
217+ height: 30px;
218+ transition: border-color 0.15s;
219+ outline: none;
219220 }
220221 .form-input:focus {
221- outline: none;
222222 border-color: var(--color-primary);
223- background: rgba(0, 0, 0, 0.3);
224- box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.1);
225223 }
226224 .form-select {
227225 width: 100%;
228- background: rgba(0, 0, 0, 0.2 );
226+ background: var(--color-bg-input );
229227 border: 1px solid var(--color-border);
230- padding: 10px 12px ;
231- border-radius: 6px ;
228+ padding: 4px 8px ;
229+ border-radius: 5px ;
232230 color: var(--color-text-main);
233- appearance: none;
234- background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23aaaaaa%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
235- background-repeat: no-repeat;
236- background-position: right 12px top 50%;
237- background-size: 10px auto;
231+ font-size: 0.8125rem;
232+ height: 30px;
233+ outline: none;
234+ }
235+ .form-select:focus {
236+ border-color: var(--color-primary);
238237 }
239238 .nested-fieldset {
240- border: 1px solid rgba(62, 207, 142, 0.15 );
241- border-radius: 8px ;
242- padding: 12px ;
243- background: rgba(0,0,0,0.1 );
244- margin-top: 4px ;
239+ border: 1px solid var(--color-border );
240+ border-radius: 6px ;
241+ padding: 8px ;
242+ background: var(--color-bg-input );
243+ margin-top: 3px ;
245244 }
246245 .array-item-row {
247246 display: flex;
248- gap: 8px ;
247+ gap: 6px ;
249248 align-items: flex-start;
250- margin-bottom: 8px ;
249+ margin-bottom: 6px ;
251250 }
252251 ` } </ style >
253252 </ >
@@ -265,7 +264,7 @@ function renderInput(field, value, onChange, error) {
265264 className = "form-select"
266265 value = { val === "" ? "" : String ( val ) }
267266 onChange = { ( e ) => onChange ( field . key , e . target . value , "Boolean" ) }
268- style = { error ? { borderColor : "#ef4444 " } : { } }
267+ style = { error ? { borderColor : "var(--color-danger) " } : { } }
269268 >
270269 < option value = "" > Select...</ option >
271270 < option value = "true" > True</ option >
@@ -282,8 +281,9 @@ function renderInput(field, value, onChange, error) {
282281 className = "form-input"
283282 value = { val }
284283 onChange = { ( e ) => onChange ( field . key , e . target . value , "Date" ) }
285- style = { error ? { borderColor : "#ef4444" } : { } }
286- />
284+ style = { error ? { borderColor : "var(--color-danger)" } : { } }
285+ >
286+ </ input >
287287 ) ;
288288 }
289289
@@ -296,7 +296,7 @@ function renderInput(field, value, onChange, error) {
296296 placeholder = { `Enter _id from ${ field . ref || 'collection' } ` }
297297 value = { val }
298298 onChange = { ( e ) => onChange ( field . key , e . target . value ) }
299- style = { error ? { borderColor : "#ef4444 " } : { } }
299+ style = { error ? { borderColor : "var(--color-danger) " } : { } }
300300 />
301301 ) ;
302302 }
@@ -307,13 +307,13 @@ function renderInput(field, value, onChange, error) {
307307 return (
308308 < div className = "nested-fieldset" >
309309 { field . fields . map ( subField => (
310- < div key = { subField . key } style = { { marginBottom : '10px ' } } >
310+ < div key = { subField . key } style = { { marginBottom : '6px ' } } >
311311 < label style = { {
312312 display : 'flex' , justifyContent : 'space-between' ,
313- fontSize : '0.8rem ' , color : 'var(--color-text-muted)' , marginBottom : '4px '
313+ fontSize : '0.725rem ' , color : 'var(--color-text-muted)' , marginBottom : '2px '
314314 } } >
315- < span > { subField . key } { subField . required && < span style = { { color : '#ef4444 ' } } > *</ span > } </ span >
316- < span style = { { fontSize : '0.65rem ' , opacity : 0.6 } } > { subField . type } </ span >
315+ < span > { subField . key } { subField . required && < span style = { { color : 'var(--color-danger) ' } } > *</ span > } </ span >
316+ < span style = { { fontSize : '0.6rem ' , opacity : 0.6 } } > { subField . type } </ span >
317317 </ label >
318318 { renderInput (
319319 subField ,
@@ -354,21 +354,20 @@ function renderInput(field, value, onChange, error) {
354354 < div className = "nested-fieldset" >
355355 { arrVal . map ( ( item , idx ) => (
356356 < div key = { idx } className = "array-item-row" >
357- < span style = { { fontSize : '0.75rem ' , color : 'var(--color-text-muted)' , minWidth : '20px ' , paddingTop : '10px ' } } >
357+ < span style = { { fontSize : '0.7rem ' , color : 'var(--color-text-muted)' , minWidth : '16px ' , paddingTop : '6px ' } } >
358358 { idx }
359359 </ span >
360360 < div style = { { flex : 1 } } >
361361 { itemType === 'Object' && field . items ?. fields ? (
362- // Array of objects
363- < div className = "nested-fieldset" style = { { padding : '8px' } } >
362+ < div className = "nested-fieldset" style = { { padding : '6px' } } >
364363 { field . items . fields . map ( subField => (
365- < div key = { subField . key } style = { { marginBottom : '8px ' } } >
364+ < div key = { subField . key } style = { { marginBottom : '4px ' } } >
366365 < label style = { {
367366 display : 'flex' , justifyContent : 'space-between' ,
368- fontSize : '0.75rem ' , color : 'var(--color-text-muted)' , marginBottom : '3px '
367+ fontSize : '0.7rem ' , color : 'var(--color-text-muted)' , marginBottom : '2px '
369368 } } >
370369 < span > { subField . key } </ span >
371- < span style = { { fontSize : '0.6rem ' , opacity : 0.6 } } > { subField . type } </ span >
370+ < span style = { { fontSize : '0.55rem ' , opacity : 0.6 } } > { subField . type } </ span >
372371 </ label >
373372 { renderInput (
374373 subField ,
@@ -424,19 +423,19 @@ function renderInput(field, value, onChange, error) {
424423 type = "button"
425424 onClick = { ( ) => removeItem ( idx ) }
426425 className = "btn-icon"
427- style = { { color : 'var(--color-text-muted)' , paddingTop : '8px ' , flexShrink : 0 } }
426+ style = { { color : 'var(--color-text-muted)' , paddingTop : '4px ' , flexShrink : 0 } }
428427 >
429- < Trash2 size = { 14 } />
428+ < Trash2 size = { 13 } />
430429 </ button >
431430 </ div >
432431 ) ) }
433432 < button
434433 type = "button"
435434 onClick = { addItem }
436435 className = "btn btn-secondary"
437- style = { { fontSize : '0.8rem ' , width : '100%' , marginTop : '4px' } }
436+ style = { { fontSize : '0.725rem ' , width : '100%' , marginTop : '3px' , height : '26px' , padding : '0 8px' , gap : '4px' } }
438437 >
439- < Plus size = { 14 } /> Add Item
438+ < Plus size = { 12 } /> Add Item
440439 </ button >
441440 </ div >
442441 ) ;
@@ -451,7 +450,7 @@ function renderInput(field, value, onChange, error) {
451450 value = { val }
452451 onChange = { ( e ) => onChange ( field . key , e . target . value , field . type ) }
453452 step = { field . type === "Number" ? "any" : undefined }
454- style = { error ? { borderColor : "#ef4444 " } : { } }
453+ style = { error ? { borderColor : "var(--color-danger) " } : { } }
455454 />
456455 ) ;
457456}
0 commit comments