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

chore(documentation): complete internet header docs #1855

Merged
merged 35 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
18de644
chore(documentation): fix badges on internet-header documentation pages
alizedebray Aug 21, 2023
65e9d94
chore(documentation): fix comments in internet-header migration guide…
alizedebray Aug 21, 2023
996c4e0
chore(documentation): move reusable function to utils
alizedebray Aug 21, 2023
6ae493f
Merge branch 'main' into 1700-complete-internet-header-docs
alizedebray Aug 22, 2023
c6b7ac8
temp
alizedebray Aug 22, 2023
bfe9bad
Merge branch 'main' into 1700-complete-internet-header-docs
gfellerph Sep 4, 2023
ef144cb
feat: add example header story with controls
gfellerph Sep 4, 2023
b3a8fe2
fix: enable nested scroll container for stickyness and logo animation
gfellerph Sep 4, 2023
ae893a1
chore: adds fullscreen layout to container if specified in params
gfellerph Sep 4, 2023
172f2e2
chore: update lockfile
gfellerph Sep 4, 2023
ad77069
Merge branch 'main' into 1700-complete-internet-header-docs
gfellerph Sep 6, 2023
9afc134
fix: update header docs
gfellerph Sep 6, 2023
ab44c03
docs: update breadcrumbs docs
gfellerph Sep 6, 2023
1e6abca
update footer stories
gfellerph Sep 7, 2023
05db329
Merge branch 'main' into 1700-complete-internet-header-docs
gfellerph Sep 7, 2023
27418a9
Update getting-started.docs.mdx
gfellerph Sep 7, 2023
e82a806
fix custom config for the footer
gfellerph Sep 7, 2023
82e9954
fix some of the cypress tests
gfellerph Sep 7, 2023
06083e7
test: fixed e2e tests
gfellerph Sep 8, 2023
32c86c1
Update packages/documentation/src/stories/internet-header/components/…
gfellerph Sep 8, 2023
8d5019c
Merge branch 'main' into 1700-complete-internet-header-docs
imagoiq Sep 21, 2023
55f7f03
Fix preview order
imagoiq Sep 21, 2023
8c10101
Rename breadcrumbs stories to ts
imagoiq Sep 21, 2023
7330f3b
Remove unnecessary statement
imagoiq Sep 21, 2023
d68eae4
Fix display of contact button
imagoiq Sep 21, 2023
8b45598
Fix missing semi-colons
imagoiq Sep 21, 2023
2238583
Update .changeset/olive-zebras-dress.md
imagoiq Sep 21, 2023
3207738
Fix file extension
imagoiq Sep 21, 2023
066d7b9
Add type + required to project argTypes
imagoiq Sep 21, 2023
d5d1957
Try to fix e2e not working in ci
imagoiq Sep 21, 2023
f8e7d56
Fix e2e stickyness tests
imagoiq Sep 21, 2023
7c8adf0
Update pnpm lock
imagoiq Sep 21, 2023
ebc89c1
Fix container
imagoiq Sep 21, 2023
28f3db8
Fix sonar code smells
imagoiq Sep 21, 2023
43acbee
Type declaration
imagoiq Sep 21, 2023
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/olive-zebras-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/internet-header': minor
---

Enabled nesting the header in a different scroll container than the `<body>` element. The header stickyness and logo animation logic will automatically attach to the nearest scrolling container instead of the document when nested in a container that has `overflow: auto | scroll` set.
5 changes: 5 additions & 0 deletions .changeset/quick-feet-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/internet-header': patch
---

Fixed an issue with custom configuration that was not applied when the prop "language" was not set on the internet header.
15 changes: 10 additions & 5 deletions packages/documentation/.storybook/blocks/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocsContainer, DocsContainerProps, Unstyled } from '@storybook/blocks';
import React, { PropsWithChildren } from 'react';
import { PropsWithChildren } from 'react';
import '../styles/layout.scss';
import Footer from './footer';
import Header from './header';
Expand All @@ -12,13 +12,18 @@ function shouldShowFooter() {
return window.location !== window.parent.location;
}

