Skip to content

Commit

Permalink
fix(components): update post-list component (#4137)
Browse files Browse the repository at this point in the history
- Reflected the `horizontal` property on the host to allow updating the
orientation with `document.querySelector('post-list).horizontal = true;`
- Reduced the selectors specificity to allow flexible styling
- Gave a default value to all CSS custom properties
  • Loading branch information
alizedebray authored Dec 10, 2024
1 parent 82de514 commit 041d6fe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-cheetahs-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-components': patch
---

Fixed an issue with the post-list component where the `horizontal` property could not be set programmatically. Also, reduced the specificity of the component's styles to make customization easier.
16 changes: 8 additions & 8 deletions packages/components/src/components/post-list/post-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

post-list {
display: flex;
gap: var(--post-list-title-gap);
flex-direction: column;
align-items: flex-start;
gap: var(--post-list-title-gap, 0);

& > div[role='list'] {
flex-direction: column;
> [role='list'] {
display: flex;
gap: var(--post-list-item-gap);
flex-direction: column;
gap: var(--post-list-item-gap, 0);
}

&[horizontal]:not([horizontal='false']) {
&:where([horizontal]:not([horizontal='false'])) {
flex-direction: row;
align-items: baseline;
& > div[role='list'] {
align-items: center;

> [role='list'] {
flex-direction: row;
align-items: center;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/components/post-list/post-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export class PostList {
/**
* The list can become horizontal by setting `horizontal="true"` or just `horizontal`
*/
@Prop() readonly horizontal: boolean = false;
@Prop({ reflect: true }) readonly horizontal: boolean = false;

private titleEl: HTMLElement;

componentWillLoad() {
/**
* Get the id set on the host element or use a random id by default
*/
this.titleId = `list-${crypto.randomUUID()}`;
this.titleId = `title-${this.host.id || crypto.randomUUID()}`;
}

componentDidLoad() {
Expand Down

0 comments on commit 041d6fe

Please sign in to comment.