Skip to content

Commit

Permalink
fix(components, documentation): z-index on header + fake content on h…
Browse files Browse the repository at this point in the history
…eader preview
  • Loading branch information
leagrdv committed Dec 30, 2024
1 parent ca1d4c5 commit 9993e01
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 51 deletions.
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 @@ -197,6 +197,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,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,7 @@ const meta: MetaComponent = {
},
args: {},
argTypes: {},
decorators: [story => html` ${story()} ${fakeContent()} `],
};

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 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

0 comments on commit 9993e01

Please sign in to comment.