Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit dd55605

Browse files
author
Kerry Archibald
committed
use semantic headings in LabsUserSettingsTab
1 parent 603e2f8 commit dd55605

File tree

6 files changed

+138
-150
lines changed

6 files changed

+138
-150
lines changed

Diff for: res/css/_components.pcss

-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@
344344
@import "./views/settings/tabs/user/_GeneralUserSettingsTab.pcss";
345345
@import "./views/settings/tabs/user/_HelpUserSettingsTab.pcss";
346346
@import "./views/settings/tabs/user/_KeyboardUserSettingsTab.pcss";
347-
@import "./views/settings/tabs/user/_LabsUserSettingsTab.pcss";
348347
@import "./views/settings/tabs/user/_MjolnirUserSettingsTab.pcss";
349348
@import "./views/settings/tabs/user/_PreferencesUserSettingsTab.pcss";
350349
@import "./views/settings/tabs/user/_SecurityUserSettingsTab.pcss";

Diff for: res/css/views/beta/_BetaCard.pcss

-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ limitations under the License.
1515
*/
1616

1717
.mx_BetaCard {
18-
margin-bottom: $spacing-20;
1918
padding: $spacing-24;
2019
background-color: $system;
2120
border-radius: 8px;
@@ -114,10 +113,6 @@ limitations under the License.
114113
}
115114
}
116115
}
117-
118-
&:last-child {
119-
margin-bottom: 0;
120-
}
121116
}
122117

123118
.mx_BetaCard_betaPill {

Diff for: res/css/views/settings/tabs/user/_LabsUserSettingsTab.pcss

-27
This file was deleted.

Diff for: src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx

+29-22
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import BetaCard from "../../../beta/BetaCard";
2525
import SettingsFlag from "../../../elements/SettingsFlag";
2626
import { LabGroup, labGroupNames } from "../../../../../settings/Settings";
2727
import { EnhancedMap } from "../../../../../utils/maps";
28+
import { SettingsSection } from "../../shared/SettingsSection";
29+
import SettingsSubsection, { SettingsSubsectionText } from "../../shared/SettingsSubsection";
30+
import SettingsTab from "../SettingsTab";
2831

2932
export default class LabsUserSettingsTab extends React.Component<{}> {
3033
private readonly labs: string[];
@@ -54,11 +57,11 @@ export default class LabsUserSettingsTab extends React.Component<{}> {
5457
let betaSection: JSX.Element | undefined;
5558
if (this.betas.length) {
5659
betaSection = (
57-
<div data-testid="labs-beta-section" className="mx_SettingsTab_section">
60+
<>
5861
{this.betas.map((f) => (
5962
<BetaCard key={f} featureId={f} />
6063
))}
61-
</div>
64+
</>
6265
);
6366
}
6467

@@ -93,31 +96,35 @@ export default class LabsUserSettingsTab extends React.Component<{}> {
9396
labsSections = (
9497
<>
9598
{sortBy(Array.from(groups.entries()), "0").map(([group, flags]) => (
96-
<div className="mx_SettingsTab_section" key={group} data-testid={`labs-group-${group}`}>
97-
<span className="mx_SettingsTab_subheading">{_t(labGroupNames[group])}</span>
99+
<SettingsSubsection
100+
key={group}
101+
data-testid={`labs-group-${group}`}
102+
heading={_t(labGroupNames[group])}
103+
>
98104
{flags}
99-
</div>
105+
</SettingsSubsection>
100106
))}
101107
</>
102108
);
103109
}
104110

105111
return (
106-
<div className="mx_SettingsTab mx_LabsUserSettingsTab">
107-
<div className="mx_SettingsTab_heading">{_t("Upcoming features")}</div>
108-
<div className="mx_SettingsTab_subsectionText">
109-
{_t(
110-
"What's next for %(brand)s? " +
111-
"Labs are the best way to get things early, " +
112-
"test out new features and help shape them before they actually launch.",
113-
{ brand: SdkConfig.get("brand") },
114-
)}
115-
</div>
116-
{betaSection}
112+
<SettingsTab>
113+
<SettingsSection heading={_t("Upcoming features")}>
114+
<SettingsSubsectionText>
115+
{_t(
116+
"What's next for %(brand)s? " +
117+
"Labs are the best way to get things early, " +
118+
"test out new features and help shape them before they actually launch.",
119+
{ brand: SdkConfig.get("brand") },
120+
)}
121+
</SettingsSubsectionText>
122+
{betaSection}
123+
</SettingsSection>
124+
117125
{labsSections && (
118-
<>
119-
<div className="mx_SettingsTab_heading">{_t("Early previews")}</div>
120-
<div className="mx_SettingsTab_subsectionText">
126+
<SettingsSection heading={_t("Early previews")}>
127+
<SettingsSubsectionText>
121128
{_t(
122129
"Feeling experimental? " +
123130
"Try out our latest ideas in development. " +
@@ -139,11 +146,11 @@ export default class LabsUserSettingsTab extends React.Component<{}> {
139146
},
140147
},
141148
)}
142-
</div>
149+
</SettingsSubsectionText>
143150
{labsSections}
144-
</>
151+
</SettingsSection>
145152
)}
146-
</div>
153+
</SettingsTab>
147154
);
148155
}
149156
}

Diff for: test/components/views/settings/tabs/user/LabsUserSettingsTab-test.tsx

+9-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License.
1515
*/
1616

1717
import React from "react";
18-
import { render, waitFor } from "@testing-library/react";
18+
import { render, screen, waitFor } from "@testing-library/react";
1919
import { defer } from "matrix-js-sdk/src/utils";
2020

2121
import LabsUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/LabsUserSettingsTab";
@@ -51,26 +51,27 @@ describe("<LabsUserSettingsTab />", () => {
5151
});
5252

5353
it("renders settings marked as beta as beta cards", () => {
54-
const { getByTestId } = render(getComponent());
55-
expect(getByTestId("labs-beta-section")).toMatchSnapshot();
54+
render(getComponent());
55+
expect(screen.getByText("Upcoming features").parentElement!).toMatchSnapshot();
5656
});
5757

5858
it("does not render non-beta labs settings when disabled in config", () => {
59-
const { container } = render(getComponent());
59+
render(getComponent());
6060
expect(sdkConfigSpy).toHaveBeenCalledWith("show_labs_settings");
6161

62-
const labsSections = container.getElementsByClassName("mx_SettingsTab_section");
6362
// only section is beta section
64-
expect(labsSections.length).toEqual(1);
63+
expect(screen.queryByText("Early previews")).not.toBeInTheDocument();
6564
});
6665

6766
it("renders non-beta labs settings when enabled in config", () => {
6867
// enable labs
6968
sdkConfigSpy.mockImplementation((configName) => configName === "show_labs_settings");
7069
const { container } = render(getComponent());
7170

72-
const labsSections = container.getElementsByClassName("mx_SettingsTab_section");
73-
expect(labsSections).toHaveLength(12);
71+
// non-beta labs section
72+
expect(screen.getByText("Early previews")).toBeInTheDocument();
73+
const labsSections = container.getElementsByClassName("mx_SettingsSubsection");
74+
expect(labsSections).toHaveLength(11);
7475
});
7576

7677
it("allow setting a labs flag which requires unstable support once support is confirmed", async () => {

0 commit comments

Comments
 (0)