Skip to content

Commit 33f90b9

Browse files
authored
feat(ui5-panel): expose header-wrapper part (#13571)
a 'header-wrapper' part is added to allow apps to style the outermost header wrapper, useful for adjusting sticky header position. Related to: #13392
1 parent 73a4a8b commit 33f90b9

4 files changed

Lines changed: 68 additions & 1 deletion

File tree

packages/main/src/Panel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ import panelCss from "./generated/themes/Panel.css.js";
7676
* @extends UI5Element
7777
* @public
7878
* @slot {Array<Node>} default - Defines the content of the component. The content is visible only when the component is expanded.
79-
* @csspart header - Used to style the wrapper of the header.
79+
* @csspart header-wrapper - Used to style the outermost header wrapper, useful for adjusting sticky header position.
80+
* @csspart header - Used to style the header.
8081
* @csspart content - Used to style the wrapper of the content.
8182
*/
8283
@customElement({

packages/main/src/PanelTemplate.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default function PanelTemplate(this: Panel) {
2121
}}
2222
role={this.headingWrapperRole}
2323
aria-level={this.headingWrapperAriaLevel}
24+
part="header-wrapper"
2425
>
2526
<div
2627
onClick={this._headerClick}

packages/main/test/pages/Panel.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,40 @@
175175
</ui5-label>
176176
</ui5-panel>
177177

178+
<br>
179+
180+
<section>
181+
<ui5-title>Sticky Header with Custom Top Offset Demo</ui5-title>
182+
<p>The container below has a fixed toolbar at the top. The panel's sticky header uses <code>::part(header-wrapper) { top: 50px }</code> to stick below the toolbar.</p>
183+
184+
<div id="sticky-demo-container">
185+
<div id="sticky-demo-toolbar">Fixed Toolbar (50px)</div>
186+
<div id="sticky-demo-scroll-area">
187+
<ui5-panel id="panel-stickyHeader-customTop" fixed sticky-header header-text="Sticky header with custom top (50px)">
188+
<ui5-label wrapping-type="Normal">
189+
<span>
190+
Scroll this container to see the sticky header stick at 50px from the top (below the toolbar).
191+
Lorem ipsum dolor sit amet, tamquam invidunt cu sed, unum regione mel ea, quo ea alia novum. Ne qui illud zril
192+
nostrum, vel ea sint dicant postea. Vel ne facete tritani, neglegentur concludaturque sed te. His animal dolorum ut.
193+
Aeterno appareat ei mei, cu sed elit scripserit, an quodsi oportere accusamus quo. Pri ea probo corpora rationibus,
194+
soluta incorrupte ex his.
195+
Mei ei brute cetero, id duo magna aeque torquatos. Quodsi erroribus mediocritatem his ut, ad pri legere iracundia
196+
democritum. Menandri intellegam in mea, ex vero movet qualisque sed. Maiorum verterem perfecto nec ea, est velit
197+
elaboraret consequuntur eu, eam ad reque postea admodum. Ne inimicus convenire pri, doctus vidisse te ius.
198+
Percipitur contentiones in vis, cu vim propriae phaedrum. Has ad magna errem honestatis, duo vero graeco epicurei
199+
no, populo semper sit ne. Vulputate dissentiunt interpretaris ea vis, nec civibus moderatius at. Cu vim stet
200+
dissentias, no vidit saperet indoctum nec, et pro magna prima nobis. Vis consul feugiat qualisque in, regione
201+
persecuti cotidieque id eos, id ius omnesque vituperata.
202+
Pri ex impedit percipit consulatu. Ius iudico feugiat instructior an. Iusto putant eum eu, ubique splendide pri ad,
203+
cu qui salutandi assentior percipitur. At esse ceteros salutandi ius. Te dicam reprehendunt nec, ea discere ponderum
204+
sensibus duo. Vis cu commodo definiebas, postea dissentias ne vim. Modo homero eos ad. Ut vix equidem temporibus.
205+
</span>
206+
</ui5-label>
207+
</ui5-panel>
208+
</div>
209+
</div>
210+
</section>
211+
178212
<br>
179213
<ui5-panel id="panel1" collapsed header-text="Click to expand!" header-level="H3" accessible-role="Form">
180214

packages/main/test/pages/styles/Panel.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,35 @@
1414

1515
#panel-expandable::part(header) {
1616
color: green;
17+
}
18+
19+
#sticky-demo-container {
20+
position: relative;
21+
height: 300px;
22+
border: 1px solid #ccc;
23+
}
24+
25+
#sticky-demo-toolbar {
26+
position: sticky;
27+
top: 0;
28+
height: 50px;
29+
background: #0854a0;
30+
color: white;
31+
display: flex;
32+
align-items: center;
33+
padding: 0 1rem;
34+
z-index: 2;
35+
}
36+
37+
#sticky-demo-scroll-area {
38+
height: 250px;
39+
overflow: auto;
40+
}
41+
42+
#panel-stickyHeader-customTop::part(header-wrapper) {
43+
top: 50px;
44+
}
45+
46+
#panel-stickyHeader-customTop::part(content) {
47+
padding-top: 50px;
1748
}

0 commit comments

Comments
 (0)