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

docs: pattern for sorry pages #2676

Merged
merged 11 commits into from
Mar 27, 2024
6 changes: 6 additions & 0 deletions .changeset/swift-dragons-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@swisspost/design-system-documentation': minor
'@swisspost/design-system-styles': minor
---

Added a pattern for error pages with an image. Currently available is a graphic for "404 not found" errors. More error types may be supported in the future.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Meta, Canvas } from '@storybook/blocks';
import * as ErrorPageStories from './error-page.stories';

<Meta of={ErrorPageStories} />

# Error page template

A generic error page pattern with an image. The image can be exchanged based on the type of error.

- 404 not found: <a download="/images/content/404.png" href="/images/content/404.png">Download "404 not found" image</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap this content in a <div class="container"> element.

And as far as I know, the download attribute on a link should contain no value or at least only the filename/exension, but not the hole path (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes).


<Canvas of={ErrorPageStories.Default} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Args, Meta, StoryObj } from '@storybook/web-components';
import { BADGE } from '../../../../.storybook/constants';
import { html } from 'lit';

const meta: Meta = {
id: 'a536a61d-cac2-4f39-adbf-092bdd445ce5',
title: 'Patterns/Error page',
parameters: {
badges: [BADGE.NEEDS_REVISION],
layout: 'fullscreen',
},
render,
decorators: [
story => html`
<swisspost-internet-header project="test"></swisspost-internet-header>
<div class="container my-4">
<swisspost-internet-breadcrumbs hide-buttons></swisspost-internet-breadcrumbs>
</div>
${story()}
<swisspost-internet-footer></swisspost-internet-footer>
`,
],
};

function render(args: Args) {
return html`
<div class="bg-light error-container">
<div class="container">
<div class="row">
<div class="col-rg-8 py-huge">
<h2>
This page could not be found.
<br />
<span class="fw-light">
Possible reasons for this could be a misspelled or old URL.
</span>
</h2>
<p class="fw-light mt-3">
We kindly ask you to review this once again. It is also possible that we have moved,
archived, or renamed the relevant page. Perhaps you can find the content you're
looking for on our homepage. Or use the search on our portal to locate the desired
page.
</p>
<div class="d-flex gap-3 mt-4">
<a class="btn btn-primary" href="/">Home page</a>
<a class="btn btn-secondary" href="https://www.post.ch/de/pages/suche#t=AllTab">
Search
</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some click event listeners (@click="${e => e.preventDefault()}") on both links, to prevent default behaviour in the example. Because at least the Home page button is misleading us to our storybook root url.

</div>
</div>
<div class="col-6 offset-3 offset-rg-0 col-rg-4 align-self-end">
<img class="error-container--image" src="/images/content/404.png" alt="" />
oliverschuerch marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
</div>
</div>
`;
}

export default meta;

type Story = StoryObj;

export const Default: Story = {};
1 change: 1 addition & 0 deletions packages/styles/src/components/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@use 'carousel';
@use 'close';
@use 'elevation';
@use 'error-container';
@use 'form-range';
@use 'form-select';
@use 'form-textarea';
Expand Down
9 changes: 9 additions & 0 deletions packages/styles/src/components/error-container.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.error-container {
overflow-x: hidden;
}

.error-container--image {
max-width: 150%;
margin: 10vw 0 0 3rem;
object-fit: contain;
}
Loading