Skip to content

Commit 205449b

Browse files
author
Dennis Labordus
authored
feat(filter-button): Added option to disable filter button
1 parent 49e9007 commit 205449b

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

src/oscd-filter-button.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export class FilterButton extends FilteredList {
2626
header!: TemplateResult | string;
2727
@property()
2828
icon!: string;
29+
@property({ type: Boolean })
30+
disabled = false;
2931

3032
@query('#filterDialog')
3133
private filterDialog!: Dialog;
@@ -48,7 +50,11 @@ export class FilterButton extends FilteredList {
4850

4951
render(): TemplateResult {
5052
return html`
51-
<mwc-icon-button icon="${this.icon}" @click=${this.toggleList}>
53+
<mwc-icon-button
54+
icon="${this.icon}"
55+
@click="${this.toggleList}"
56+
?disabled="${this.disabled}"
57+
>
5258
<slot name="icon"></slot>
5359
</mwc-icon-button>
5460
<mwc-dialog

test/unit/__snapshots__/oscd-filter-button.test.snap.js

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @web/test-runner snapshot v1 */
22
export const snapshots = {};
33

4-
snapshots["oscd-filter-button multi selection with custom header and standard icon looks like its latest snapshot"] =
4+
snapshots["oscd-filter-button multi selection with custom header and standard icon looks like its latest snapshot"] =
55
`<mwc-icon-button icon="developer_board">
66
<slot name="icon">
77
</slot>
@@ -42,7 +42,7 @@ snapshots["oscd-filter-button multi selection with custom header and standard ic
4242
`;
4343
/* end snapshot oscd-filter-button multi selection with custom header and standard icon looks like its latest snapshot */
4444

45-
snapshots["oscd-filter-button single selection with default header and custom icon looks like its latest snapshot"] =
45+
snapshots["oscd-filter-button single selection with default header and custom icon looks like its latest snapshot"] =
4646
`<mwc-icon-button icon="undefined">
4747
<slot name="icon">
4848
</slot>
@@ -79,3 +79,47 @@ snapshots["oscd-filter-button single selection with default header and custom ic
7979
`;
8080
/* end snapshot oscd-filter-button single selection with default header and custom icon looks like its latest snapshot */
8181

82+
snapshots["oscd-filter-button is disabled looks like its latest snapshot"] =
83+
`<mwc-icon-button
84+
disabled=""
85+
icon="developer_board"
86+
>
87+
<slot name="icon">
88+
</slot>
89+
</mwc-icon-button>
90+
<mwc-dialog
91+
heading="Filter Header"
92+
id="filterDialog"
93+
scrimclickaction=""
94+
>
95+
<div id="tfcontainer">
96+
<abbr title="[filter]">
97+
<mwc-textfield
98+
icontrailing="search"
99+
label=""
100+
outlined=""
101+
>
102+
</mwc-textfield>
103+
</abbr>
104+
<mwc-formfield class="checkall">
105+
<mwc-checkbox indeterminate="">
106+
</mwc-checkbox>
107+
</mwc-formfield>
108+
</div>
109+
<ul
110+
class="mdc-deprecated-list"
111+
tabindex="-1"
112+
>
113+
<slot>
114+
</slot>
115+
</ul>
116+
<mwc-button
117+
dialogaction="close"
118+
slot="primaryAction"
119+
>
120+
[close]
121+
</mwc-button>
122+
</mwc-dialog>
123+
`;
124+
/* end snapshot oscd-filter-button is disabled looks like its latest snapshot */
125+

test/unit/oscd-filter-button.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,33 @@ describe('oscd-filter-button', () => {
141141
await expect(element).shadowDom.to.equalSnapshot();
142142
});
143143
});
144+
145+
describe('is disabled', () => {
146+
beforeEach(async () => {
147+
element = await fixture(
148+
html`<oscd-filter-button
149+
id="filter"
150+
icon="developer_board"
151+
header="Filter Header"
152+
disabled="true"
153+
>
154+
${Array.from(listItems).map(
155+
item =>
156+
html` <mwc-check-list-item
157+
value="${item.prim}"
158+
?selected="${item.defaultSelected}"
159+
>
160+
<span>${item.prim}</span>
161+
</mwc-check-list-item>`
162+
)}
163+
</oscd-filter-button>`
164+
);
165+
await element.requestUpdate();
166+
await element.updateComplete;
167+
});
168+
169+
it('looks like its latest snapshot', async () => {
170+
await expect(element).shadowDom.to.equalSnapshot();
171+
});
172+
});
144173
});

0 commit comments

Comments
 (0)