@@ -36,7 +36,7 @@ const AppBar = ({
36
36
37
37
const hasHeadlineExpandedElement = findSlotProp (
38
38
children ,
39
- "headline-expanded" ,
39
+ "headline-expanded"
40
40
) ;
41
41
const _headlineExpandedElement = headlineExpandedElement
42
42
? headlineExpandedElement
@@ -79,7 +79,12 @@ const AppBar = ({
79
79
setIsHeadlineExpandedVisible ( entry . isIntersecting ) ;
80
80
onExpansionChange ?.( ! entry . isIntersecting ) ;
81
81
} ) ;
82
- } ) ;
82
+ } ,
83
+ {
84
+ rootMargin : "-20px 0px" ,
85
+ threshold : 0 ,
86
+ }
87
+ ) ;
83
88
observer . observe ( headlineExpandedRef . current ) ;
84
89
}
85
90
return ( ) => {
@@ -91,39 +96,47 @@ const AppBar = ({
91
96
< >
92
97
< div
93
98
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
95
100
showExpandedHeadline && isHeadlineExpandedVisible
96
101
? "pt-3 pb-0"
97
102
: "py-3" ,
98
- className ,
103
+ className
99
104
) }
100
105
{ ...props }
101
106
>
102
107
< div
103
108
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
+ ) }
105
113
>
106
114
{ _leadingElements }
107
115
</ div >
108
116
109
117
< div
110
118
id = "headline"
111
119
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" ,
116
126
showExpandedHeadline && isHeadlineExpandedVisible
117
127
? "opacity-0"
118
- : "opacity-100" ,
128
+ : "opacity-100"
119
129
) }
120
130
>
121
131
{ _headlineElement }
122
132
</ div >
123
133
124
134
< div
125
135
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
+ ) }
127
140
>
128
141
{ _trailingElements }
129
142
</ div >
@@ -137,8 +150,8 @@ const AppBar = ({
137
150
ref = { headlineExpandedRef }
138
151
className = { twMerge (
139
152
"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"
142
155
) }
143
156
>
144
157
{ _headlineExpandedElement }
0 commit comments