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

Commit

Permalink
Use semantic headings in user settings Help & About (#10752)
Browse files Browse the repository at this point in the history
* split SettingsSection out of SettingsTab, replace usage

* correct copyright

* use semantic headings in GeneralRoomSettingsTab

* use SettingsTab and SettingsSubsection in room settings

* fix VoipRoomSettingsTab

* use SettingsSection components in space settings

* settingssubsection text component

* use semantic headings in HelpUserSetttings tab

* use ExternalLink components for external links

* test

* strict

* lint
  • Loading branch information
Kerry authored May 3, 2023
1 parent bbdca11 commit 692d73d
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 211 deletions.
21 changes: 19 additions & 2 deletions res/css/components/views/settings/shared/_SettingsSubsection.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,30 @@ limitations under the License.
}

.mx_SettingsSubsection_description {
margin-top: $spacing-8;
}

.mx_SettingsSubsection_text {
width: 100%;
box-sizing: inherit;
line-height: $font-24px;
margin-bottom: $spacing-24;
font-size: $font-15px;
color: $secondary-content;
}

.mx_SettingsSubsection_content {
width: 100%;
display: grid;
grid-gap: $spacing-8;
grid-template-columns: 1fr;
justify-items: flex-start;
margin-top: $spacing-24;

summary {
color: $accent;
}
details[open] {
summary {
margin-bottom: $spacing-8;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
.mx_SettingsSubsectionHeading {
display: flex;
flex-direction: row;
padding-bottom: $spacing-8;

gap: $spacing-8;
}
Expand Down
14 changes: 12 additions & 2 deletions src/components/views/settings/shared/SettingsSubsection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,20 @@ export interface SettingsSubsectionProps extends HTMLAttributes<HTMLDivElement>
children?: React.ReactNode;
}

const SettingsSubsection: React.FC<SettingsSubsectionProps> = ({ heading, description, children, ...rest }) => (
export const SettingsSubsectionText: React.FC<HTMLAttributes<HTMLDivElement>> = ({ children, ...rest }) => (
<div {...rest} className="mx_SettingsSubsection_text">
{children}
</div>
);

export const SettingsSubsection: React.FC<SettingsSubsectionProps> = ({ heading, description, children, ...rest }) => (
<div {...rest} className="mx_SettingsSubsection">
{typeof heading === "string" ? <SettingsSubsectionHeading heading={heading} /> : <>{heading}</>}
{!!description && <div className="mx_SettingsSubsection_description">{description}</div>}
{!!description && (
<div className="mx_SettingsSubsection_description">
<SettingsSubsectionText>{description}</SettingsSubsectionText>
</div>
)}
<div className="mx_SettingsSubsection_content">{children}</div>
</div>
);
Expand Down
360 changes: 167 additions & 193 deletions src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion test/components/views/dialogs/UserSettingsDialog-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ describe("<UserSettingsDialog />", () => {

const getActiveTabLabel = (container: Element) =>
container.querySelector(".mx_TabbedView_tabLabel_active")?.textContent;
const getActiveTabHeading = (container: Element) => container.querySelector(".mx_SettingsTab_heading")?.textContent;
const getActiveTabHeading = (container: Element) =>
container.querySelector(".mx_SettingsTab_heading")?.textContent ||
container.querySelector(".mx_SettingsSection .mx_Heading_h2")?.textContent;

it("should render general settings tab when no initialTabId", () => {
const { container } = render(getComponent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ exports[`<SecurityRecommendations /> renders both cards when user has both unver
<div
class="mx_SettingsSubsection_description"
>
Improve your account security by following these recommendations.
<div
class="mx_SettingsSubsection_text"
>
Improve your account security by following these recommendations.
</div>
</div>
<div
class="mx_SettingsSubsection_content"
Expand Down Expand Up @@ -139,7 +143,11 @@ exports[`<SecurityRecommendations /> renders inactive devices section when user
<div
class="mx_SettingsSubsection_description"
>
Improve your account security by following these recommendations.
<div
class="mx_SettingsSubsection_text"
>
Improve your account security by following these recommendations.
</div>
</div>
<div
class="mx_SettingsSubsection_content"
Expand Down Expand Up @@ -260,7 +268,11 @@ exports[`<SecurityRecommendations /> renders unverified devices section when use
<div
class="mx_SettingsSubsection_description"
>
Improve your account security by following these recommendations.
<div
class="mx_SettingsSubsection_text"
>
Improve your account security by following these recommendations.
</div>
</div>
<div
class="mx_SettingsSubsection_content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ exports[`<SettingsSubsection /> renders with plain text description 1`] = `
<div
class="mx_SettingsSubsection_description"
>
This describes the subsection
<div
class="mx_SettingsSubsection_text"
>
This describes the subsection
</div>
</div>
<div
class="mx_SettingsSubsection_content"
Expand Down Expand Up @@ -72,14 +76,18 @@ exports[`<SettingsSubsection /> renders with react element description 1`] = `
<div
class="mx_SettingsSubsection_description"
>
<p>
This describes the section
<a
href="/#"
>
link
</a>
</p>
<div
class="mx_SettingsSubsection_text"
>
<p>
This describes the section
<a
href="/#"
>
link
</a>
</p>
</div>
</div>
<div
class="mx_SettingsSubsection_content"
Expand Down

0 comments on commit 692d73d

Please sign in to comment.