Skip to content

Commit

Permalink
Improve spacing when the card has an icon with no image.
Browse files Browse the repository at this point in the history
  • Loading branch information
marvel-uiuc committed Sep 12, 2024
1 parent 2900656 commit c4194a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/ilw-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Card extends LitElement {
align: {},
aspectRatio: {},
_hasGraphic: { state: true, type: Boolean },
_iconOnly: { state: true, type: Boolean },
};
}

Expand All @@ -26,6 +27,7 @@ class Card extends LitElement {
this.aspectRatio = "";
this.clickable = false;
this._hasGraphic = false;
this._iconOnly = false;

this._click = (ev) => {
/**
Expand Down Expand Up @@ -54,6 +56,7 @@ class Card extends LitElement {
}
const icons = this.shadowRoot.querySelector("slot[name=icon]");
if (icons.assignedElements().length > 0) {
this._iconOnly = true;
this._hasGraphic = true;
return;
}
Expand All @@ -66,6 +69,7 @@ class Card extends LitElement {
// Only add the force-ratio class if we are in fact forcing an aspect ratio
"force-ratio": !!this.aspectRatio,
graphic: this._hasGraphic,
"icon-only": this._iconOnly
};
const styles = {
"--ilw-card--aspect-ratio": this.aspectRatio
Expand Down
6 changes: 5 additions & 1 deletion src/ilw-card.styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ article {

.card-icon {
position: absolute;
top: var(--ilw-card--content-padding-top);
top: 0;
left: 0;
right: 0;
bottom: 0;
Expand Down Expand Up @@ -300,6 +300,10 @@ article {
flex: 1;
}

.icon-only .card-content {
padding-top: 0;
}

.card-footer {
padding: 0 var(--ilw-card--content-padding-right) var(--ilw-card--content-padding-bottom) var(--ilw-card--content-padding-left);
}

0 comments on commit c4194a8

Please sign in to comment.