Skip to content

Commit 7e23cf7

Browse files
committed
Adds renderCheckbox() method to "uui-card" component
1 parent 10a10e2 commit 7e23cf7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

packages/uui-card/lib/uui-card.element.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { property } from 'lit/decorators.js';
99

1010
import { UUICardEvent } from './UUICardEvent';
1111

12+
import '@umbraco-ui/uui-checkbox/lib';
13+
1214
/**
1315
* Card is a Component that provides the basics for a Card component. This can be extended in code to match a certain need.
1416
* @element uui-card
@@ -83,6 +85,19 @@ export class UUICardElement extends SelectOnlyMixin(
8385
this.dispatchEvent(new UUICardEvent(UUICardEvent.OPEN));
8486
}
8587

88+
protected renderCheckbox() {
89+
if (!this.selectable) return;
90+
return html`
91+
<uui-checkbox
92+
id="select-checkbox"
93+
label="select"
94+
?checked=${this.selected}
95+
@click=${(e: MouseEvent) => e.stopPropagation()}
96+
@change=${() => this.click()}>
97+
</uui-checkbox>
98+
`;
99+
}
100+
86101
protected render() {
87102
return html`<slot id="open-part"></slot>
88103
<div id="select-border"></div>`;
@@ -236,6 +251,21 @@ export class UUICardElement extends SelectOnlyMixin(
236251
background: var(--uui-color-disabled);
237252
color: var(--uui-color-disabled-contrast);
238253
}
254+
255+
#select-checkbox {
256+
position: absolute;
257+
top: var(--uui-size-4);
258+
left: var(--uui-size-4);
259+
opacity: 0;
260+
transition: opacity 120ms;
261+
z-index: 3;
262+
}
263+
:host(:focus) #select-checkbox,
264+
:host(:focus-within) #select-checkbox,
265+
:host(:hover) #select-checkbox,
266+
#select-checkbox[checked] {
267+
opacity: 1;
268+
}
239269
`,
240270
];
241271
}

0 commit comments

Comments
 (0)