Compare commits

...

2 Commits

Author SHA1 Message Date
Lea Verou
024dc6a0b4 --wa-card-* CSS properties PoC 2025-01-15 15:01:48 -05:00
Lea Verou
561e0c9553 Reintroduce --border-width and --border-radius, fixes #531 2025-01-15 14:59:07 -05:00
2 changed files with 32 additions and 18 deletions

View File

@@ -1,29 +1,36 @@
:host {
--spacing: var(--wa-space-xl);
--border-width: var(--wa-card-border-width, var(--wa-panel-border-width));
--border-radius: var(--wa-card-border-radius, var(--wa-panel-border-radius));
--inner-border-radius: calc(var(--border-radius) - var(--border-width));
display: flex;
flex-direction: column;
background-color: var(--wa-color-surface-default);
border-color: var(--wa-color-surface-border);
border-radius: var(--wa-panel-border-radius);
background-color: var(--wa-card-background-color, var(--wa-color-surface-default));
border-color: var(--wa-card-border-color, var(--wa-color-surface-border));
border-radius: var(--border-radius);
border-style: var(--wa-panel-border-style);
border-width: var(--wa-panel-border-width);
box-shadow: var(--wa-shadow-s);
border-width: var(--border-width);
box-shadow: var(--wa-card-shadow, var(--wa-shadow-s));
color: var(--wa-color-text-normal);
}
.image,
:host(:not([with-image])) .header {
border-start-start-radius: var(--inner-border-radius);
border-start-end-radius: var(--inner-border-radius);
}
.image {
display: flex;
border-top-left-radius: inherit;
border-top-right-radius: inherit;
margin: calc(-1 * var(--border-width));
overflow: hidden;
background-color: var(--wa-card-image-background-color, transparent);
&::slotted(img) {
display: block;
width: 100%;
border-bottom-left-radius: 0 !important;
border-bottom-right-radius: 0 !important;
border-start-start-radius: inherit !important;
border-start-end-radius: inherit !important;
}
}
@@ -31,11 +38,7 @@
display: block;
border-bottom: inherit;
padding: calc(var(--spacing) / 2) var(--spacing);
}
:host(:not([with-image])) .header {
border-top-left-radius: inherit;
border-top-right-radius: inherit;
background-color: var(--wa-card-header-background-color, transparent);
}
.body {
@@ -46,9 +49,10 @@
.footer {
display: block;
border-top: inherit;
border-bottom-left-radius: inherit;
border-bottom-right-radius: inherit;
border-end-start-radius: var(--inner-border-radius);
border-end-end-radius: var(--inner-border-radius);
padding: var(--spacing);
background-color: var(--wa-card-footer-background-color, transparent);
}
:host(:not([with-header])) .header,

View File

@@ -19,7 +19,17 @@ import styles from './card.css';
* @csspart body - The container that wraps the card's main content.
* @csspart footer - The container that wraps the card's footer.
*
* @cssproperty --border-radius - The radius for the card's corners. Expects a single value. Defaults to `var(--wa-panel-border-radius)`.
* @cssproperty --border-width - The width of the card's borders. Expects a single value. Defaults to `var(--wa-panel-border-width)`.
* @cssproperty --spacing - The amount of space around and between sections of the card. Expects a single value.
* @cssproperty --wa-card-border-radius - The default radius for all cards, typically set on an ancestor element (e.g. by a theme). Expects a single value.
* @cssproperty --wa-card-border-color - The default border color for all cards, typically set on an ancestor element (e.g. by a theme). Expects a single color.
* @cssproperty --wa-card-border-width - The default border width for all cards, typically set on an ancestor element (e.g. by a theme). Expects a single value.
* @cssproperty --wa-card-background-color - The default background color for all cards, typically set on an ancestor element (e.g. by a theme).
* @cssproperty --wa-card-shadow - The default shadow for all cards, typically set on an ancestor element (e.g. by a theme).
* @cssproperty --wa-card-header-background-color - The default background color for card headers, typically set on an ancestor element (e.g. by a theme).
* @cssproperty --wa-card-footer-background-color - The default background color for card footers, typically set on an ancestor element (e.g. by a theme).
* @cssproperty --wa-card-image-background-color - The default background color for card images, typically set on an ancestor element (e.g. by a theme).
*/
@customElement('wa-card')
export default class WaCard extends WebAwesomeElement {