Skip to content

Commit a48f455

Browse files
committed
lint
1 parent 20a4111 commit a48f455

File tree

9 files changed

+74
-31
lines changed

9 files changed

+74
-31
lines changed

res/css/views/settings/tabs/user/_SidebarUserSettingsTab.pcss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ Please see LICENSE files in the repository root for full details.
1616

1717
.mx_SidebarUserSettingsTab_icon {
1818
margin-right: var(--cpd-space-2x);
19-
}
19+
}

src/components/structures/SpaceHierarchy.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,14 @@ const Tile: React.FC<ITileProps> = ({
174174
let checkbox: ReactElement | undefined;
175175
if (onToggleClick) {
176176
if (hasPermissions) {
177-
checkbox = <StyledCheckbox role="presentation" aria-labelledby={checkboxLabelId} checked={!!selected} tabIndex={-1} />;
177+
checkbox = (
178+
<StyledCheckbox
179+
role="presentation"
180+
aria-labelledby={checkboxLabelId}
181+
checked={!!selected}
182+
tabIndex={-1}
183+
/>
184+
);
178185
} else {
179186
checkbox = (
180187
<TextWithTooltip
@@ -183,7 +190,12 @@ const Tile: React.FC<ITileProps> = ({
183190
ev.stopPropagation();
184191
}}
185192
>
186-
<StyledCheckbox role="presentation" aria-labelledby={checkboxLabelId} disabled={true} tabIndex={-1} />
193+
<StyledCheckbox
194+
role="presentation"
195+
aria-labelledby={checkboxLabelId}
196+
disabled={true}
197+
tabIndex={-1}
198+
/>
187199
</TextWithTooltip>
188200
);
189201
}

src/components/views/dialogs/BulkRedactDialog.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ const BulkRedactDialog: React.FC<Props> = (props) => {
113113
<div className="mx_Dialog_content" id="mx_Dialog_content">
114114
<p>{_t("user_info|redact|confirm_description_1", { count, user })}</p>
115115
<p>{_t("user_info|redact|confirm_description_2")}</p>
116-
<StyledCheckbox description={_t("user_info|redact|confirm_keep_state_explainer")} checked={keepStateEvents} onChange={(e) => setKeepStateEvents(e.target.checked)}>
116+
<StyledCheckbox
117+
description={_t("user_info|redact|confirm_keep_state_explainer")}
118+
checked={keepStateEvents}
119+
onChange={(e) => setKeepStateEvents(e.target.checked)}
120+
>
117121
{_t("user_info|redact|confirm_keep_state_label")}
118122
</StyledCheckbox>
119123
</div>

src/components/views/dialogs/ManageRestrictedJoinRuleDialog.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ const Entry: React.FC<{
5151
disabled={!onChange}
5252
description={description}
5353
>
54-
<div>
55-
{localRoom ? <RoomAvatar role="none" room={room} size="20px" /> : <RoomAvatar oobData={room} size="20px" />}
56-
<span className="mx_ManageRestrictedJoinRuleDialog_entry_name">{room.name}</span>
57-
</div>
54+
<div>
55+
{localRoom ? (
56+
<RoomAvatar role="none" room={room} size="20px" />
57+
) : (
58+
<RoomAvatar oobData={room} size="20px" />
59+
)}
60+
<span className="mx_ManageRestrictedJoinRuleDialog_entry_name">{room.name}</span>
61+
</div>
5862
</StyledCheckbox>
5963
</div>
6064
);

src/components/views/dialogs/SpacePreferencesDialog.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@ const SpacePreferencesAppearanceTab: React.FC<Pick<IProps, "space">> = ({ space
4545
!showPeople,
4646
);
4747
}}
48-
description={
49-
_t("space|preferences|show_people_in_space", {
50-
spaceName: space.name,
51-
})}
48+
description={_t("space|preferences|show_people_in_space", {
49+
spaceName: space.name,
50+
})}
5251
>
5352
{_t("common|people")}
5453
</StyledCheckbox>
55-
<SettingsSubsectionText>
56-
</SettingsSubsectionText>
54+
<SettingsSubsectionText />
5755
</SettingsSubsection>
5856
</SettingsSection>
5957
</SettingsTab>

src/components/views/elements/LabelledCheckbox.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ interface IProps {
2828

2929
const LabelledCheckbox: React.FC<IProps> = ({ value, label, byline, disabled, onChange, className }) => {
3030
return (
31-
<label className={classnames("mx_LabelledCheckbox", className)}>
32-
<StyledCheckbox description={byline} disabled={disabled} checked={value} onChange={(e) => onChange(e.target.checked)}>
31+
<div className={classnames("mx_LabelledCheckbox", className)}>
32+
<StyledCheckbox
33+
description={byline}
34+
disabled={disabled}
35+
checked={value}
36+
onChange={(e) => onChange(e.target.checked)}
37+
>
3338
<span className="mx_LabelledCheckbox_label">{label}</span>
3439
</StyledCheckbox>
35-
</label>
40+
</div>
3641
);
3742
};
3843

src/components/views/elements/StyledCheckbox.tsx

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,47 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
66
Please see LICENSE files in the repository root for full details.
77
*/
88

9-
import React, { PropsWithChildren, useId, type ReactNode, type Ref } from "react";
9+
import React, { useId, type ReactNode, type Ref } from "react";
1010
import { secureRandomString } from "matrix-js-sdk/src/randomstring";
1111
import { CheckboxInput, Form, HelpMessage, InlineField, Label } from "@vector-im/compound-web";
1212

1313
interface IProps extends React.InputHTMLAttributes<HTMLInputElement> {
1414
inputRef?: Ref<HTMLInputElement>;
1515
id?: string;
16-
description?: ReactNode,
16+
description?: ReactNode;
1717
}
1818

1919
/* eslint @typescript-eslint/no-unused-vars: ["error", { "ignoreRestSiblings": true }] */
20-
export default function StyledCheckbox({id: initialId, children: label, className, inputRef, description, ...otherProps}: PropsWithChildren<IProps>) {
21-
const id = initialId || "checkbox_" + secureRandomString(10);
22-
const name = useId();
23-
const descriptionId = useId();
24-
return <Form.Root>
25-
<InlineField className={className} name={name} control={
26-
<CheckboxInput ref={inputRef} aria-describedby={description ? descriptionId : undefined} id={id} {...otherProps}/>
27-
}>
20+
const StyledCheckbox: React.FC<IProps> = ({
21+
id: initialId,
22+
children: label,
23+
className,
24+
inputRef,
25+
description,
26+
...otherProps
27+
}) => {
28+
const id = initialId || "checkbox_" + secureRandomString(10);
29+
const name = useId();
30+
const descriptionId = useId();
31+
return (
32+
<Form.Root>
33+
<InlineField
34+
className={className}
35+
name={name}
36+
control={
37+
<CheckboxInput
38+
ref={inputRef}
39+
aria-describedby={description ? descriptionId : undefined}
40+
id={id}
41+
{...otherProps}
42+
/>
43+
}
44+
>
2845
{label && <Label htmlFor={id}>{label}</Label>}
2946
{description && <HelpMessage id={descriptionId}>{description}</HelpMessage>}
3047
</InlineField>
31-
</Form.Root>;
32-
}
48+
</Form.Root>
49+
);
50+
};
51+
52+
export default StyledCheckbox;

src/components/views/settings/devices/SelectableDeviceTile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface Props extends DeviceTileProps {
2020
const SelectableDeviceTile: React.FC<Props> = ({ children, device, isSelected, onSelect, onClick }) => {
2121
return (
2222
<div className="mx_SelectableDeviceTile">
23-
{/* hs-a11y-todo */}
23+
{/* hs-a11y-todo */}
2424
<StyledCheckbox
2525
checked={isSelected}
2626
onChange={onSelect}

src/components/views/settings/tabs/user/SidebarUserSettingsTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const SidebarUserSettingsTab: React.FC = () => {
139139
className="mx_SidebarUserSettingsTab_checkbox"
140140
description={_t("settings|sidebar|metaspaces_orphans_description")}
141141
>
142-
{_t("settings|sidebar|metaspaces_orphans")}
142+
{_t("settings|sidebar|metaspaces_orphans")}
143143
</StyledCheckbox>
144144
{SettingsStore.getValue("feature_video_rooms") && (
145145
<StyledCheckbox

0 commit comments

Comments
 (0)