Skip to content
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5d07337
parametrized fade animation and removed css animation
myrta2302 Nov 27, 2025
cb7a7ee
revert closing duration
myrta2302 Nov 28, 2025
8926d11
update mobile and create temp preview story
myrta2302 Nov 28, 2025
5a4d65b
fix e2e error
myrta2302 Nov 28, 2025
38f5d6c
update show
myrta2302 Nov 28, 2025
e6ba180
revert doc example
myrta2302 Nov 28, 2025
1b564c2
Merge branch 'main' into 6589-header-portal-adjust-microanimation-forโ€ฆ
myrta2302 Nov 28, 2025
d20492d
small improvements
myrta2302 Nov 28, 2025
010f470
Merge branch '6589-header-portal-adjust-microanimation-for-megamenu-oโ€ฆ
myrta2302 Nov 28, 2025
468f235
add changeset
myrta2302 Nov 28, 2025
285a582
temp example with faster animation 350ms
myrta2302 Dec 2, 2025
422b601
Merge branch 'main' into 6589-header-portal-adjust-microanimation-forโ€ฆ
myrta2302 Dec 2, 2025
21edb2d
create temp animation play story
myrta2302 Dec 2, 2025
f569b4f
Merge branch '6589-header-portal-adjust-microanimation-for-megamenu-oโ€ฆ
myrta2302 Dec 2, 2025
223edce
update example
myrta2302 Dec 3, 2025
e67bc6a
revert temp example
myrta2302 Dec 10, 2025
396ae29
update megadropdown and header animation params
myrta2302 Dec 10, 2025
e257108
update animation files
myrta2302 Dec 10, 2025
9a1f1c1
udpate animations
myrta2302 Dec 10, 2025
df2f24d
more animations update
myrta2302 Dec 10, 2025
dc6f610
udpate megadropdown animation
myrta2302 Dec 10, 2025
3bc52fe
update animation slidepx
myrta2302 Dec 10, 2025
7d3d665
Merge branch 'main' into 6589-header-portal-adjust-microanimation-forโ€ฆ
myrta2302 Dec 10, 2025
f00864e
update fade-slide animation
myrta2302 Dec 10, 2025
85a71e1
fix slide translate value
myrta2302 Dec 10, 2025
03babbd
revert files
myrta2302 Dec 10, 2025
36c02ef
improve code
myrta2302 Dec 11, 2025
703e3f6
fix error and revert files
myrta2302 Dec 11, 2025
7423c16
lint error
myrta2302 Dec 11, 2025
5984025
minor updates
myrta2302 Dec 11, 2025
1ee5a15
Merge branch 'main' into 6589-header-portal-adjust-microanimation-forโ€ฆ
myrta2302 Dec 11, 2025
2ecb7cc
reduce duplicate code
myrta2302 Dec 12, 2025
97c80cc
deduplicate animation function code
myrta2302 Dec 12, 2025
c1f35e6
update types
myrta2302 Dec 12, 2025
cced124
deduplicate megardopdown code
myrta2302 Dec 15, 2025
e5cce77
Delete packages/internet-header/cypress/downloads/downloads.htm
myrta2302 Dec 15, 2025
f96fa98
fix error
myrta2302 Dec 15, 2025
c9279ac
Merge branch '6589-header-portal-adjust-microanimation-for-megamenu-oโ€ฆ
myrta2302 Dec 15, 2025
5eeca5b
revert
myrta2302 Dec 15, 2025
4167930
partial revert
myrta2302 Dec 15, 2025
e67c074
update action sequence
myrta2302 Dec 15, 2025
db010e2
cancel all animations on breakpoint change
myrta2302 Dec 15, 2025
45377b7
rename
myrta2302 Dec 15, 2025
76b21f1
deduplicate reset actions
myrta2302 Dec 15, 2025
2fb7038
small updates
myrta2302 Dec 15, 2025
92cec0b
update megadropdown
myrta2302 Dec 15, 2025
61481aa
Merge branch 'main' into 6589-header-portal-adjust-microanimation-forโ€ฆ
myrta2302 Dec 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/young-states-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-components': patch
---

