Skip to content

Commit

Permalink
Merge branch 'main' into 3438-component-check-list
Browse files Browse the repository at this point in the history
  • Loading branch information
gfellerph authored Sep 27, 2024
2 parents 8a73022 + d6033c5 commit ce49461
Show file tree
Hide file tree
Showing 98 changed files with 4,322 additions and 2,810 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-frogs-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-components': patch
---

Fixed a bug in nested accordions where closing a child item unintentionally closed all parent accordion elements.
5 changes: 5 additions & 0 deletions .changeset/cuddly-bears-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-styles': patch
---

Removed global styles
5 changes: 5 additions & 0 deletions .changeset/empty-islands-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-documentation': minor
---

Added a toolbar for switching the theme, channel, and mode of all stories.
5 changes: 5 additions & 0 deletions .changeset/lemon-clocks-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-documentation': minor
---

Added documentation outlining the mission statement of the Design System.
5 changes: 5 additions & 0 deletions .changeset/six-spiders-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-documentation': minor
---

Added documentation for design principles.
6 changes: 6 additions & 0 deletions .changeset/tame-terms-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@swisspost/design-system-documentation': major
'@swisspost/design-system-components': major
---

Made the heading-level property required for the accordion and removed it from the accordion-item docs.
5 changes: 5 additions & 0 deletions .changeset/yellow-yaks-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-documentation': patch
---

Fixed typos in the Sass and HTML href paths.
2 changes: 1 addition & 1 deletion .github/actions/setup-netlify-cli/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ runs:
steps:
- name: Install netlify-cli
shell: bash
run: pnpm i -g netlify-cli@17
run: pnpm i -g netlify-cli@17.36.1
5 changes: 2 additions & 3 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ jobs:
- name: Setup
uses: ./.github/actions/setup-pnpm

# Install packages changed since main, as well as their dependants and dependencies
- name: Install dependencies
run: pnpm --filter "...[origin/main]" install
- name: Install dependencies and build packages
run: pnpm bootstrap

- name: Run unit tests
run: pnpm --filter "...[origin/main]" unit
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
## Packages

