Skip to content

Commit 2743cf3

Browse files
committed
feat(cc-popover): add disabled property
Fixes #1207
1 parent 7c69413 commit 2743cf3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/components/cc-popover/cc-popover.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class CcPopover extends LitElement {
6161
static get properties() {
6262
return {
6363
a11yName: { type: String, attribute: 'a11y-name' },
64+
disabled: { type: Boolean, reflect: true },
6465
hideText: { type: Boolean, attribute: 'hide-text' },
6566
icon: { type: Object },
6667
isOpen: { type: Boolean, attribute: 'is-open', reflect: true },
@@ -74,6 +75,9 @@ export class CcPopover extends LitElement {
7475
/** @type {string|null} Sets the a11yName property of the underlying `cc-button` element. CAUTION: The accessible name should always start with the visible text if there is one. */
7576
this.a11yName = null;
7677

78+
/** @type {boolean} Sets `disabled` attribute on the underlying `cc-button` element. */
79+
this.disabled = false;
80+
7781
/** @type {boolean} Whether the button text should be hidden. */
7882
this.hideText = false;
7983

@@ -210,13 +214,14 @@ export class CcPopover extends LitElement {
210214
.a11yExpanded=${this.isOpen}
211215
.a11yName=${this.a11yName}
212216
?hide-text=${this.hideText}
217+
?disabled=${this.disabled}
213218
.icon=${this.icon}
214219
@cc-button:click=${this.toggle}
215220
>
216221
<slot name="button-content"></slot>
217222
</cc-button>
218223
219-
${this.isOpen
224+
${this.isOpen && !this.disabled
220225
? html`
221226
<div class="content ${this.position.replace('-', ' ')}" ${ref(this._contentRef)}>
222227
<slot></slot>

src/components/cc-popover/cc-popover.stories.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ export const defaultStory = makeStory(conf, {
6363
items,
6464
});
6565

66+
export const disabled = makeStory(conf, {
67+
items: items.map((item) => ({
68+
...item,
69+
disabled: true,
70+
})),
71+
});
72+
6673
export const withButtonText = makeStory(conf, {
6774
items: items.map((item) => ({
6875
...item,

0 commit comments

Comments
 (0)