@@ -33,10 +33,12 @@ export default function RoundDiv({style, children, dontConvertShadow, ...props})
33
33
const [ innerPath , setInnerPath ] = useState ( 'Z' )
34
34
35
35
const div = useRef ( )
36
+ const slotWrapper = useRef ( )
36
37
37
38
const updateStatesWithArgs = ( ) => {
38
39
updateStates ( {
39
40
div,
41
+ slotWrapper,
40
42
style,
41
43
setBoxSizing,
42
44
setOverflow,
@@ -108,11 +110,10 @@ export default function RoundDiv({style, children, dontConvertShadow, ...props})
108
110
const pathIsEmpty = path . startsWith ( 'Z' ) || path === ''
109
111
const divStyle = {
110
112
...style ,
111
- ...( pathIsEmpty ? {
112
- borderImage : 'none' ,
113
- } : {
113
+ borderImage : 'none' ,
114
+ ...( pathIsEmpty ? { } : {
114
115
...invisibleBorderStyles ,
115
- borderImage : 'none ' ,
116
+ padding : '0 ' ,
116
117
background : 'transparent' ,
117
118
boxShadow : dontConvertShadow
118
119
// "box-shadow" must be overridden for the style extraction to work (with nth: 1, and not nth: 0)
@@ -125,13 +126,12 @@ export default function RoundDiv({style, children, dontConvertShadow, ...props})
125
126
}
126
127
127
128
const shapeComponentStyles = {
128
- height : boxSizing === 'border-box' ? height : height - ( border . width [ 0 ] + padding [ 0 ] + border . width [ 2 ] + padding [ 2 ] ) ,
129
- width : boxSizing === 'border-box' ? width : width - ( border . width [ 1 ] + padding [ 1 ] + border . width [ 3 ] + padding [ 3 ] ) ,
130
- padding : padding . map ( n => n + 'px' ) . join ( ' ' ) ,
129
+ height : boxSizing === 'border-box' ? height : height - ( border . width [ 0 ] + border . width [ 2 ] ) ,
130
+ width : boxSizing === 'border-box' ? width : width - ( border . width [ 1 ] + border . width [ 3 ] ) ,
131
131
position : 'fixed' ,
132
132
left : 0 ,
133
133
top : 0 ,
134
- transform : `translate(-${ padding [ 3 ] + border . width [ 3 ] } px, -${ padding [ 0 ] + border . width [ 0 ] } px)` ,
134
+ transform : `translate(-${ border . width [ 3 ] } px, -${ border . width [ 0 ] } px)` ,
135
135
zIndex : - 1 ,
136
136
}
137
137
@@ -142,9 +142,7 @@ export default function RoundDiv({style, children, dontConvertShadow, ...props})
142
142
143
143
return < div { ...props } style = { divStyle } ref = { div } >
144
144
{ pathIsEmpty ? null : < ShadowRoot >
145
- < div style = { {
146
- transform : 'scale(1)'
147
- } } >
145
+ < div style = { { transform : 'scale(1)' } } >
148
146
< div style = { {
149
147
...shapeComponentStyles ,
150
148
...invisibleBorderStyles ,
@@ -165,7 +163,7 @@ export default function RoundDiv({style, children, dontConvertShadow, ...props})
165
163
< div style = { {
166
164
height : height - ( widenedBorderWidth [ 0 ] + widenedBorderWidth [ 2 ] ) ,
167
165
width : width - ( widenedBorderWidth [ 1 ] + widenedBorderWidth [ 3 ] ) ,
168
- transform : `translate(-${ padding [ 3 ] + border . width [ 3 ] } px, -${ padding [ 0 ] + border . width [ 0 ] } px)` ,
166
+ transform : `translate(-${ border . width [ 3 ] } px, -${ border . width [ 0 ] } px)` ,
169
167
clipPath : `path("M0,0V${ height } H${ width } V0Z${ innerPath } ")` ,
170
168
borderRadius : radius . map ( n => ( n * .95 ) + 'px' ) . join ( ' ' ) ,
171
169
borderColor : border . color ,
@@ -181,13 +179,14 @@ export default function RoundDiv({style, children, dontConvertShadow, ...props})
181
179
} } />
182
180
</ div >
183
181
< div style = { {
184
- height : height - ( border . width [ 0 ] + border . width [ 2 ] ) * 2 ,
185
- width : width - ( border . width [ 1 ] + border . width [ 3 ] ) * 2 ,
182
+ display : 'inline-flex' ,
186
183
...invisibleBorderStyles ,
187
- transform : `translate(- ${ padding [ 3 ] + border . width [ 3 ] } px, - ${ padding [ 0 ] + border . width [ 0 ] } px)` ,
184
+ padding : padding . map ( n => n + 'px' ) . join ( ' ' ) ,
188
185
clipPath : overflow === 'hidden' ? `path("${ innerPath } ")` : null ,
189
- } } >
190
- < slot style = { { overflow : 'visible' } } />
186
+ transform : `translate(-${ border . width [ 3 ] } px, -${ border . width [ 0 ] } px)` ,
187
+ boxSizing : 'border-box' ,
188
+ } } ref = { slotWrapper } >
189
+ < slot />
191
190
</ div >
192
191
</ div >
193
192
</ ShadowRoot > }
0 commit comments