Skip to content

Commit 46073af

Browse files
committed
Group checkboxes in dropdowns
1 parent 40272b8 commit 46073af

File tree

8 files changed

+1252
-1140
lines changed

8 files changed

+1252
-1140
lines changed

src/app/content/components/popUp/ChapterFilter.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const ChapterFilter = (props: ChapterFilterProps) => {
118118
)
119119
: null}
120120
<Row>
121-
{sectionChunks.map((sectionChunk, index) => <Column key={index}>
121+
{sectionChunks.map((sectionChunk, index) => <Column key={index} role='group' aria-label='Filter by chapters'>
122122
{sectionChunk.map((location) => {
123123
const { section, children } = location;
124124
if (!children) {

src/app/content/components/popUp/ColorFilter.tsx

+28-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import styled, { css } from 'styled-components/macro';
55
import AllOrNone from '../../../components/AllOrNone';
66
import Checkbox from '../../../components/Checkbox';
77
import { textStyle } from '../../../components/Typography/base';
8-
import theme from '../../../theme';
8+
import theme, { hiddenButAccessible } from '../../../theme';
99
import { highlightStyles } from '../../constants';
1010
import ColorIndicator from '../../highlights/components/ColorIndicator';
1111
import { filters, mobileMarginSides } from '../../styles/PopupConstants';
@@ -19,6 +19,17 @@ const ColorLabel = styled.span`
1919
white-space: nowrap;
2020
`;
2121

22+
// tslint:disable-next-line: variable-name
23+
const Fieldset = styled.fieldset`
24+
padding: 0;
25+
border: none;
26+
margin: 0;
27+
28+
legend {
29+
${hiddenButAccessible}
30+
}
31+
`;
32+
2233
export interface ColorFilterProps {
2334
className?: string;
2435
disabled?: boolean;
@@ -58,19 +69,22 @@ const ColorFilter = ({
5869
onAll={() => setSelectedColors({ remove: [], new: Array.from(colorFiltersWithContent) })}
5970
disabled={disabled}
6071
/>
61-
{styles.map((style) => <Checkbox
62-
key={style.label}
63-
checked={selectedColorFilters.has(style.label)}
64-
disabled={disabled || !colorFiltersWithContent.has(style.label)}
65-
onChange={() => handleChange(style.label)}
66-
>
67-
<ColorIndicator style={style} size='small'/>
68-
<ColorLabel>
69-
<FormattedMessage id={labelKey(style.label)}>
70-
{(msg) => msg}
71-
</FormattedMessage>
72-
</ColorLabel>
73-
</Checkbox>)}
72+
<Fieldset>
73+
<legend>Filter by colors</legend>
74+
{styles.map((style) => <Checkbox
75+
key={style.label}
76+
checked={selectedColorFilters.has(style.label)}
77+
disabled={disabled || !colorFiltersWithContent.has(style.label)}
78+
onChange={() => handleChange(style.label)}
79+
>
80+
<ColorIndicator style={style} size='small'/>
81+
<ColorLabel>
82+
<FormattedMessage id={labelKey(style.label)}>
83+
{(msg) => msg}
84+
</FormattedMessage>
85+
</ColorLabel>
86+
</Checkbox>)}
87+
</Fieldset>
7488
</div>;
7589
};
7690

src/app/content/components/popUp/__snapshots__/ChapterFilter.spec.tsx.snap

+2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ input:checked + .c10 .c12 {
294294
className="c5"
295295
>
296296
<div
297+
aria-label="Filter by chapters"
297298
className="c6"
299+
role="group"
298300
>
299301
<label
300302
className="c7 c8"

0 commit comments

Comments
 (0)