Skip to content

Commit

Permalink
chore(documentation): Rework getting started section and add Angular …
Browse files Browse the repository at this point in the history
…CUSTOM_ELEMENTS_SCHEMA info (#2722)

* Add a getting started page in the getting started section with a table
to better understand the different packages
* Move docs page about packages into a packages folder. This include the
page that you can find in specific components like `icon`,
`internet-header`, `intranet-header`
* Remove list of components inside `preview.ts` as with the previous
changes folders are not required, and we can let (for the moment at
least) Storybook manage order
* Move list of icons into foundations
* Add new page about Angular
* Add `Components-Angular` into compatibility page
* Move migration-guide for the internet-header package into the package
page.
* Fixes
  * Change some typos like "swiss" to "Swiss"
* Fixes some links that were not using the right prefix "href="?path" to
"href="/?path"
  * Fix "Notification overlay" story which is missing an id


### Todo/discuss
* We should perhaps merge the stories of the internet-header to match
other components structure.

---------

Co-authored-by: Alizé Debray <[email protected]>
Co-authored-by: Oliver Schürch <[email protected]>
  • Loading branch information
3 people authored Mar 11, 2024
1 parent ce45ec0 commit 238597b
Show file tree
Hide file tree
Showing 163 changed files with 1,368 additions and 696 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-pumas-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-documentation': patch
---

Reworked the getting-started section to better understand the different packages and add more info about Angular.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h5 class="card-title">Card title</h5>
</div>

<h3>Card columns</h3>
<p>Card columns can be checked out in the swiss post example below.</p>
<p>Card columns can be checked out in the Swiss Post example below.</p>

<p>
Default
Expand Down
39 changes: 2 additions & 37 deletions packages/documentation/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ const preview: Preview = {

// Category - Getting Started
'Getting Started',
['Styles', 'Components', 'Components-Angular', 'Compatibility'],
['Introduction', 'Angular', 'Compatibility', 'Packages'],

// Category - Foundations
'Foundations',
[
'Typography',
'Color',
'Search for Icons',
'Layout',
['Breakpoints', 'Containers', 'Grid', 'Columns', 'TODOS'],
'Elevation',
Expand All @@ -40,42 +41,6 @@ const preview: Preview = {

// Category - Components
'Components',
[
'Accordion',
'Alert',
'Badge',
'Blockquote',
'Button',
'Button Group',
'Cards',
'Carousel',
'Collapsible',
'Datepicker',
'Dropdown',
'Forms',
'Heading',
'Icons',
['Getting Started'],
'Internet Header',
['Getting Started', 'Header'],
'Intranet Header',
'Modal',
'Notification overlay',
'Pagination',
'Popover',
'Progressbar',
'Rating',
'Spinner',
'Stepper',
'Subnavigation',
'Table',
'Tabs',
'Timepicker',
'Toast',
'Tooltip',
'Topic Teaser',
'Typeahead',
],

// Category - Patterns
'Patterns',
Expand Down
6 changes: 4 additions & 2 deletions packages/documentation/.storybook/styles/preview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#storybook-root,
#storybook-docs {
overflow: hidden;

.sbdocs-content .container >,
.sbdocs-content .container > post-tabs > post-tab-panel >,
.sbdocs-content .container > migration-global-state {
Expand Down Expand Up @@ -38,6 +36,10 @@
h6 {
margin-block: 1rem;
}
.table,
.table-responsive {
margin-block: 1.5rem 1rem;
}
}

.sbdocs-content .container {
Expand Down
1 change: 1 addition & 0 deletions packages/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"devDependencies": {
"@geometricpanda/storybook-addon-badges": "2.0.1",
"@lit/task": "1.0.0",
"@open-wc/lit-helpers": "0.6.0",
"@percy/cli": "1.27.7",
"@percy/cypress": "3.1.2",
Expand Down
1 change: 0 additions & 1 deletion packages/documentation/src/noop.txt

This file was deleted.

152 changes: 152 additions & 0 deletions packages/documentation/src/shared/packages.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import { DEPENDENCIES, getVersion } from '../utils/version';
import metaStyles from '../stories/getting-started/packages/styles/styles.stories';
import metaComponents from '../stories/getting-started/packages/components/components.stories';
import metaComponentsAngular from '../stories/getting-started/packages/components-angular/components-angular.stories';
import metaInternetHeader from '../stories/getting-started/packages/internet-header/internet-header.stories';
import metaIntranetHeader from '../stories/getting-started/packages/intranet-header/intranet-header.stories';
import metaIcons from '../stories/getting-started/packages/icons/package-icons.stories';
import { PackageType } from '../../types';

interface IPackage {
name: string;
docsStoryId: string;
type: PackageType;
link: {
[key: string]: {
href: string;
ariaLabel: string;
};
};
img: {
src: string;
alt: string;
};
version: string;
}

export const packages: IPackage[] = [
{
name: 'Styles',
docsStoryId: metaStyles.id,
type: PackageType.Html,
link: {
github: {
href: 'https://github.com/swisspost/design-system/tree/main/packages/styles',
ariaLabel: 'Source of Styles package',
},
docs: {
href: generateDocsRelativeLink(metaStyles.id),
ariaLabel: 'Getting started with Styles package',
},
},
img: {
src: '/assets/images/packages/styles.svg',
alt: '',
},
version: `v${getVersion(DEPENDENCIES['@swisspost/design-system-styles'])}`,
},
{
name: 'Components',
docsStoryId: metaComponents.id,
type: PackageType.Wc,
link: {
github: {
href: 'https://github.com/swisspost/design-system/tree/main/packages/components',
ariaLabel: 'Source of Components package',
},
docs: {
href: generateDocsRelativeLink(metaComponents.id),
ariaLabel: 'Getting started with Components package',
},
},
img: {
src: '/assets/images/packages/components.svg',
alt: '',
},
version: `v${getVersion(DEPENDENCIES['@swisspost/design-system-components'])}`,
},
{
name: 'Components for Angular',
docsStoryId: metaComponentsAngular.id,
type: PackageType.Angular,
link: {
github: {
href: 'https://github.com/swisspost/design-system/tree/main/packages/components-angular',
ariaLabel: 'Source of Components for Angular package',
},
docs: {
href: generateDocsRelativeLink(metaComponentsAngular.id),
ariaLabel: 'Getting started with Components for Angular package',
},
},
img: {
src: '/assets/images/packages/components-angular.svg',
alt: '',
},
version: `v${getVersion(DEPENDENCIES['@swisspost/design-system-components-angular'])}`,
},
{
name: 'Internet-Header',
docsStoryId: metaInternetHeader.id,
type: PackageType.Wc,
link: {
github: {
href: 'https://github.com/swisspost/design-system/tree/main/packages/internet-header',
ariaLabel: 'Source of Internet-Header package',
},
docs: {
href: generateDocsRelativeLink(metaInternetHeader.id),
ariaLabel: 'Getting started with Internet-Header package',
},
},
img: {
src: '/assets/images/packages/internet-header.svg',
alt: '',
},
version: `v${getVersion(DEPENDENCIES['@swisspost/internet-header'])}`,
},
{
name: 'Intranet-Header',
docsStoryId: metaIntranetHeader.id,
type: PackageType.Angular,
link: {
github: {
href: 'https://github.com/swisspost/design-system/tree/main/packages/intranet-header-workspace/projects/intranet-header',
ariaLabel: 'Source of Intranet-Header package',
},
docs: {
href: generateDocsRelativeLink(metaIntranetHeader.id),
ariaLabel: 'Getting started with Intranet-Header package',
},
},
img: {
src: '/assets/images/packages/intranet-header.svg',
alt: '',
},
version: `v${getVersion(DEPENDENCIES['@swisspost/design-system-intranet-header'])}`,
},
{
name: 'Icons',
docsStoryId: metaIcons.id,
type: PackageType.Assets,
link: {
github: {
href: 'https://github.com/swisspost/design-system/tree/main/packages/icons',
ariaLabel: 'Source of Icons package',
},
docs: {
href: generateDocsRelativeLink(metaIcons.id),
ariaLabel: 'Getting started with Icons package',
},
},
img: {
src: '/assets/images/packages/icons.svg',
alt: '',
},
version: `v${getVersion(DEPENDENCIES['@swisspost/design-system-icons'])}`,
},
];

function generateDocsRelativeLink(storyId: string) {
return `/?path=/docs/${storyId}--docs`;
}
100 changes: 100 additions & 0 deletions packages/documentation/src/shared/tile/tile.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
@use 'sass:map';
@use '@swisspost/design-system-styles/core.scss' as post;
@use '@swisspost/design-system-styles/mixins/utilities';

$tile-size: var(--post-docs-tile-size, 120px);
$tile-rg-size: var(--post-docs-tile-rg-size, calc($tile-size / 1.2));

:host{
.tile {
display: flex;
flex-direction: column;
width: $tile-size;
height: $tile-size;
background-color: post.$white;
border-radius: post.$size-regular;
box-shadow: 0 2px 5px 0 rgba(post.$aubergine-dark, 0.3);
text-decoration: none;
text-align: center;

@include utilities.high-contrast-mode() {
border: 2px solid transparent;
}

.tile--title {
display: flex;
justify-content: center;
align-items: center;
flex: 0 0 auto;
padding: 0 post.$size-micro;
height: calc(#{post.$size-mini * 2} + 2.2em);
background-color: post.$yellow;
border-top-left-radius: inherit;
border-top-right-radius: inherit;
font-size: max(12px, calc($tile-size * 0.1));
font-weight: post.$font-weight-bold;
color: post.$black;
z-index: 1;
line-height: 1.1;
box-shadow: 0 2px 0 1px rgba(post.$yellow, 0.5);

~ .tile--icon {
img {
max-height: 50px;
}
}
}

.tile--icon {
flex: 0 1 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: post.$size-micro;
border-bottom-left-radius: inherit;
border-bottom-right-radius: inherit;

::slotted(img) {
height: 0;
min-height: min(100%, calc($tile-size * 0.4));
}

::slotted(span) {
font-size: 0.6875em;
color: post.$gray-600;
}
}

&[href] {
transition: transform 150ms ease-out;

&:hover {
transform: scale(1.1);
}
}

@include post.media-breakpoint-down(rg) {
width: $tile-rg-size;
height: $tile-rg-size;

.tile--title {
height: calc(#{post.$size-mini * 1.5} + 2.2em);

~ .tile--icon {
::slotted(img) {
min-height: calc($tile-size * 0.3);
}
}
}

.tile--icon {
::slotted(img) {
min-height: calc($tile-size * 0.4);
}
}
}
}
}


31 changes: 31 additions & 0 deletions packages/documentation/src/shared/tile/tile.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { css, LitElement, nothing, unsafeCSS } from 'lit';
import { html, unsafeStatic } from 'lit/static-html.js';
import { customElement, property } from 'lit/decorators.js';
import { spread } from '@open-wc/lit-helpers';
import Styles from './tile.component.scss?inline';

@customElement('ti-le')
export class TileComponent extends LitElement {
@property({ type: String }) title: string = '';
@property({ type: String }) ariaLabel: string | null = null;
@property({ type: String }) href: string | null = null;

static get styles() {
return css`
${unsafeCSS(Styles)}
`;
}

render() {
const isLink = this.href !== null;
const tag = isLink ? 'a' : 'div';
const attributes = isLink ? { href: this.href, target: '_blank' } : {};

return html` <${unsafeStatic(tag)} class="tile" ${spread(attributes)} aria-label="${
this.ariaLabel ?? nothing
}">
${this.title ? html`<span class="tile--title">${this.title}</span>` : nothing}
<span class="tile--icon"><slot></slot></span>
</${unsafeStatic(tag)}>`;
}
}
Loading

0 comments on commit 238597b

Please sign in to comment.