added actions slot to horizontal card

This commit is contained in:
Kelsey Jackson
2025-08-29 13:14:29 -05:00
parent fde32d57c6
commit e7199c5fab
3 changed files with 44 additions and 8 deletions

View File

@@ -158,15 +158,28 @@ Use the `appearance` attribute to change the card's visual appearance.
### Orientation
Set the `orientation` attribute to `horizontal` to create a card with a horizontal, side-by-side layout. Make sure to set a width or maximum width for the media slot. Horizontal cards do not currently contain the header and footer slots.
```html {.example}
<div class="wa-grid">
<wa-card orientation="horizontal">
<wa-card orientation="horizontal" class="horizontal-card">
<img
slot="media"
src="https://images.unsplash.com/photo-1559209172-0ff8f6d49ff7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80"
alt="A kitten sits patiently between a terracotta pot and decorative grasses."
/>
Outlined (default)
This is a kitten, but not just any kitten. This kitten likes walking along pallets.
<wa-button slot="actions" variant="neutral" appearance="plain"
><wa-icon name="ellipsis" label="actions"></wa-icon
></wa-button>
</wa-card>
</div>
<style>
.horizontal-card {
img[slot='media'] {
max-width: 300px;
}
}
</style>
```

View File

@@ -42,11 +42,6 @@
border-color: transparent;
}
/* Orientation Styles */
:host([orientation='horizontal']) {
display: flex;
}
/* Take care of top and bottom radii */
.media,
:host(:not([with-media])) .header,
@@ -107,3 +102,26 @@
:host(:not([with-media])) .media {
display: none;
}
/* Orientation Styles */
:host([orientation='horizontal']) {
flex-direction: row;
.media {
border-start-start-radius: var(--inner-border-radius);
border-end-start-radius: var(--inner-border-radius);
border-start-end-radius: 0;
}
}
:host([orientation='horizontal']) ::slotted(*) {
display: block;
height: 100%;
margin: 0 !important;
object-fit: cover !important;
}
:host([orientation='horizontal']) ::slotted([slot='actions']) {
display: flex;
align-items: center;
padding: var(--spacing);
}

View File

@@ -15,6 +15,7 @@ import styles from './card.css';
* @slot header - An optional header for the card.
* @slot footer - An optional footer for the card.
* @slot media - An optional media section to render at the start of the card.
* @slot actions - An optional actions section to render at the end for the horizontal card.
*
* @csspart media - The container that wraps the card's media.
* @csspart header - The container that wraps the card's header.
@@ -55,7 +56,11 @@ export default class WaCard extends WebAwesomeElement {
render() {
if (this.orientation === 'horizontal') {
return html`<slot name="media" part="media" class="media"></slot><slot part="body" class="body"></slot>`;
return html`
<slot name="media" part="media" class="media"></slot>
<slot part="body" class="body"></slot>
<slot name="actions" part="actions" class="actions"></slot>
`;
}
return html`
<slot name="media" part="media" class="media"></slot>