Skip to content

Commit e8954f0

Browse files
authored
Move CSS for ResetIdentityPanel into EncryptionCard (#29311)
* Move CSS for ResetIdentityPanel into EncryptionCard This allows it to be re-used in other components. It's a *bit* magic that EncryptionCard applies style to divs within it, although it somewhat makes sense that it wants them styled a particular way. The alternative would be to add another component for a div child of encryption card like EncryptionCardButtons that just makes it flexbox and centered: I'm not sure which is better. * Update snapshot * Update snapshot * Do it the other way Because we only want it in the destructive cards, not the other ones. * Use flex component * Also use gap prop and update snapshots * Fix justification * Snaspshots again * Set align-items to normal As center affected the list items too. Also add it to the flex component because it didn't have it as an option.
1 parent e161f9f commit e8954f0

File tree

8 files changed

+54
-30
lines changed

8 files changed

+54
-30
lines changed

res/css/_components.pcss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@
360360
@import "./views/settings/encryption/_AdvancedPanel.pcss";
361361
@import "./views/settings/encryption/_ChangeRecoveryKey.pcss";
362362
@import "./views/settings/encryption/_EncryptionCard.pcss";
363+
@import "./views/settings/encryption/_EncryptionCardEmphasisedContent.pcss";
363364
@import "./views/settings/encryption/_RecoveryPanelOutOfSync.pcss";
364-
@import "./views/settings/encryption/_ResetIdentityPanel.pcss";
365365
@import "./views/settings/tabs/_SettingsBanner.pcss";
366366
@import "./views/settings/tabs/_SettingsIndent.pcss";
367367
@import "./views/settings/tabs/_SettingsSection.pcss";
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright 2024 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
5+
* Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
.mx_EncryptionCard_emphasisedContent {
9+
span {
10+
font: var(--cpd-font-body-md-medium);
11+
text-align: center;
12+
}
13+
}

res/css/views/settings/encryption/_ResetIdentityPanel.pcss

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/components/utils/Flex.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type FlexProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any
3333
* The alignment of the flex children
3434
* @default start
3535
*/
36-
align?: "start" | "center" | "end" | "baseline" | "stretch";
36+
align?: "start" | "center" | "end" | "baseline" | "stretch" | "normal";
3737
/**
3838
* The justification of the flex children
3939
* @default start
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2025 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
5+
* Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
import React, { type PropsWithChildren } from "react";
9+
10+
import { Flex } from "../../../utils/Flex";
11+
12+
/**
13+
* A component for emphasised text within an {@link EncryptionCard}
14+
* (mostly as somewhere for the common CSS to live).
15+
*/
16+
export function EncryptionCardEmphasisedContent({ children }: PropsWithChildren): JSX.Element {
17+
return (
18+
<Flex
19+
direction="column"
20+
gap="var(--cpd-space-3x)"
21+
align="normal"
22+
className="mx_EncryptionCard_emphasisedContent"
23+
>
24+
{children}
25+
</Flex>
26+
);
27+
}

src/components/views/settings/encryption/ResetIdentityPanel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { EncryptionCard } from "./EncryptionCard";
1616
import { useMatrixClientContext } from "../../../../contexts/MatrixClientContext";
1717
import { uiAuthCallback } from "../../../../CreateCrossSigning";
1818
import { EncryptionCardButtons } from "./EncryptionCardButtons";
19+
import { EncryptionCardEmphasisedContent } from "./EncryptionCardEmphasisedContent";
1920

2021
interface ResetIdentityPanelProps {
2122
/**
@@ -59,9 +60,8 @@ export function ResetIdentityPanel({ onCancelClick, onFinish, variant }: ResetId
5960
? _t("settings|encryption|advanced|breadcrumb_title_forgot")
6061
: _t("settings|encryption|advanced|breadcrumb_title")
6162
}
62-
className="mx_ResetIdentityPanel"
6363
>
64-
<div className="mx_ResetIdentityPanel_content">
64+
<EncryptionCardEmphasisedContent>
6565
<VisualList>
6666
<VisualListItem Icon={CheckIcon} success={true}>
6767
{_t("settings|encryption|advanced|breadcrumb_first_description")}
@@ -74,7 +74,7 @@ export function ResetIdentityPanel({ onCancelClick, onFinish, variant }: ResetId
7474
</VisualListItem>
7575
</VisualList>
7676
{variant === "compromised" && <span>{_t("settings|encryption|advanced|breadcrumb_warning")}</span>}
77-
</div>
77+
</EncryptionCardEmphasisedContent>
7878
<EncryptionCardButtons>
7979
<Button
8080
destructive={true}

test/unit-tests/components/views/settings/encryption/__snapshots__/ResetIdentityPanel-test.tsx.snap

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ exports[`<ResetIdentityPanel /> should display the 'forgot recovery key' variant
5555
</ol>
5656
</nav>
5757
<div
58-
class="mx_EncryptionCard mx_ResetIdentityPanel"
58+
class="mx_EncryptionCard"
5959
>
6060
<div
6161
class="mx_EncryptionCard_header"
@@ -83,7 +83,8 @@ exports[`<ResetIdentityPanel /> should display the 'forgot recovery key' variant
8383
</h2>
8484
</div>
8585
<div
86-
class="mx_ResetIdentityPanel_content"
86+
class="mx_Flex mx_EncryptionCard_emphasisedContent"
87+
style="--mx-flex-display: flex; --mx-flex-direction: column; --mx-flex-align: normal; --mx-flex-justify: start; --mx-flex-gap: var(--cpd-space-3x);"
8788
>
8889
<ul
8990
class="_visual-list_4dcf8_17"
@@ -235,7 +236,7 @@ exports[`<ResetIdentityPanel /> should reset the encryption when the continue bu
235236
</ol>
236237
</nav>
237238
<div
238-
class="mx_EncryptionCard mx_ResetIdentityPanel"
239+
class="mx_EncryptionCard"
239240
>
240241
<div
241242
class="mx_EncryptionCard_header"
@@ -263,7 +264,8 @@ exports[`<ResetIdentityPanel /> should reset the encryption when the continue bu
263264
</h2>
264265
</div>
265266
<div
266-
class="mx_ResetIdentityPanel_content"
267+
class="mx_Flex mx_EncryptionCard_emphasisedContent"
268+
style="--mx-flex-display: flex; --mx-flex-direction: column; --mx-flex-align: normal; --mx-flex-justify: start; --mx-flex-gap: var(--cpd-space-3x);"
267269
>
268270
<ul
269271
class="_visual-list_4dcf8_17"

test/unit-tests/components/views/settings/tabs/user/__snapshots__/EncryptionUserSettingsTab-test.tsx.snap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ exports[`<EncryptionUserSettingsTab /> should display the reset identity panel w
226226
</ol>
227227
</nav>
228228
<div
229-
class="mx_EncryptionCard mx_ResetIdentityPanel"
229+
class="mx_EncryptionCard"
230230
>
231231
<div
232232
class="mx_EncryptionCard_header"
@@ -254,7 +254,8 @@ exports[`<EncryptionUserSettingsTab /> should display the reset identity panel w
254254
</h2>
255255
</div>
256256
<div
257-
class="mx_ResetIdentityPanel_content"
257+
class="mx_Flex mx_EncryptionCard_emphasisedContent"
258+
style="--mx-flex-display: flex; --mx-flex-direction: column; --mx-flex-align: normal; --mx-flex-justify: start; --mx-flex-gap: var(--cpd-space-3x);"
258259
>
259260
<ul
260261
class="_visual-list_4dcf8_17"

0 commit comments

Comments
 (0)