11import type { RectDimensions } from '@/lib/editor/engine/overlay/rect' ;
22import { adaptValueToCanvas } from '@/lib/editor/engine/overlay/utils' ;
3+ import type { DomElementStyles } from '@onlook/models/element' ;
34import { colors } from '@onlook/ui/tokens' ;
45import { nanoid } from 'nanoid' ;
56import { BaseRect } from './BaseRect' ;
@@ -90,7 +91,7 @@ const parseCssBoxValues = (
9091
9192interface ClickRectProps extends RectDimensions {
9293 isComponent ?: boolean ;
93- styles : Record < string , string > ;
94+ styles : DomElementStyles | null ;
9495 shouldShowResizeHandles : boolean ;
9596}
9697
@@ -104,10 +105,10 @@ export const ClickRect = ({
104105 shouldShowResizeHandles,
105106} : ClickRectProps ) => {
106107 const renderMarginLabels = ( ) => {
107- if ( ! styles ?. margin ) {
108+ if ( ! styles ?. computed . margin ) {
108109 return null ;
109110 }
110- const { adjusted, original } = parseCssBoxValues ( styles . margin ) ;
111+ const { adjusted, original } = parseCssBoxValues ( styles . computed . margin ) ;
111112
112113 const patternId = `margin-pattern-${ nanoid ( ) } ` ;
113114 const maskId = `margin-mask-${ nanoid ( ) } ` ;
@@ -201,10 +202,10 @@ export const ClickRect = ({
201202 } ;
202203
203204 const renderPaddingLabels = ( ) => {
204- if ( ! styles ?. padding ) {
205+ if ( ! styles ?. computed . padding ) {
205206 return null ;
206207 }
207- const { adjusted, original } = parseCssBoxValues ( styles . padding ) ;
208+ const { adjusted, original } = parseCssBoxValues ( styles . computed . padding ) ;
208209
209210 const patternId = `padding-pattern-${ nanoid ( ) } ` ;
210211 const maskId = `padding-mask-${ nanoid ( ) } ` ;
@@ -301,8 +302,8 @@ export const ClickRect = ({
301302
302303 const renderDimensionLabels = ( ) => {
303304 const rectColor = isComponent ? colors . purple [ 500 ] : colors . red [ 500 ] ;
304- const displayWidth = parseFloat ( styles ?. width || '0' ) . toFixed ( 0 ) ;
305- const displayHeight = parseFloat ( styles ?. height || '0' ) . toFixed ( 0 ) ;
305+ const displayWidth = parseFloat ( styles ?. defined . width || '0' ) . toFixed ( 0 ) ;
306+ const displayHeight = parseFloat ( styles ?. defined . height || '0' ) . toFixed ( 0 ) ;
306307 const text = `${ displayWidth } × ${ displayHeight } ` ;
307308
308309 // Constants from showDimensions
@@ -355,9 +356,9 @@ export const ClickRect = ({
355356 height = { height }
356357 left = { left }
357358 top = { top }
358- borderRadius = { parseInt ( styles ?. [ 'borderRadius' ] || '0' ) }
359+ borderRadius = { parseInt ( styles ?. computed [ 'borderRadius' ] || '0' ) }
359360 isComponent = { isComponent }
360- styles = { styles }
361+ styles = { styles ?. computed ?? { } }
361362 />
362363 ) }
363364 </ BaseRect >
0 commit comments