Skip to content

Commit

Permalink
feat(cc-popover): add disabled property
Browse files Browse the repository at this point in the history
Fixes #1207
  • Loading branch information
pdesoyres-cc committed Jan 17, 2025
1 parent 7c69413 commit 2743cf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/cc-popover/cc-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class CcPopover extends LitElement {
static get properties() {
return {
a11yName: { type: String, attribute: 'a11y-name' },
disabled: { type: Boolean, reflect: true },
hideText: { type: Boolean, attribute: 'hide-text' },
icon: { type: Object },
isOpen: { type: Boolean, attribute: 'is-open', reflect: true },
Expand All @@ -74,6 +75,9 @@ export class CcPopover extends LitElement {
/** @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. */
this.a11yName = null;

/** @type {boolean} Sets `disabled` attribute on the underlying `cc-button` element. */
this.disabled = false;

/** @type {boolean} Whether the button text should be hidden. */
this.hideText = false;

Expand Down Expand Up @@ -210,13 +214,14 @@ export class CcPopover extends LitElement {
.a11yExpanded=${this.isOpen}
.a11yName=${this.a11yName}
?hide-text=${this.hideText}
?disabled=${this.disabled}
.icon=${this.icon}
@cc-button:click=${this.toggle}
>
<slot name="button-content"></slot>
</cc-button>
${this.isOpen
${this.isOpen && !this.disabled
? html`
<div class="content ${this.position.replace('-', ' ')}" ${ref(this._contentRef)}>
<slot></slot>
Expand Down
7 changes: 7 additions & 0 deletions src/components/cc-popover/cc-popover.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ export const defaultStory = makeStory(conf, {
items,
});

export const disabled = makeStory(conf, {
items: items.map((item) => ({
...item,
disabled: true,
})),
});

export const withButtonText = makeStory(conf, {
items: items.map((item) => ({
...item,
Expand Down

0 comments on commit 2743cf3

Please sign in to comment.