| Name | Description | Version | Changelog URL |
| :------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------- |
| :------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |:------------------------------------------------------------------------------|
| [Styles](https://design-system.post.ch/?path=/docs/e53e2de8-0bbf-4f70-babc-074c5466f700--docs) | The styling package, including theming for [Bootstrap](https://getbootstrap.com/) and [ng-bootstrap](https://ng-bootstrap.github.io/#/home) components. | [![Styles pacakge version shield for npm](https://img.shields.io/npm/v/%40swisspost%2Fdesign-system-styles?style=flat-square&logo=npm&label=%20&color=%23fc0)](https://www.npmjs.com/package/@swisspost/design-system-styles) | [Styles changelog](/packages/styles/CHANGELOG.md) |
| [Components](https://design-system.post.ch/?path=/docs/edfb619b-fda1-4570-bf25-20830303d483--docs) | A set of standard web components for easy integration with every framework or no framework at all. | [![Components package version shield for npm](https://img.shields.io/npm/v/%40swisspost%2Fdesign-system-components?style=flat-square&logo=npm&label=%20&color=%23fc0)](https://www.npmjs.com/package/@swisspost/design-system-components) | [Components changelog](/packages/components/CHANGELOG.md) |
| [Internet Header](https://design-system.post.ch/?path=/docs/9b02bcb2-3b6a-4271-b550-675a62ff3890--docs) | The header for client facing applications. | [![Internet Header package version shield for npm](https://img.shields.io/npm/v/%40swisspost%2Finternet-header?style=flat-square&logo=npm&label=%20&color=%23fc0)](https://www.npmjs.com/package/@swisspost/internet-header) | [Interet Header changelog](/packages/internet-header/CHANGELOG.md) |
| [Internet Header](https://design-system.post.ch/?path=/docs/9b02bcb2-3b6a-4271-b550-675a62ff3890--docs) | The header for client facing applications. | [![Internet Header package version shield for npm](https://img.shields.io/npm/v/%40swisspost%2Finternet-header?style=flat-square&logo=npm&label=%20&color=%23fc0)](https://www.npmjs.com/package/@swisspost/internet-header) | [Internet Header changelog](/packages/internet-header/CHANGELOG.md) |
| [Intranet Header](https://design-system.post.ch/?path=/docs/d59a459b-6f14-47c6-9f98-a36a3f79a6e3--docs) | The Angular component for internal usage. | [![Intranet Header package version shield for npm](https://img.shields.io/npm/v/%40swisspost%2Fdesign-system-intranet-header?style=flat-square&logo=npm&label=%20&color=%23fc0)](https://www.npmjs.com/package/@swisspost/design-system-intranet-header) | [Intranet Header changelog](/packages/intranet-header-workspace/CHANGELOG.md) |
| [Icons](https://design-system.post.ch/?path=/docs/40ed323b-9c1a-42ab-91ed-15f97f214608--docs) | A collection of Post icons in svg format. | [![Icons package version shield for npm](https://img.shields.io/npm/v/%40swisspost%2Fdesign-system-icons?style=flat-square&logo=npm&label=%20&color=%23fc0)](https://www.npmjs.com/package/@swisspost/design-system-icons) | [Icons changelog](/packages/icons/CHANGELOG.md) |

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="my-4">
<h2>Post Accordion</h2>
<post-accordion>
<post-accordion [headingLevel]="3">
<post-accordion-item>
<span slot="header">Titulum 1</span>
<p>Contentus momentus vero siteos et accusam iretea et justo.</p>
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export namespace Components {
/**
* Defines the hierarchical level of the `post-accordion-item` headers within the headings structure.
*/
"headingLevel"?: HeadingLevel;
"headingLevel": HeadingLevel;
/**
* If `true`, multiple `post-accordion-item` can be open at the same time.
*/
Expand Down Expand Up @@ -540,7 +540,7 @@ declare namespace LocalJSX {
/**
* Defines the hierarchical level of the `post-accordion-item` headers within the headings structure.
*/
"headingLevel"?: HeadingLevel;
"headingLevel": HeadingLevel;
/**
* If `true`, multiple `post-accordion-item` can be open at the same time.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class PostAccordionItem {
* Defines the hierarchical level of the accordion item header within the headings structure.
* @deprecated set the `heading-level` property on the parent `post-accordion` instead.
*/
@Prop() readonly headingLevel?: HeadingLevel = 2;
@Prop() readonly headingLevel?: HeadingLevel;

@Watch('headingLevel')
validateHeadingLevel(newValue = this.headingLevel) {
Expand All @@ -51,7 +51,7 @@ export class PostAccordionItem {
// capture to make sure the "collapsed" property is updated before the event is consumed
@Listen('postToggle', { capture: true })
onCollapseToggle(event: CustomEvent<boolean>): void {
if ((event.target as HTMLElement).localName === 'post-accordion-item') {
if (event.target === this.host && (event.target as HTMLElement).localName === 'post-accordion-item') {
this.collapsed = !event.detail;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

## Properties

| Property | Attribute | Description | Type | Default |
| -------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ------- |
| `collapsed` | `collapsed` | If `true`, the element is collapsed otherwise it is displayed. | `boolean` | `false` |
| `headingLevel` | `heading-level` | <span style="color:red">**[DEPRECATED]**</span> set the `heading-level` property on the parent `post-accordion` instead.<br/><br/>Defines the hierarchical level of the accordion item header within the headings structure. | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | `2` |
| Property | Attribute | Description | Type | Default |
| -------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ----------- |
| `collapsed` | `collapsed` | If `true`, the element is collapsed otherwise it is displayed. | `boolean` | `false` |
| `headingLevel` | `heading-level` | <span style="color:red">**[DEPRECATED]**</span> set the `heading-level` property on the parent `post-accordion` instead.<br/><br/>Defines the hierarchical level of the accordion item header within the headings structure. | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | `undefined` |


## Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class PostAccordion {
/**
* Defines the hierarchical level of the `post-accordion-item` headers within the headings structure.
*/
@Prop() readonly headingLevel?: HeadingLevel;
@Prop() readonly headingLevel!: HeadingLevel;

@Watch('headingLevel')
validateHeadingLevel(newValue = this.headingLevel) {
Expand Down Expand Up @@ -50,23 +50,26 @@ export class PostAccordion {

@Listen('postToggle')
collapseToggleHandler(event: CustomEvent<boolean>) {
if ((event.target as HTMLElement).localName === 'post-accordion-item') {
event.stopPropagation();
event.stopPropagation();

const toggledItem = event.target as HTMLPostAccordionItemElement;
const isClosing = this.expandedItems.has(toggledItem);
const toggledItem = event.target as HTMLElement;
const closestParentAccordion = toggledItem.closest('post-accordion');

if (closestParentAccordion === this.host && toggledItem.localName === 'post-accordion-item') {
const toggledAccordionItem = event.target as HTMLPostAccordionItemElement;
const isClosing = this.expandedItems.has(toggledAccordionItem);

if (isClosing) {
this.expandedItems.delete(toggledItem);
this.expandedItems.delete(toggledAccordionItem);
} else {
this.expandedItems.add(toggledItem);
this.expandedItems.add(toggledAccordionItem);
}

if (this.multiple || isClosing) return;

// close other open accordion items to have only one opened at a time
Array.from(this.expandedItems.values())
.filter(item => item !== toggledItem)
.filter(item => item !== toggledAccordionItem)
.forEach(item => {
item.toggle(false);
});
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/components/post-accordion/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

## Properties

| Property | Attribute | Description | Type | Default |
| -------------- | --------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | ----------- |
| `headingLevel` | `heading-level` | Defines the hierarchical level of the `post-accordion-item` headers within the headings structure. | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | `undefined` |
| `multiple` | `multiple` | If `true`, multiple `post-accordion-item` can be open at the same time. | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| --------------------------- | --------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | ----------- |
| `headingLevel` _(required)_ | `heading-level` | Defines the hierarchical level of the `post-accordion-item` headers within the headings structure. | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | `undefined` |
| `multiple` | `multiple` | If `true`, multiple `post-accordion-item` can be open at the same time. | `boolean` | `false` |


## Methods
Expand Down
39 changes: 39 additions & 0 deletions packages/documentation/.storybook/addons/addons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@use '@swisspost/design-system-styles/core' as post;

.addon-dropdown {
min-width: 12rem;
display: flex;
flex-flow: column nowrap;
gap: post.$size-line;
position: absolute;
top: -5px;
right: 0;
padding: post.$size-mini;
background-color: post.$white;
border: post.$border-width solid post.$border-color;
border-radius: post.$border-radius;
font-size: post.$font-size-sm;

.addon-dropdown__item {
display: block;
padding: post.$size-mini post.$size-small-regular;
border-radius: post.$border-radius-sm;
text-decoration: none;
color: post.$body-color !important;

&:hover {
background-color: post.$gray-10;
}

&.active {
background-color: post.$yellow;
}
}
}

.addon-button {
post-icon {
font-size: post.$font-size-20;
margin-inline-end: post.$size-line;
}
}
Loading

0 comments on commit ce49461

Please sign in to comment.