@@ -36,7 +36,7 @@ const AppBar = ({
3636
3737 const hasHeadlineExpandedElement = findSlotProp (
3838 children ,
39- "headline-expanded" ,
39+ "headline-expanded"
4040 ) ;
4141 const _headlineExpandedElement = headlineExpandedElement
4242 ? headlineExpandedElement
@@ -79,7 +79,12 @@ const AppBar = ({
7979 setIsHeadlineExpandedVisible ( entry . isIntersecting ) ;
8080 onExpansionChange ?.( ! entry . isIntersecting ) ;
8181 } ) ;
82- } ) ;
82+ } ,
83+ {
84+ rootMargin : "-20px 0px" ,
85+ threshold : 0 ,
86+ }
87+ ) ;
8388 observer . observe ( headlineExpandedRef . current ) ;
8489 }
8590 return ( ) => {
@@ -91,39 +96,47 @@ const AppBar = ({
9196 < >
9297 < div
9398 className = { twMerge (
94- "w-full px-2 flex flex-row justify-between items-center gap-2 left-0 bg-background transition-all" ,
99+ "w-full px-2 flex flex-row justify-between items-center gap-2 left-0 bg-background transition-all relative" , // Added 'relative' here
95100 showExpandedHeadline && isHeadlineExpandedVisible
96101 ? "pt-3 pb-0"
97102 : "py-3" ,
98- className ,
103+ className
99104 ) }
100105 { ...props }
101106 >
102107 < div
103108 id = "leading-actions"
104- className = "flex flex-row justify-center items-center gap-2"
109+ className = { twMerge (
110+ "flex flex-row justify-center items-center gap-2" ,
111+ _variant === "center-aligned" && "flex-1 justify-start"
112+ ) }
105113 >
106114 { _leadingElements }
107115 </ div >
108116
109117 < div
110118 id = "headline"
111119 className = { twMerge (
112- "flex flex-row flex-1 w-full h-full items-center gap-2 text-lg transition-all" ,
113- _variant === "center-aligned" && "justify-center text-center" ,
114- ( _variant === "small" || _variant === "medium" ) &&
115- "justify-start text-left" ,
120+ "absolute left-1/2 transform -translate-x-1/2 flex items-center gap-2 text-lg transition-all" , // Changed this line
121+ _variant === "center-aligned" && "text-center" ,
122+ ( _variant === "small" ||
123+ _variant === "medium" ||
124+ _variant === "large" ) &&
125+ "justify-start text-left w-full" ,
116126 showExpandedHeadline && isHeadlineExpandedVisible
117127 ? "opacity-0"
118- : "opacity-100" ,
128+ : "opacity-100"
119129 ) }
120130 >
121131 { _headlineElement }
122132 </ div >
123133
124134 < div
125135 id = "trailing-actions"
126- className = "flex flex-row justify-center items-center gap-2"
136+ className = { twMerge (
137+ "flex flex-row justify-center items-center gap-2" ,
138+ _variant === "center-aligned" && "flex-1 justify-end"
139+ ) }
127140 >
128141 { _trailingElements }
129142 </ div >
@@ -137,8 +150,8 @@ const AppBar = ({
137150 ref = { headlineExpandedRef }
138151 className = { twMerge (
139152 "flex flex-row text-left w-full px-4 pb-5" ,
140- _variant === "medium" && "text-xl pt-1 " ,
141- _variant === "large" && "text-2xl pt-4" ,
153+ _variant === "medium" && "text-xl pt-2 " ,
154+ _variant === "large" && "text-2xl pt-4"
142155 ) }
143156 >
144157 { _headlineExpandedElement }
0 commit comments