export default ({ children, context }: PropsWithChildren<DocsContainerProps>) => {
export default (props: PropsWithChildren<DocsContainerProps>) => {
const { children, context } = props;
const container =
context.channel.data.docsPrepared[0].parameters.layout === 'fullscreen'
? 'container-fluid'
: 'container';
return (
<DocsContainer context={context}>
<Unstyled>
{shouldShowHeader() && <Header/>}
<div className="container">{children}</div>
{shouldShowFooter() && <Footer/>}
{shouldShowHeader() && <Header />}
<div className={container}>{children}</div>
{shouldShowFooter() && <Footer />}
</Unstyled>
</DocsContainer>
);
Expand Down
1 change: 0 additions & 1 deletion packages/documentation/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const config: StorybookConfig = {
backgrounds: false,
highlight: false,
outline: false,
toolbars: false,
},
},
'@storybook/addon-links',
Expand Down
8 changes: 1 addition & 7 deletions packages/documentation/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ const preview: Preview = {
['Typography', 'Color', 'Layout', 'Elevation', 'Accessibility'],
'Components',
'Internet Header',
[
'Getting Started',
'Migration Guide',
'Header Component',
'Breadcrumbs Component',
'Footer Component',
],
['Getting Started', 'Migration Guide', 'Header', 'Breadcrumbs', 'Footer'],
'Intranet Header',
['Getting Started'],
'Icons',
Expand Down
22 changes: 22 additions & 0 deletions packages/documentation/.storybook/styles/preview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,25 @@
}
}
}

.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;
}
}
oliverschuerch marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Canvas, Controls, Meta } from '@storybook/blocks';
import * as BreadcrumbsStories from './breadcrumbs.stories';

<Meta of={BreadcrumbsStories} />

# Breadcrumbs

<div className="lead">Indicate the current page’s location within the navigational hierarchy.</div>

The breadcrumbs element usually needs to be placed in a container so it only spans the width of the content.

<Canvas of={BreadcrumbsStories.Default} />

<Controls of={BreadcrumbsStories.Default} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Meta, StoryObj } from '@storybook/web-components';
import { html } from 'lit';
import { spread } from '@open-wc/lit-helpers';
import { BADGE } from '../../../../../.storybook/constants';
import { getAttributes } from '../../../../utils';
import customItems from './overrides/custom-items';

const meta: Meta<HTMLSwisspostInternetBreadcrumbsElement> = {
title: 'Internet Header/Breadcrumbs',
component: 'swisspost-internet-breadcrumbs',
render: renderInternetBreadcrumbs,
decorators: [hiddenHeader],
parameters: {
badges: [BADGE.STABLE],
},
argTypes: {
customItems: {
name: 'custom-items',
control: 'object',
description:
"Add custom breadcrumb items to the end of the pre-configured list. Handy if your online service has it's own navigation structure.",
table: {
type: {
summary: 'IBreadcrumbItem',
detail: JSON.stringify(customItems),
},
},
},
},
};

export default meta;

// DECORATORS
function hiddenHeader(story: any) {
return html`
<swisspost-internet-header project="test" hidden></swisspost-internet-header>
${story()}
`;
}

// RENDERER
function renderInternetBreadcrumbs(args: Partial<HTMLSwisspostInternetBreadcrumbsElement>) {
const attributes = getAttributes(args, arg => arg !== null && arg !== undefined);
return html`
<swisspost-internet-breadcrumbs ${spread(attributes)}></swisspost-internet-breadcrumbs>
`;
}

// STORIES
type Story = StoryObj<HTMLSwisspostInternetBreadcrumbsElement>;

export const Default: Story = {};

