diff --git a/.changeset/two-shrimps-argue.md b/.changeset/two-shrimps-argue.md
new file mode 100644
index 0000000000..46c20b0b0e
--- /dev/null
+++ b/.changeset/two-shrimps-argue.md
@@ -0,0 +1,6 @@
+---
+'@swisspost/design-system-documentation': minor
+'@swisspost/design-system-components': minor
+---
+
+Added the new default slot, to allow the integration of custom HTML in the card-control component.
diff --git a/packages/components/src/components/post-card-control/post-card-control.scss b/packages/components/src/components/post-card-control/post-card-control.scss
index e2ba443d2a..fdb0b368b1 100644
--- a/packages/components/src/components/post-card-control/post-card-control.scss
+++ b/packages/components/src/components/post-card-control/post-card-control.scss
@@ -22,7 +22,8 @@
--post-card-control-input-bg: #{post.$white};
flex-basis: 100%;
- display: flex;
+ display: grid;
+ grid-template: 'input label icon' 'input content icon' / min-content auto min-content;
gap: 0 post.$size-mini;
padding: post.$size-regular;
background-color: var(--post-card-control-bg);
@@ -34,7 +35,7 @@
transition: background-color 100ms linear, border-color 100ms linear;
.card-control--input {
- flex: 0 0 auto;
+ grid-area: input;
margin: post.$size-micro 0;
background-color: var(--post-card-control-input-bg);
border-color: var(--post-card-control-input-border-color) !important;
@@ -46,21 +47,28 @@
&:focus-visible {
box-shadow: none;
}
+ }
- ~ .card-control--label {
- flex-grow: 2;
- margin: post.$size-micro 0;
- color: inherit !important;
- pointer-events: none;
- }
+ .card-control--label {
+ grid-area: label;
+ margin: post.$size-micro 0;
+ padding: 0;
+ color: inherit !important;
+ pointer-events: none;
+ transition-duration: 100ms;
}
.card-control--description {
+ grid-area: label;
font-size: 0.75rem;
}
+ .card-control--content {
+ grid-area: content;
+ }
+
.card-control--icon {
- flex: 0 0 auto;
+ grid-area: icon;
width: post.$size-big;
height: post.$size-big;
pointer-events: none;
diff --git a/packages/components/src/components/post-card-control/post-card-control.tsx b/packages/components/src/components/post-card-control/post-card-control.tsx
index dffe7f05f0..024df1c94c 100644
--- a/packages/components/src/components/post-card-control/post-card-control.tsx
+++ b/packages/components/src/components/post-card-control/post-card-control.tsx
@@ -26,7 +26,8 @@ let cardControlIds = 0;
/**
* @class PostCardControl - representing a stencil component
*
- * @slot icon - Content to place in the named `icon` slot.
Markup accepted: inline content . It is only meant for img
or svg
elements and overrides the `icon` property.
+ * @slot default - Content to place into the `default` slot.Markup accepted: block content .
Even if it is generally possible, we do not recommend using interactive elements in this slot because the background of the card control is clickable. This can lead to confusion when the hit box of nested interactive controls is not clearly separated from the background, is invalid HTML and click events bubbling up to the card control will unexpectedly toggle it if they're not captured. More info: https://accessibilityinsights.io/info-examples/web/nested-interactive/
+ * @slot icon - To insert a custom icon into the named `icon` slot.Markup accepted: inline content .
It is only meant for img
or svg
elements and overrides the `icon` property.
*/
@Component({
tag: 'post-card-control',
@@ -367,6 +368,7 @@ export class PostCardControl {
name={this.name}
value={this.value}
checked={this.checked}
+ aria-describedby={`${this.controlId}_label ${this.controlId}_content`}
aria-disabled={this.disabled}
aria-invalid={this.validity === 'false'}
onClick={this.controlClickHandler}
@@ -377,7 +379,11 @@ export class PostCardControl {
onKeyDown={this.controlKeyDownHandler}
/>
-
+
{this.label}
{this.description ? (
{this.description}
@@ -387,6 +393,10 @@ export class PostCardControl {
+
+
+
+
);
diff --git a/packages/components/src/components/post-card-control/readme.md b/packages/components/src/components/post-card-control/readme.md
index cd78493c3f..ba8708d175 100644
--- a/packages/components/src/components/post-card-control/readme.md
+++ b/packages/components/src/components/post-card-control/readme.md
@@ -54,9 +54,10 @@ Type: `Promise`
## Slots
-| Slot | Description |
-| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `"icon"` | Content to place in the named `icon` slot.Markup accepted: inline content . It is only meant for img
or svg
elements and overrides the `icon` property.
|
+| Slot | Description |
+| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `"default"` | Content to place into the `default` slot.Markup accepted: block content .
Even if it is generally possible, we do not recommend using interactive elements in this slot because the background of the card control is clickable. This can lead to confusion when the hit box of nested interactive controls is not clearly separated from the background, is invalid HTML and click events bubbling up to the card control will unexpectedly toggle it if they're not captured. More info: https://accessibilityinsights.io/info-examples/web/nested-interactive/
|
+| `"icon"` | To insert a custom icon into the named `icon` slot.Markup accepted: inline content .
It is only meant for img
or svg
elements and overrides the `icon` property.
|
## Dependencies
diff --git a/packages/documentation/src/stories/components/card-control/card-control.docs.mdx b/packages/documentation/src/stories/components/card-control/card-control.docs.mdx
index 3e5470f7c3..f6b75fa922 100644
--- a/packages/documentation/src/stories/components/card-control/card-control.docs.mdx
+++ b/packages/documentation/src/stories/components/card-control/card-control.docs.mdx
@@ -18,7 +18,7 @@ The `` element is part of the `@swisspost/design-system-compo
## Examples
-### On dark background
+### Dark backgrounds
@@ -35,6 +35,17 @@ If this is not enough, you can also use the named `icon` slot and add your very
+### Custom content
+
+If you need to add other content to the component, you can use the default slot to do so.
+
+
+
Even if it is generally possible, we do not recommend using interactive elements in this slot because the background of the card control is clickable.
+
This can lead to confusion when the hit box of nested interactive controls is not clearly separated from the background, is invalid HTML and click events bubbling up to the card control will unexpectedly toggle it if they're not captured. More info: https://accessibilityinsights.io/info-examples/web/nested-interactive/
+
+
+
+
### Form Integration
You can use the component directly in your forms, the control value will be available in the `FormData` of the surrounding `