@@ -14,37 +14,13 @@ import { AxoBaseDialog } from './_internal/AxoBaseDialog.dom.js';
1414import { AxoSymbol } from './AxoSymbol.dom.js' ;
1515import { tw } from './tw.dom.js' ;
1616import { AxoScrollArea } from './AxoScrollArea.dom.js' ;
17- import { getScrollbarGutters } from './_internal/scrollbars.dom.js' ;
1817import { AxoButton } from './AxoButton.dom.js' ;
1918import { AxoIconButton } from './AxoIconButton.dom.js' ;
2019
2120const Namespace = 'AxoDialog' ;
2221
2322const { useContentEscapeBehavior } = AxoBaseDialog ;
2423
25- // We want to have 24px of padding on either side of header/body/footer, but
26- // it's import that we remain aligned with the vertical scrollbar gutters that
27- // we need to measure in the browser to know the value of.
28- //
29- // Chrome currently renders vertical scrollbars as 11px with
30- // `scrollbar-width: thin` but that could change someday or based on some OS
31- // settings. So we'll target 24px but we'll tolerate different values.
32- function getPadding ( target : number , scrollbars : boolean ) : number {
33- const scrollbarWidthExpected = 11 ;
34- const paddingBeforeScrollbarWidth = target - scrollbarWidthExpected ;
35-
36- if ( scrollbars ) {
37- // If this element has scrollbars we should just rely on the rendered gutter
38- return paddingBeforeScrollbarWidth ;
39- }
40-
41- const scrollbarWidthActual = getScrollbarGutters ( 'thin' , 'custom' ) . vertical ;
42-
43- // If this element doesn't have scrollbars, we need to add the exact value of
44- // the actual scrollbar gutter
45- return scrollbarWidthActual + paddingBeforeScrollbarWidth ;
46- }
47-
4824export namespace AxoDialog {
4925 /**
5026 * Component: <AxoDialog.Root>
@@ -140,18 +116,12 @@ export namespace AxoDialog {
140116 } > ;
141117
142118 export const Header : FC < HeaderProps > = memo ( props => {
143- const style = useMemo ( ( ) => {
144- return {
145- paddingInline : getPadding ( 10 , false ) ,
146- } ;
147- } , [ ] ) ;
148119 return (
149120 < div
150121 className = { tw (
151- 'grid items-center py -2.5' ,
122+ 'grid items-center p -2.5' ,
152123 'grid-cols-[[back-slot]_1fr_[title-slot]_auto_[close-slot]_1fr]'
153124 ) }
154- style = { style }
155125 >
156126 { props . children }
157127 </ div >
@@ -204,20 +174,14 @@ export namespace AxoDialog {
204174 } > ;
205175
206176 export const Title : FC < TitleProps > = memo ( props => {
207- const style = useMemo ( ( ) => {
208- return {
209- paddingInline : 24 - getPadding ( 10 , false ) ,
210- } ;
211- } , [ ] ) ;
212177 return (
213178 < Dialog . Title
214179 className = { tw (
215- 'col-[title-slot] py-0.5' ,
180+ 'col-[title-slot] px-3.5 py-0.5' ,
216181 'truncate text-center' ,
217182 'type-body-medium font-semibold text-label-primary' ,
218183 props . screenReaderOnly && 'sr-only'
219184 ) }
220- style = { style }
221185 >
222186 { props . children }
223187 </ Dialog . Title >
@@ -281,14 +245,7 @@ export namespace AxoDialog {
281245 } > ;
282246
283247 export const ExperimentalSearch : FC < ExperimentalSearchProps > = memo ( props => {
284- const style = useMemo ( ( ) => {
285- return { paddingInline : getPadding ( 16 , false ) } ;
286- } , [ ] ) ;
287- return (
288- < div style = { style } className = { tw ( 'pb-2' ) } >
289- { props . children }
290- </ div >
291- ) ;
248+ return < div className = { tw ( 'px-4 pb-2' ) } > { props . children } </ div > ;
292249 } ) ;
293250
294251 ExperimentalSearch . displayName = `${ Namespace } .ExperimentalSearch` ;
@@ -308,9 +265,13 @@ export namespace AxoDialog {
308265 export const Body : FC < BodyProps > = memo ( props => {
309266 const { padding = 'normal' } = props ;
310267
311- const style = useMemo ( ( ) : CSSProperties => {
268+ const style = useMemo ( ( ) : CSSProperties | undefined => {
269+ if ( padding === 'only-scrollbar-gutter' ) {
270+ return ;
271+ }
272+
312273 return {
313- paddingInline : padding === 'normal' ? getPadding ( 24 , true ) : undefined ,
274+ paddingInline : 'calc(24px - var(--axo-scrollbar-gutter-thin-vertical))' ,
314275 } ;
315276 } , [ padding ] ) ;
316277
@@ -358,17 +319,8 @@ export namespace AxoDialog {
358319 } > ;
359320
360321 export const Footer : FC < FooterProps > = memo ( props => {
361- const style = useMemo ( ( ) : CSSProperties => {
362- return {
363- paddingInline : getPadding ( 12 , false ) ,
364- } ;
365- } , [ ] ) ;
366-
367322 return (
368- < div
369- className = { tw ( 'flex flex-wrap items-center gap-3 py-2.5' ) }
370- style = { style }
371- >
323+ < div className = { tw ( 'flex flex-wrap items-center gap-3 px-3 py-2.5' ) } >
372324 { props . children }
373325 </ div >
374326 ) ;
@@ -386,12 +338,10 @@ export namespace AxoDialog {
386338 } > ;
387339
388340 export const FooterContent : FC < FooterContentProps > = memo ( props => {
389- const style = useMemo ( ( ) => {
390- return { paddingInlineStart : 24 - getPadding ( 12 , false ) } ;
391- } , [ ] ) ;
392341 return (
393342 < div
394343 className = { tw (
344+ 'px-3' ,
395345 // Allow the flex layout to place it in the same row as the actions
396346 // if it can be wrapped to fit within the available space:
397347 'basis-[min-content]' ,
@@ -402,7 +352,6 @@ export namespace AxoDialog {
402352 'flex-grow' ,
403353 'type-body-large text-label-primary'
404354 ) }
405- style = { style }
406355 >
407356 { props . children }
408357 </ div >
0 commit comments