Skip to content

Commit 9f7e069

Browse files
authored
feat(components, docs): add user menu to the post-header (#6402)
## 📄 Description - Added the user menu to the `post-header` component - Added the option in storybook to have the login within the custom controls for the future but disabled it for now ## 🚀 Demo https://preview-6402--swisspost-design-system-next.netlify.app/iframe.html?args=isLoggedIn%3A!true&globals=&viewMode=story&id=27a2e64d-55ba-492d-ab79-5f7c5e818498--default --- ## 🔮 Design review - [x] Design review done - [ ] No design review needed ## 📝 Checklist - ✅ My code follows the style guidelines of this project - 🛠️ I have performed a self-review of my own code - 📄 I have made corresponding changes to the documentation - ⚠️ My changes generate no new warnings or errors - 🧪 I have added tests that prove my fix is effective or that my feature works - ✔️ New and existing unit tests pass locally with my changes
1 parent 06b42f6 commit 9f7e069

File tree

22 files changed

+337
-156
lines changed

22 files changed

+337
-156
lines changed

.changeset/crazy-onions-jam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@swisspost/design-system-components': patch
3+
---
4+
5+
Updated styles of the `post-menu-item` component, which is used in both the new user menu and the `post-breadcrumbs` dropdown menu when breadcrumb items are concatenated.

.changeset/new-months-cross.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@swisspost/design-system-documentation': minor
3+
'@swisspost/design-system-components': minor
4+
'@swisspost/design-system-styles': minor
5+
---
6+
7+
Added the user menu for logged in users in the `post-header` component.

.changeset/weak-places-scream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@swisspost/design-system-components': patch
3+
---
4+
5+
Removed the hover border color from `post-avatar` to maintain design consistency.

packages/components/cypress/fixtures/post-mainnavigation-overflow.test.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<!-- Menu button for mobile -->
2626
<post-togglebutton slot="post-togglebutton">
27-
<span class="visually-hidden-sm">Menu</span>
27+
<span>Menu</span>
2828
<post-icon aria-hidden="true" name="burger" data-showWhen="untoggled"></post-icon>
2929
<post-icon aria-hidden="true" name="closex" data-showWhen="toggled"></post-icon>
3030
</post-togglebutton>
@@ -49,21 +49,20 @@ <h1 slot="title">Application title</h1>
4949
<ul class="list-inline">
5050
<li>
5151
<a href="#">
52-
<span class="visually-hidden-sm">Search</span>
52+
<span>Search</span>
5353
<post-icon aria-hidden="true" name="search"></post-icon>
5454
</a>
5555
</li>
5656
<li>
5757
<a href="#">
58-
<span class="visually-hidden-sm">Login</span>
58+
<span>Login</span>
5959
<post-icon aria-hidden="true" name="login"></post-icon>
6060
</a>
6161
</li>
6262
</ul>
6363

6464
<!-- Main navigation -->
6565
<post-mainnavigation caption="Hauptnavigation">
66-
6766
<post-list title-hidden="">
6867
<h2>Main Navigation</h2>
6968

packages/components/cypress/fixtures/post-mainnavigation.test.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<!-- Menu button for mobile -->
2626
<post-togglebutton slot="post-togglebutton">
27-
<span class="visually-hidden-sm">Menu</span>
27+
<span>Menu</span>
2828
<post-icon aria-hidden="true" name="burger" data-showWhen="untoggled"></post-icon>
2929
<post-icon aria-hidden="true" name="closex" data-showWhen="toggled"></post-icon>
3030
</post-togglebutton>
@@ -49,21 +49,20 @@ <h1 slot="title">Application title</h1>
4949
<ul class="list-inline">
5050
<li>
5151
<a href="#">
52-
<span class="visually-hidden-sm">Search</span>
52+
<span>Search</span>
5353
<post-icon aria-hidden="true" name="search"></post-icon>
5454
</a>
5555
</li>
5656
<li>
5757
<a href="#">
58-
<span class="visually-hidden-sm">Login</span>
58+
<span>Login</span>
5959
<post-icon aria-hidden="true" name="login"></post-icon>
6060
</a>
6161
</li>
6262
</ul>
6363

6464
<!-- Main navigation -->
6565
<post-mainnavigation caption="Hauptnavigation">
66-
6766
<post-list title-hidden="">
6867
<h2>Main Navigation</h2>
6968

packages/components/src/components/post-avatar/post-avatar.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ img,
6464
border-radius: tokens.get('avatar-border-radius');
6565
color: var(--post-avatar-fg);
6666
text-transform: uppercase;
67+
font-weight: 400;
6768

6869
span {
6970
@include post.visuallyhidden();

packages/components/src/components/post-header/post-header.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
.global-sub {
7878
display: flex;
7979
align-items: center;
80-
gap: 24px;
80+
gap: 4px;
8181

8282
@include media.min(lg) {
8383
// targets the right links and language switch to hide them on scroll

packages/components/src/components/post-header/post-header.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { EventFrom } from '@/utils/event-from';
1616
* @slot default - Custom controls or content, right aligned in the local header.
1717
* @slot post-mainnavigation - Has a default slot because it's only meant to be used in the `<post-header>`.
1818
* @slot target-group - Holds the list of buttons to choose the target group.
19+
* @slot global-login - Holds the user menu or login button in the global header.
1920
*/
2021

2122
@Component({
@@ -398,6 +399,7 @@ export class PostHeader {
398399
)}
399400
<slot name="global-controls"></slot>
400401
{!this.hasMobileMenu && <slot name="post-language-switch"></slot>}
402+
<slot name="global-login"></slot>
401403
{this.hasNavigation && (
402404
<div onClick={() => this.toggleMobileMenu()} class="mobile-toggle">
403405
<slot name="post-togglebutton"></slot>

packages/components/src/components/post-header/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Type: `Promise<void>`
2929
| Slot | Description |
3030
| ------------------------ | ----------------------------------------------------------------------------- |
3131
| `"default"` | Custom controls or content, right aligned in the local header. |
32+
| `"global-login"` | Holds the user menu or login button in the global header. |
3233
| `"meta-navigation"` | Holds an `<ul>` with meta navigation links. |
3334
| `"post-language-switch"` | Should be used with the `<post-language-switch>` component. |
3435
| `"post-logo"` | Should be used together with the `<post-logo>` component. |
Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
@use '@swisspost/design-system-styles/mixins/button';
22
@use '@swisspost/design-system-styles/mixins/media';
3-
@use '@swisspost/design-system-styles/mixins/utilities';
4-
@use '@swisspost/design-system-styles/variables/animation';
53

64
post-menu-item {
75
button {
@@ -18,51 +16,48 @@ post-menu-item {
1816
display: flex;
1917
width: 100%;
2018
align-items: center;
21-
padding: .5rem 1rem;
22-
gap: .5rem;
23-
font-size: 1rem;
19+
padding: 0.5rem 0.75rem 0.5rem 1rem;
20+
gap: 0.5rem;
21+
font-size: 0.875rem;
2422
color: #050400;
25-
transition: color animation.$transition-base-timing;
26-
outline-offset: 0;
23+
border-radius: 0;
2724

28-
&:has(post-icon:last-child) {
29-
padding-inline-end: .75rem;
25+
post-icon {
26+
width: 1.25rem;
27+
height: 1.25rem;
28+
margin: 0.125rem;
3029
}
3130

32-
@include media.min(lg) {
33-
font-size: 1.25rem;
31+
@include media.min(md) {
32+
font-size: 1rem;
33+
padding-block: 0.75rem;
34+
gap: 1rem;
35+
36+
post-icon {
37+
width: 1.375rem;
38+
height: 1.375rem;
39+
margin: 0;
40+
}
3441
}
3542

36-
@include media.min(xs) {
37-
padding-block: .75rem;
43+
@include media.min(lg) {
44+
font-size: 1.25rem;
45+
padding-block: 0.8125rem;
3846

39-
& > post-icon:last-child {
40-
margin-inline-start: .5rem;
47+
post-icon {
48+
width: 1.5rem;
49+
height: 1.5rem;
4150
}
4251
}
4352

4453
&:focus-visible {
45-
outline-offset: -2px !important;
54+
outline-offset: 2px !important;
4655
border-radius: 4px;
4756
}
4857

49-
&::after {
50-
content: "";
51-
display: block;
52-
position: absolute;
53-
inset-block-end: 0;
54-
inset-inline: 0;
55-
height: 3px;
56-
background-color: transparent;
57-
transition: background-color animation.$transition-base-timing;
58-
}
59-
6058
&:hover {
61-
color: #504F4B;
62-
63-
&::after {
64-
background-color: currentColor;
65-
}
59+
background-color: #504f4b;
60+
color: #fff;
6661
}
6762
}
6863
}

0 commit comments

Comments
 (0)