Updated the Header to use the new dissolve animation.
2 changes: 1 addition & 1 deletion packages/components/cypress/e2e/header.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('header', () => {
// Check if animation class is present
cy.get('post-megadropdown .megadropdown-container')
.should('be.visible')
.should('have.class', 'slide-in');
.should('have.css', 'opacity', '1');
});

it('should update active class when active link changes within the same or different megadropdown', () => {
Expand Down
74 changes: 74 additions & 0 deletions packages/components/src/animations/fade-slide.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Used by
* 1. PostHeader (mobile)
* 2. PostMegadropdown
*/

import { CurveEasing, PresetEasing, FadeSlideOptions } from './types';

const defaultOptions: FadeSlideOptions = {
translateY: -10,
duration: 300,
easing: 'linear',
fill: 'forwards',
};

function resolveEasing(easing: CurveEasing | PresetEasing): string {
if (typeof easing === 'string') return easing;
const { x1, y1, x2, y2 } = easing;
return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`;
}

export function fadeSlideIn(el: Element, options: FadeSlideOptions = {}): Animation {
if (!el) return;

const { translateY, duration, easing, fill } = {
...defaultOptions,
...options,
};

return el.animate(
[
{
opacity: '0',
transform: `translateY(${translateY}px)`,
},
{
opacity: '1',
transform: 'translateY(0px)',
},
],
{
duration: duration,
easing: resolveEasing(easing),
fill: fill,
},
);
}

export function fadeSlideOut(el: Element, options: FadeSlideOptions): Animation {
if (!el) return;

const { translateY, duration, easing, fill } = {
...defaultOptions,
...options,
};

return el.animate(
[
{
opacity: '1',
transform: 'translateY(0)',
},
{
opacity: '0',
transform: `translateY(${translateY}px)`,
},
],
{
duration: duration,
easing: resolveEasing(easing),
fill: fill,
},
);
}
2 changes: 2 additions & 0 deletions packages/components/src/animations/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './fade';
export * from './slide';
export * from './fade-slide';
62 changes: 35 additions & 27 deletions packages/components/src/animations/slide.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
const easing: string = 'ease';
const duration: number = 500;
const fill: FillMode = 'forwards';
/**
* Used by PostMegadropdown
*/

export function slideUp(el: HTMLElement, translateSize: string = '-100%'): Animation {
return el.animate(
[
{ transform: 'translateY(0)' }, // Starting position (no translation)
{ transform: `translateY(${translateSize})` }, // End position
],
{
duration: duration,
easing,
fill,
},
);
import { SlideOptions } from './types';

// Global defaults
const defaultSlideOptions: SlideOptions = {
translateX: 100,
duration: 500,
easing: 'ease',
fill: 'forwards',
};

export function slideIn(el: HTMLElement, options: SlideOptions = {}): Animation {
const { translateX, duration, easing, fill } = {
...defaultSlideOptions,
...options,
};

return el.animate([{ transform: `translateX(${translateX}%)` }, { transform: 'translateX(0)' }], {
duration,
easing,
fill,
});
}

export function slideDown(el: HTMLElement, translateSize: string = '-100%'): Animation {
return el.animate(
[
{ transform: `translateY(${translateSize})` }, // Starting position (no translation)
{ transform: 'translateY(0)' }, // End position
],
{
duration: duration,
easing,
fill,
},
);
export function slideOut(el: HTMLElement, options: SlideOptions = {}): Animation {
const { translateX, duration, easing, fill } = {
...defaultSlideOptions,
...options,
};

return el.animate([{ transform: 'translateX(0)' }, { transform: `translateX(${translateX}%)` }], {
duration,
easing,
fill,
});
}
22 changes: 22 additions & 0 deletions packages/components/src/animations/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export type CurveEasing = {
x1: number;
y1: number;
x2: number;
y2: number;
};

export type PresetEasing = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out';

export interface FadeSlideOptions {
translateY?: number;
duration?: number;
easing?: CurveEasing | PresetEasing;
fill?: FillMode;
}

export interface SlideOptions {
translateX?: number;
duration?: number;
easing?: string;
fill?: FillMode;
}
22 changes: 18 additions & 4 deletions packages/components/src/components/post-header/post-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { throttle } from 'throttle-debounce';
import { version } from '@root/package.json';
import { SwitchVariant } from '@/components';
import { breakpoint, Device } from '@/utils/breakpoints';
import { slideDown, slideUp } from '@/animations/slide';
import { fadeSlideIn, fadeSlideOut } from '@/animations';
import { getFocusableChildren } from '@/utils/get-focusable-children';
import { EventFrom } from '@/utils/event-from';
import { FadeSlideOptions } from '@/animations/types';

/**
* @slot post-logo - Should be used together with the `<post-logo>` component.
Expand Down Expand Up @@ -39,6 +40,17 @@ export class PostHeader {
return this.device !== 'desktop' && this.hasNavigation;
}

private animationOptions: FadeSlideOptions = {
translateY: 0,
duration: 350,
easing: {
x1: 0.8,
y1: 0.2,
x2: 0.8,
y2: 0.7,
},
};

get scrollParent(): HTMLElement {
const frozenScrollParent: HTMLElement | null = document.querySelector(
'[data-post-scroll-locked]',
Expand Down Expand Up @@ -189,8 +201,8 @@ export class PostHeader {
async toggleBurgerMenu(force?: boolean) {
if (this.device === 'desktop') return;
this.burgerMenuAnimation = this.burgerMenuExtended
? slideUp(this.burgerMenu)
: slideDown(this.burgerMenu);
? fadeSlideOut(this.burgerMenu, this.animationOptions)
: fadeSlideIn(this.burgerMenu, this.animationOptions);

// Update the state of the toggle button
const menuButton = this.host.querySelector<HTMLPostTogglebuttonElement>('post-togglebutton');
Expand Down Expand Up @@ -222,7 +234,9 @@ export class PostHeader {
private getFocusableElements() {
// Get elements in the correct order (different as the DOM order)
const focusableEls = [
...Array.from(this.host.querySelectorAll('.list-inline:not([slot="global-nav-secondary"]) > li')),
...Array.from(
this.host.querySelectorAll('.list-inline:not([slot="global-nav-secondary"]) > li'),
),
...Array.from(
this.host.querySelectorAll(
'nav > post-list > div > post-list-item, post-megadropdown-trigger',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,6 @@
@use '@swisspost/design-system-styles/components/header/mixins' as header-mx;
@use '@swisspost/design-system-styles/mixins/utilities';

@keyframes slide-in {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(0%);
}
}

@keyframes slide-out {
from {
transform: translateX(0%);
}
to {
transform: translateX(100%);
}
}

@keyframes slide-down {
from {
transform: translateY(-100%);
}
to {
transform: translateY(0%);
}
}

@keyframes slide-up {
0% {
transform: translateY(0%);
}
100% {
transform: translateY(-100%);
}
}

*,
::before,
::after {
Expand All @@ -60,14 +24,6 @@
border-block-end: 1px solid CanvasText;
}

&.slide-in {
animation: slide-down 350ms forwards;
}

&.slide-out {
animation: slide-up 350ms forwards;
}

@include media.max(lg) {
z-index: 1;
position: absolute;
Expand All @@ -80,14 +36,6 @@
border-block-start: unset;
overflow-y: auto;
overscroll-behavior: contain;

&.slide-in {
animation: slide-in 350ms forwards;
}

&.slide-out {
animation: slide-out 350ms forwards;
}
}

@include media.min(lg) {
Expand Down
Loading
Loading