export const CustomItems: Story = {
args: {
customItems: customItems,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Canvas, Controls, Meta } from '@storybook/blocks';
import * as BreadcrumbStories from './breadcrumbs-config.stories';

<Meta of={BreadcrumbStories} />

# Breadcrumbs with custom items

<div className="lead">When you need to add your own breadcrumb items.</div>

<Canvas of={BreadcrumbStories.Default} />

<Controls of={BreadcrumbStories.Default} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as BreadcrumbsStories from '../breadcrumbs.stories';

export default { ...BreadcrumbsStories.default, title: 'Internet Header/Breadcrumbs/Custom Items' };

export const Default = BreadcrumbsStories.CustomItems;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default [
{ text: 'X', url: '/x' },
{ text: 'XY', url: '/x/xy' },
{ text: 'XYZ', url: '/x/xy/xyz' },
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const footerBlock = (lang: string) => ({
footer: {
block: {
title: `Eigene Footer-Konfiguration (${lang})`,
links: [
{ url: 'https://fireship.io', text: 'Fireship.io', target: '_blank' },
{ url: 'https://css-tricks.com', text: 'CSS-Tricks', target: '_blank' },
{ url: 'https://web.dev', text: 'web.dev', target: '_blank' },
{ url: 'https://developer.mozilla.org', text: 'MDN Web Docs', target: '_blank' },
{ url: 'https://getbootstrap.com', text: 'Bootstrap', target: '_blank' },
{ url: 'https://google.com', text: 'Google', target: '_blank' },
{ url: 'https://microsoft.com', text: 'Microsoft', target: '_blank' },
],
},
},
});

export default {
de: footerBlock('de'),
fr: footerBlock('fr'),
it: footerBlock('it'),
en: footerBlock('en'),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Canvas, Controls, Meta } from '@storybook/blocks';
import * as FooterConfig from './footer-config.stories';

<Meta of={FooterConfig} />

<div className="container">
<h1>Footer with custom config</h1>
<div className="lead">When you need to add your own footer links.</div>
</div>

<Canvas of={FooterConfig.Default} />

<div className="container">
<Controls of={FooterConfig.Default} />
</div>
imagoiq marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as FooterStories from '../footer.stories';

export default { ...FooterStories.default, title: 'Internet Header/Footer/Custom Config' };

export const Default = FooterStories.CustomConfig;
oliverschuerch marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Canvas, Controls, Meta } from '@storybook/blocks';
import * as FooterStories from './footer.stories';

<Meta of={FooterStories} />

<div className="container">
<h1>Footer</h1>
<div className="lead">
Provides key app-wide information such as contact details and legal links.
</div>
<p>The footer comes with its own container and can be placed at the end of your content.</p>
</div>

<Canvas of={FooterStories.Default} />

<div className="container">
<Controls of={FooterStories.Default} />
</div>
imagoiq marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Args, Meta, StoryContext, StoryObj } from '@storybook/web-components';
import { html } from 'lit';
import { BADGE } from '../../../../../.storybook/constants';
import customFooterConfig from './custom-config/custom-footer-config';
import { spread } from '@open-wc/lit-helpers';

const meta: Meta = {
title: 'Internet Header/Footer',
component: 'swisspost-internet-footer',
render: renderInternetFooter,
decorators: [hiddenHeader],
parameters: {
layout: 'fullscreen',
badges: [BADGE.STABLE],
},
argTypes: {
customConfig: {
control: 'object',
table: {
type: {
summary: 'ICustomConfig',
detail: JSON.stringify(customFooterConfig),
},
},
},
},
};

export default meta;

// DECORATORS
function hiddenHeader(story: any, { args }: StoryContext) {
return html`
<style>
swisspost-internet-header {
display: none;
}
</style>
${story()}
`;
}

// RENDERER
function renderInternetFooter(args: Args) {
const props = args.customConfig ? { 'custom-config': JSON.stringify(args.customConfig) } : {};
return html`
<swisspost-internet-header ${spread(props)} project="test"></swisspost-internet-header>
<swisspost-internet-footer></swisspost-internet-footer>
`;
}

// STORIES
type Story = StoryObj;

export const Default: Story = {};

export const CustomConfig: Story = {
args: {
customConfig: customFooterConfig,
},
};
Loading
Loading