Skip to content

Commit 33fc0d8

Browse files
committed
feat(pos-make-findable): Switch from button to checkbox, to be able to indicate, whether a resource is present in the given index
1 parent 1d43714 commit 33fc0d8

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

elements/src/components/pos-make-findable/pos-make-findable.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ button.main {
5555
padding: 0;
5656
margin: 0;
5757
list-style: none;
58-
button {
58+
label {
59+
display: flex;
60+
justify-content: flex-start;
61+
align-items: center;
5962
transition: all 300ms var(--ease-in-out-sine);
6063
margin: 0;
6164
border: none;
6265
outline: none;
6366
padding: var(--size-2);
6467
width: var(--size-full);
6568

66-
&:hover {
69+
&:hover,
70+
&:focus {
6771
filter: brightness(80%);
6872
}
6973

@@ -72,6 +76,9 @@ button.main {
7276
}
7377
}
7478
}
79+
label:has(input:checked) {
80+
background-color: var(--color-green-100);
81+
}
7582
}
7683

7784
svg {

elements/src/components/pos-make-findable/pos-make-findable.spec.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,18 +340,20 @@ describe('pos-make-findable', () => {
340340
expect(list).toEqualHtml(`
341341
<ol role="listbox">
342342
<li role="option">
343-
<button>
343+
<label>
344+
<input type="checkbox">
344345
<pos-resource uri="https://pod.example/first-index" lazy>
345346
<pos-label></pos-label>
346347
</pos-resource>
347-
</button>
348+
</label>
348349
</li>
349350
<li role="option">
350-
<button>
351+
<label>
352+
<input type="checkbox">
351353
<pos-resource uri="https://pod.example/second-index" lazy>
352354
<pos-label></pos-label>
353355
</pos-resource>
354-
</button>
356+
</label>
355357
</li>
356358
</ol>`);
357359
});
@@ -365,8 +367,8 @@ describe('pos-make-findable', () => {
365367
// and an option is chosen
366368
const options = screen.getAllByRole('option');
367369
expect(options.length).toEqual(2);
368-
const indexButton = within(options[0]).getByRole('button');
369-
fireEvent.click(indexButton);
370+
const indexCheckbox = within(options[0]).getByRole('checkbox');
371+
fireEvent.change(indexCheckbox);
370372
await page.waitForChanges();
371373

372374
// then the thing is added to the index

elements/src/components/pos-make-findable/pos-make-findable.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ export class PosMakeFindable implements PodOsAware {
127127
<ol role="listbox">
128128
{this.indexes.map((index: LabelIndex) => (
129129
<li role="option">
130-
<button onClick={e => this.chooseOption(e, index)}>
130+
<label>
131+
<input type="checkbox" checked={false} onChange={e => this.chooseOption(e, index)} />
131132
<pos-resource uri={index.uri} lazy={true}>
132133
<pos-label></pos-label>
133134
</pos-resource>
134-
</button>
135+
</label>
135136
</li>
136137
))}
137138
</ol>
@@ -141,7 +142,7 @@ export class PosMakeFindable implements PodOsAware {
141142
);
142143
}
143144

144-
private async chooseOption(e: MouseEvent, index: LabelIndex) {
145+
private async chooseOption(e: Event, index: LabelIndex) {
145146
e.preventDefault();
146147
await this.addToLabelIndex(index);
147148
}

0 commit comments

Comments
 (0)