Skip to content

Commit

Permalink
fix(core/card-list): adapt title margin to figma (#1492)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Leroux <[email protected]>
  • Loading branch information
matthiashader and danielleroux authored Oct 22, 2024
1 parent eb97f91 commit 20553f5
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-meals-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siemens/ix': patch
---

fix(core/card-list): adapt title margin to figma
6 changes: 3 additions & 3 deletions packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@
"type": "string"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand Down Expand Up @@ -1970,7 +1970,7 @@
"name": "showAllCount",
"type": "number",
"complexType": {
"original": "number | undefined",
"original": "number",
"resolved": "number",
"references": {}
},
Expand All @@ -1984,7 +1984,7 @@
"type": "number"
}
],
"optional": false,
"optional": true,
"required": false
},
{
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export namespace Components {
/**
* Name the card list
*/
"label": string;
"label"?: string;
/**
* List style
*/
Expand All @@ -354,7 +354,7 @@ export namespace Components {
/**
* Overwrite the default show all count.
*/
"showAllCount": number | undefined;
"showAllCount"?: number;
/**
* Suppress the overflow handling of child elements
*/
Expand Down Expand Up @@ -4435,7 +4435,7 @@ declare namespace LocalJSX {
/**
* Overwrite the default show all count.
*/
"showAllCount"?: number | undefined;
"showAllCount"?: number;
/**
* Suppress the overflow handling of child elements
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/card-list/card-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $CardList__Title__Height: 1.5rem;
height: $CardList__Title__Height;
align-items: center;
width: 100%;
margin-bottom: 0.5rem;
margin-bottom: 1rem;

&__Label {
overflow: hidden;
Expand Down
27 changes: 15 additions & 12 deletions packages/core/src/components/card-list/card-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import {
import { createMutationObserver } from '../utils/mutation-observer';

function CardListTitle(props: {
label: string;
label?: string;
isCollapsed: boolean;
onClick: (e: MouseEvent) => void;
onShowAllClick: (e: MouseEvent) => void;
showAllLabel: string;
showAllCounter: number;
hideShowAll: boolean;
}) {
if (props.label === '') {
if (!props.label) {
return null;
}

Expand Down Expand Up @@ -67,7 +67,7 @@ export class CardList {
/**
* Name the card list
*/
@Prop() label: string;
@Prop() label?: string;

/**
* Collapse the list
Expand All @@ -89,7 +89,7 @@ export class CardList {
/**
* Overwrite the default show all count.
* */
@Prop() showAllCount: number | undefined;
@Prop() showAllCount?: number;

/**
* Suppress the overflow handling of child elements
Expand All @@ -116,31 +116,31 @@ export class CardList {
/**
* Fire event when the collapse state is changed by the user
*/
@Event() collapseChanged: EventEmitter<boolean>;
@Event() collapseChanged!: EventEmitter<boolean>;

/**
* Fire event when the collapse state is changed by the user
*/
@Event() showAllClick: EventEmitter<{
@Event() showAllClick!: EventEmitter<{
nativeEvent: MouseEvent;
}>;

/**
* Fire event when the show more card is clicked.
*/
@Event() showMoreCardClick: EventEmitter<{
@Event() showMoreCardClick!: EventEmitter<{
nativeEvent: MouseEvent;
}>;

@Element() hostElement: HTMLIxCardListElement;
@Element() hostElement!: HTMLIxCardListElement;

@State() private hasOverflowingElements = false;
@State() private numberOfOverflowingElements = 0;
@State() private numberOfAllChildElements = 0;
@State() private leftScrollDistance = 0;
@State() private rightScrollDistance = 0;

private observer: MutationObserver;
private observer?: MutationObserver;

private onCardListVisibilityToggle() {
this.collapse = !this.collapse;
Expand All @@ -154,7 +154,7 @@ export class CardList {
}

private getListChildren() {
const slot = this.hostElement.shadowRoot.querySelector(
const slot = this.hostElement.shadowRoot!.querySelector(
'.CardList__Content > slot'
) as HTMLSlotElement;
return slot.assignedElements({ flatten: true });
Expand Down Expand Up @@ -185,7 +185,7 @@ export class CardList {
});

this.observer.observe(
this.hostElement.shadowRoot.querySelector('.CardList__Content'),
this.hostElement.shadowRoot!.querySelector('.CardList__Content')!,
{
childList: true,
subtree: true,
Expand All @@ -207,7 +207,7 @@ export class CardList {
}

private get listElement() {
return this.hostElement.shadowRoot.querySelector('.CardList__Content');
return this.hostElement.shadowRoot!.querySelector('.CardList__Content');
}

private onCardListScroll() {
Expand Down Expand Up @@ -260,6 +260,9 @@ export class CardList {

@Listen('resize', { target: 'window' })
private detectOverflow() {
if (!this.listElement) {
return;
}
const { clientWidth, scrollWidth, scrollLeft } = this.listElement;

this.leftScrollDistance = scrollLeft;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 20553f5

Please sign in to comment.