Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(components, documentation): z-index on header + fake content on header preview #4367

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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/nervous-mangos-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-components': patch
---

Added z-index to the `post-header` component to display it on top of other contents.
5 changes: 5 additions & 0 deletions .changeset/tough-bikes-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-documentation': patch
---

Added fake content on the header preview to show the sticky behaviour.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
--main-header-height: 56px;
--header-height: calc(var(--global-header-height) + var(--main-header-height));

z-index: 1020;

@include media.min(lg) {
display: block;
position: sticky;
Expand All @@ -27,6 +29,7 @@
@include media.max(lg) {
--global-header-height: 64px;
--main-header-height: 48px;
position: relative;
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/documentation/.storybook/styles/preview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ $monospace: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier
}

.fake-content {
margin-block: var(--post-core-dimension-32) !important;
position: relative;
min-height: calc(1.6rem * 8);
background: repeating-linear-gradient(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { StoryContext, StoryFn, StoryObj } from '@storybook/web-components';
import { MetaComponent } from '@root/types';
import { html } from 'lit';
import { fakeContent } from '@/utils';

const meta: MetaComponent = {
id: '1a1b4cab-d0a8-4b01-bd85-b70e18668cb5',
Expand All @@ -23,25 +24,7 @@ const meta: MetaComponent = {
environment="int01"
language="en"
></swisspost-internet-header>
<div class="container">
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
</div>
${fakeContent(17)}
<post-back-to-top />
</div>`,
decorators: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Canvas, Controls, Meta } from '@storybook/blocks';
import * as HeaderStories from './header.stories';
import './header.scss';

<Meta of={HeaderStories} />

Expand All @@ -11,9 +12,7 @@ import * as HeaderStories from './header.stories';
</nav>
</div>

<div className="lead">
The header of the Post.
</div>
<div className="lead">The header of the Post.</div>

<Canvas sourceState="shown" of={HeaderStories.Default} />
<div className="hide-col-default">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#storybook-docs {
.header-story-wrapper {
max-height: 20rem !important;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { StoryObj } from '@storybook/web-components';
import { MetaComponent } from '@root/types';
import HeaderMarkup from './components/header.markup';
import { html } from 'lit';
import { fakeContent } from '@/utils';

const meta: MetaComponent = {
id: 'header',
Expand All @@ -16,6 +18,9 @@ const meta: MetaComponent = {
},
args: {},
argTypes: {},
decorators: [
story => html` <div class="header-story-wrapper">${story()} ${fakeContent()}</div> `,
],
};

export default meta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,6 @@
}
}

// Used for internet header stories
.fake-content {
position: relative;
min-height: calc(1.6rem * 8);
background: repeating-linear-gradient(
rgb(230, 230, 230),
rgb(230, 230, 230) 1rem,
transparent 1rem,
transparent 1.6rem
);

&::after {
content: '';
background: white;
width: 33%;
height: 1.7rem;
display: block;
position: absolute;
bottom: 0;
right: 0;
}
}

.paragraph {
margin-top: 1em;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Args, StoryContext, StoryObj, WebComponentsRenderer } from '@storybook/web-components';
import { html } from 'lit';
import { spreadArgs } from '@/utils';
import { fakeContent, spreadArgs } from '@/utils';
import customConfig from './config/custom-config';
import osFlyoutOverrides from './config/os-flyout-overrides';
import languageSwitchOverrides from './config/language-switch-overrides';
Expand Down Expand Up @@ -164,14 +164,7 @@ const meta: MetaComponent = {
class="header-story-wrapper"
style="--header-z-index: 1;overflow: auto;max-height: 100svh;"
>
${story()}
<div class="container">
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
<p class="fake-content my-32"></p>
</div>
${story()} ${fakeContent()}
</div>
`,
],
Expand Down
7 changes: 7 additions & 0 deletions packages/documentation/src/utils/fake-content.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { html } from 'lit-html';

export function fakeContent(paragraphs = 6) {
return html`<div class="container">
${Array.from({ length: paragraphs }).map(() => html`<p aria-hidden="true" class="fake-content"></p>`)}
</div>`;
}
1 change: 1 addition & 0 deletions packages/documentation/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './bomb-args';
export * from './component-properties';
export * from './fake-content';
export * from './get-attributes';
export * from './storybook-indexer';
export * from './map-classes';
Expand Down
Loading