Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(card): extract meta from header #1288

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions __snapshots__/Card.md
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@
</div>
<div class="vwc-card-content">
<slot name="content">
<header class="no-content vwc-card-header">
<div class="vwc-card-header-content">
<div class="vwc-card-wrapper">
<header class="no-content vwc-card-header">
<slot name="graphic">
</slot>
<div>
@@ -22,10 +22,10 @@
<div class="vwc-card-subtitle">
</div>
</div>
</div>
</header>
<slot name="meta">
</slot>
</header>
</div>
<div class="vwc-card-text">
</div>
</slot>
20 changes: 11 additions & 9 deletions components/card/src/vwc-card.scss
Original file line number Diff line number Diff line change
@@ -21,19 +21,20 @@
padding: 1.5rem;
}

&-header {
&-wrapper {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 0.5rem;

width: 100%;
column-gap: 0.5rem;
:host([text]) & {
margin-bottom: 12px;
}
}

&-content {
display: inline-flex;
}
&-header {
display: inline-flex;
align-items: flex-start;
justify-content: space-between;
column-gap: 0.5rem;
}

&-title,
@@ -80,7 +81,7 @@
.icon {
flex-shrink: 0;
align-self: baseline;
margin: 4px 10px 0 0;
margin: 4px 2px 0 0;
}

.icon {
@@ -93,6 +94,7 @@
align-self: flex-start;
margin-block-start: -0.5rem;
margin-inline-end: -0.5rem;
margin-inline-start: auto;
}

.no-content {
20 changes: 10 additions & 10 deletions components/card/src/vwc-card.ts
Original file line number Diff line number Diff line change
@@ -90,7 +90,10 @@ export class VWCCard extends LitElement {
</div>
<div class="vwc-card-content">
<slot name="content">
${this.renderHeader()}
<div class="vwc-card-wrapper">
${this.renderHeader()}
<slot name="meta"></slot>
</div>
<div class="vwc-card-text">
${this.text ? this.text : nothing}
</div>
@@ -108,16 +111,13 @@ export class VWCCard extends LitElement {
private renderHeader() {
return html`
<header class="vwc-card-header ${this.headerClass}">
<div class="vwc-card-header-content">
<slot name="graphic" @slotchange="${this.graphicSlotChanged}">
${this.icon ? this.renderIcon() : ''}
</slot>
<div>
<div class="vwc-card-title">${this.heading}</div>
<div class="vwc-card-subtitle">${this.subtitle}</div>
</div>
<slot name="graphic" @slotchange="${this.graphicSlotChanged}">
${this.icon ? this.renderIcon() : ''}
</slot>
<div>
<div class="vwc-card-title">${this.heading}</div>
<div class="vwc-card-subtitle">${this.subtitle}</div>
</div>
<slot name="meta"></slot>
</header>`;
}

Binary file modified ui-tests/snapshots/vwc-card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ui-tests/tests/vwc-card/index.js
Original file line number Diff line number Diff line change
@@ -100,6 +100,10 @@ export async function createElementVariations(wrapper) {
<vwc-card elevation="24">
<div slot="content">I'm the card content that overrides the content from attributes. I have no text styles or any styles for that matter :) You can do whatever you want here</div>
</vwc-card>
<vwc-card label="card with meta-no header" text="I'm a Supporting text, cant be line trimmed. Lorem ipsum dolor sit amet, consectet adipiscing elit">
<vwc-icon-button-toggle onicon="bookmark-full" officon="bookmark" connotation="cta" slot="meta"></vwc-icon-button-toggle>
</vwc-card>
`;
wrapper.appendChild(elementWrapper);
}