From 30dc009d9bedd138a15ce3d0b8a7780e6ab3296f Mon Sep 17 00:00:00 2001 From: Max Morgan Date: Thu, 5 Oct 2023 17:41:57 -0400 Subject: [PATCH] Support clickable cards --- src/components/organisms/Card/Card.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/Card/Card.js b/src/components/organisms/Card/Card.js index 29eef75e..60e8ef52 100644 --- a/src/components/organisms/Card/Card.js +++ b/src/components/organisms/Card/Card.js @@ -98,12 +98,21 @@ export default class Card extends HTMLElement { const id = this.getAttribute('data-id'); const extraClasses = this.getAttribute('data-extra-classes'); const cardClasses = ['card']; - extraClasses !== null ? cardClasses.push(extraClasses) : 0; + extraClasses !== null ? cardClasses.push(extraClasses.split(' ')) : 0; width !== null ? (this.card.style.width = width) : 0; id !== null ? (this.card.id = id) : 0; - this.card.className = cardClasses.join(' '); + // Include any existing classes from the element. + this.card.classList.add(...cardClasses); if (!this.shadowRoot.querySelector('div')) { this.shadowRoot.appendChild(this.card); } } + + setIsClickable(isClickable = true, color = null) { + if (isClickable) { + this.card.classList.add('btn', color); + } else { + this.card.classList.remove('btn', color); + } + } }