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

Commit 603e2f8

Browse files
author
Kerry Archibald
committed
allow testids in settings sections
1 parent 3ca957b commit 603e2f8

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

res/css/components/views/settings/shared/_SettingsSubsection.pcss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ limitations under the License.
4646
margin-bottom: $spacing-8;
4747
}
4848
}
49+
50+
&.mx_SettingsSubsection_contentStretch {
51+
justify-items: stretch;
52+
}
4953
}

res/css/views/elements/_SettingsFlag.pcss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ limitations under the License.
2020
align-items: flex-start;
2121
justify-content: space-between;
2222
margin-bottom: 4px;
23+
width: 100%;
2324

2425
.mx_ToggleSwitch {
2526
flex: 0 0 auto;

res/css/views/settings/tabs/_SettingsTab.pcss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ limitations under the License.
1515
*/
1616

1717
.mx_SettingsTab {
18-
--SettingsTab_section-margin-bottom-preferences-labs: 30px;
1918
--SettingsTab_heading_nth_child-margin-top: 30px; /* TODO: Use a spacing variable */
2019
--SettingsTab_fullWidthField-margin-inline-end: 100px;
2120
--SettingsTab_tooltip-max-width: 120px; /* So it fits in the space provided by the page */

src/components/views/settings/shared/SettingsSubsection.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
import classNames from "classnames";
1718
import React, { HTMLAttributes } from "react";
1819

1920
import { SettingsSubsectionHeading } from "./SettingsSubsectionHeading";
@@ -22,6 +23,8 @@ export interface SettingsSubsectionProps extends HTMLAttributes<HTMLDivElement>
2223
heading: string | React.ReactNode;
2324
description?: string | React.ReactNode;
2425
children?: React.ReactNode;
26+
// when true content will be justify-items: stretch
27+
stretchContent?: boolean;
2528
}
2629

2730
export const SettingsSubsectionText: React.FC<HTMLAttributes<HTMLDivElement>> = ({ children, ...rest }) => (
@@ -30,15 +33,27 @@ export const SettingsSubsectionText: React.FC<HTMLAttributes<HTMLDivElement>> =
3033
</div>
3134
);
3235

33-
export const SettingsSubsection: React.FC<SettingsSubsectionProps> = ({ heading, description, children, ...rest }) => (
36+
export const SettingsSubsection: React.FC<SettingsSubsectionProps> = ({
37+
heading,
38+
description,
39+
children,
40+
stretchContent,
41+
...rest
42+
}) => (
3443
<div {...rest} className="mx_SettingsSubsection">
3544
{typeof heading === "string" ? <SettingsSubsectionHeading heading={heading} /> : <>{heading}</>}
3645
{!!description && (
3746
<div className="mx_SettingsSubsection_description">
3847
<SettingsSubsectionText>{description}</SettingsSubsectionText>
3948
</div>
4049
)}
41-
<div className="mx_SettingsSubsection_content">{children}</div>
50+
<div
51+
className={classNames("mx_SettingsSubsection_content", {
52+
mx_SettingsSubsection_contentStretch: stretchContent,
53+
})}
54+
>
55+
{children}
56+
</div>
4257
</div>
4358
);
4459

src/components/views/settings/tabs/SettingsTab.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
import React from "react";
16+
import React, { HTMLAttributes } from "react";
1717

18-
export interface SettingsTabProps {
18+
export interface SettingsTabProps extends Omit<HTMLAttributes<HTMLDivElement>, "className"> {
1919
children?: React.ReactNode;
2020
}
2121

@@ -37,8 +37,8 @@ export interface SettingsTabProps {
3737
* </SettingsTab>
3838
* ```
3939
*/
40-
const SettingsTab: React.FC<SettingsTabProps> = ({ children }) => (
41-
<div className="mx_SettingsTab">
40+
const SettingsTab: React.FC<SettingsTabProps> = ({ children, ...rest }) => (
41+
<div {...rest} className="mx_SettingsTab">
4242
<div className="mx_SettingsTab_sections">{children}</div>
4343
</div>
4444
);

0 commit comments

Comments
 (0)