Skip to content

Commit

Permalink
feat: implement readonly for uui-card-block-type
Browse files Browse the repository at this point in the history
  • Loading branch information
madsrasmussen committed Aug 28, 2024
1 parent aa16432 commit 9b97095
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/uui-card-block-type/lib/uui-card-block-type.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export class UUICardBlockTypeElement extends UUICardElement {
style=${styleMap({ backgroundColor: this.background })}>
<slot></slot>
</div>
${this.href ? this.#renderLink() : this.#renderButton()}
${this.#renderContent()}
<slot name="tag"></slot>
<slot name="actions"></slot>
`;
Expand Down Expand Up @@ -83,6 +82,16 @@ export class UUICardBlockTypeElement extends UUICardElement {
`;
}

#renderContent() {
if (this.readonly) {
return html`<div id="open-part">
<strong>${this.name}</strong><small>${this.description}</small>
</div>`;
} else {
return html` ${this.href ? this.#renderLink() : this.#renderButton()} `;
}
}

static styles = [
...UUICardElement.styles,
css`
Expand Down Expand Up @@ -135,6 +144,10 @@ export class UUICardBlockTypeElement extends UUICardElement {
color: var(--uui-color-contrast-disabled);
}
:host([readonly]) #open-part {
pointer-events: none;
}
#open-part:hover strong {
text-decoration: underline;
}
Expand Down

0 comments on commit 9b97095

Please sign in to comment.