Skip to content

Commit 22bcc76

Browse files
chore: fix security settings layout (#29258)
## **Description** This PR improves the layout of the basic security section by aligning the toggle button with the heading text. The changes include: 1. Restructuring the layout using Box components with proper alignment 2. Moving the toggle button to be inline with the heading 3. Improving the visual hierarchy by using proper Typography components 4. Maintaining the description text below with appropriate spacing [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/29258?quickstart=1) ## **Related issues** Fixes: #26667 ## **Manual testing steps** 1. Go to Settings > Security & Privacy 2. Observe the Basic Configuration section at the top 3. Verify the toggle button is properly aligned with the heading 4. Verify the description text appears below with proper spacing ## **Screenshots/Recordings** ### **Before** https://github.com/user-attachments/assets/bab9a14c-8f10-4865-b159-5343537a2785 ### **After** https://github.com/user-attachments/assets/b9d02fd8-8e35-4dfa-a00d-b4e6952625df ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 41b46a0 commit 22bcc76

File tree

2 files changed

+100
-86
lines changed

2 files changed

+100
-86
lines changed

ui/pages/settings/security-tab/__snapshots__/security-tab.test.js.snap

+57-52
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,62 @@ exports[`Security Tab should match snapshot 1`] = `
1212
<div
1313
class="settings-page__content-item"
1414
>
15-
<span>
16-
Basic functionality
17-
</span>
1815
<div
19-
class="settings-page__content-description"
16+
class="mm-box mm-box--margin-bottom-2 mm-box--display-flex mm-box--justify-content-space-between mm-box--align-items-center"
17+
>
18+
<h4
19+
class="mm-box mm-text mm-text--heading-sm mm-box--color-text-default"
20+
>
21+
Basic functionality
22+
</h4>
23+
<label
24+
class="toggle-button toggle-button--off"
25+
tabindex="0"
26+
>
27+
<div
28+
style="display: flex; width: 52px; align-items: center; justify-content: flex-start; position: relative; cursor: pointer; background-color: transparent; border: 0px; padding: 0px; user-select: none;"
29+
>
30+
<div
31+
style="width: 40px; height: 24px; padding: 0px; border-radius: 26px; display: flex; align-items: center; justify-content: center; background-color: rgb(106, 115, 125);"
32+
>
33+
<div
34+
style="font-size: 11px; display: flex; align-items: center; justify-content: center; font-family: 'Helvetica Neue', Helvetica, sans-serif; position: relative; color: rgb(250, 250, 250); margin-top: auto; margin-bottom: auto; line-height: 0; opacity: 0; width: 26px; height: 20px; left: 4px;"
35+
/>
36+
<div
37+
style="font-size: 11px; display: flex; align-items: center; justify-content: center; font-family: 'Helvetica Neue', Helvetica, sans-serif; position: relative; color: rgba(255, 255, 255, 0.6); bottom: 0px; margin-top: auto; margin-bottom: auto; padding-right: 5px; line-height: 0; width: 26px; height: 20px; opacity: 1;"
38+
/>
39+
</div>
40+
<div
41+
style="position: absolute; height: 100%; top: 0px; left: 0px; display: flex; flex: 1; align-self: stretch; align-items: center; justify-content: flex-start;"
42+
>
43+
<div
44+
style="width: 18px; height: 18px; display: flex; align-self: center; box-shadow: var(--shadow-size-xs) var(--color-shadow-default); border-radius: 50%; box-sizing: border-box; position: relative; background-color: rgb(255, 255, 255); left: 3px;"
45+
/>
46+
</div>
47+
<input
48+
style="border: 0px; height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; width: 1px;"
49+
type="checkbox"
50+
value="false"
51+
/>
52+
</div>
53+
<div
54+
class="toggle-button__status"
55+
>
56+
<span
57+
class="toggle-button__label-off"
58+
>
59+
Off
60+
</span>
61+
<span
62+
class="toggle-button__label-on"
63+
>
64+
On
65+
</span>
66+
</div>
67+
</label>
68+
</div>
69+
<p
70+
class="mm-box mm-text mm-text--body-md mm-box--margin-bottom-2 mm-box--color-text-alternative"
2071
>
2172
<span>
2273
@@ -31,57 +82,11 @@ exports[`Security Tab should match snapshot 1`] = `
3182
.
3283
3384
</span>
34-
</div>
85+
</p>
3586
</div>
3687
<div
3788
class="settings-page__content-item-col"
38-
>
39-
<label
40-
class="toggle-button toggle-button--off"
41-
tabindex="0"
42-
>
43-
<div
44-
style="display: flex; width: 52px; align-items: center; justify-content: flex-start; position: relative; cursor: pointer; background-color: transparent; border: 0px; padding: 0px; user-select: none;"
45-
>
46-
<div
47-
style="width: 40px; height: 24px; padding: 0px; border-radius: 26px; display: flex; align-items: center; justify-content: center; background-color: rgb(106, 115, 125);"
48-
>
49-
<div
50-
style="font-size: 11px; display: flex; align-items: center; justify-content: center; font-family: 'Helvetica Neue', Helvetica, sans-serif; position: relative; color: rgb(250, 250, 250); margin-top: auto; margin-bottom: auto; line-height: 0; opacity: 0; width: 26px; height: 20px; left: 4px;"
51-
/>
52-
<div
53-
style="font-size: 11px; display: flex; align-items: center; justify-content: center; font-family: 'Helvetica Neue', Helvetica, sans-serif; position: relative; color: rgba(255, 255, 255, 0.6); bottom: 0px; margin-top: auto; margin-bottom: auto; padding-right: 5px; line-height: 0; width: 26px; height: 20px; opacity: 1;"
54-
/>
55-
</div>
56-
<div
57-
style="position: absolute; height: 100%; top: 0px; left: 0px; display: flex; flex: 1; align-self: stretch; align-items: center; justify-content: flex-start;"
58-
>
59-
<div
60-
style="width: 18px; height: 18px; display: flex; align-self: center; box-shadow: var(--shadow-size-xs) var(--color-shadow-default); border-radius: 50%; box-sizing: border-box; position: relative; background-color: rgb(255, 255, 255); left: 3px;"
61-
/>
62-
</div>
63-
<input
64-
style="border: 0px; height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; width: 1px;"
65-
type="checkbox"
66-
value="false"
67-
/>
68-
</div>
69-
<div
70-
class="toggle-button__status"
71-
>
72-
<span
73-
class="toggle-button__label-off"
74-
>
75-
Off
76-
</span>
77-
<span
78-
class="toggle-button__label-on"
79-
>
80-
On
81-
</span>
82-
</div>
83-
</label>
84-
</div>
89+
/>
8590
</div>
8691
<span
8792
class="settings-page__security-tab-sub-header__bold"

ui/pages/settings/security-tab/security-tab.component.js

+43-34
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
import SRPQuiz from '../../../components/app/srp-quiz-modal/SRPQuiz';
2727
import {
2828
Button,
29-
BUTTON_SIZES,
29+
ButtonSize,
3030
Icon,
3131
IconSize,
3232
IconName,
@@ -44,6 +44,7 @@ import {
4444
TextColor,
4545
TextVariant,
4646
IconColor,
47+
AlignItems,
4748
} from '../../../helpers/constants/design-system';
4849
import { ADD_POPULAR_CUSTOM_NETWORK } from '../../../helpers/constants/routes';
4950
import {
@@ -177,7 +178,7 @@ export default class SecurityTab extends PureComponent {
177178
<Button
178179
data-testid="reveal-seed-words"
179180
type="danger"
180-
size={BUTTON_SIZES.LG}
181+
size={ButtonSize.Lg}
181182
onClick={(event) => {
182183
event.preventDefault();
183184
this.context.trackEvent({
@@ -1042,8 +1043,44 @@ export default class SecurityTab extends PureComponent {
10421043
data-testid="advanced-setting-show-testnet-conversion"
10431044
>
10441045
<div className="settings-page__content-item">
1045-
<span>{t('basicConfigurationLabel')}</span>
1046-
<div className="settings-page__content-description">
1046+
<Box
1047+
display={Display.Flex}
1048+
justifyContent={JustifyContent.spaceBetween}
1049+
alignItems={AlignItems.center}
1050+
marginBottom={2}
1051+
>
1052+
<Text variant={TextVariant.headingSm}>
1053+
{t('basicConfigurationLabel')}
1054+
</Text>
1055+
<ToggleButton
1056+
value={useExternalServices}
1057+
onToggle={() => {
1058+
if (useExternalServices) {
1059+
// If we are going to be disabling external services, then we want to show the "turn off" warning modal
1060+
setBasicFunctionalityModalOpen();
1061+
} else {
1062+
toggleExternalServices(true);
1063+
this.context.trackEvent({
1064+
category: MetaMetricsEventCategory.Settings,
1065+
event: MetaMetricsEventName.SettingsUpdated,
1066+
properties: {
1067+
settings_group: 'security_privacy',
1068+
settings_type: 'basic_functionality',
1069+
old_value: false,
1070+
new_value: true,
1071+
// these values will always be set to false
1072+
// when basic functionality is re-enabled
1073+
was_notifications_on: false,
1074+
was_profile_syncing_on: false,
1075+
},
1076+
});
1077+
}
1078+
}}
1079+
offLabel={t('off')}
1080+
onLabel={t('on')}
1081+
/>
1082+
</Box>
1083+
<Text marginBottom={2} color={TextColor.textAlternative}>
10471084
{t('basicConfigurationDescription', [
10481085
<a
10491086
href="https://consensys.io/privacy-policy"
@@ -1054,38 +1091,10 @@ export default class SecurityTab extends PureComponent {
10541091
{t('privacyMsg')}
10551092
</a>,
10561093
])}
1057-
</div>
1094+
</Text>
10581095
</div>
10591096

1060-
<div className="settings-page__content-item-col">
1061-
<ToggleButton
1062-
value={useExternalServices}
1063-
onToggle={() => {
1064-
if (useExternalServices) {
1065-
// If we are going to be disabling external services, then we want to show the "turn off" warning modal
1066-
setBasicFunctionalityModalOpen();
1067-
} else {
1068-
toggleExternalServices(true);
1069-
this.context.trackEvent({
1070-
category: MetaMetricsEventCategory.Settings,
1071-
event: MetaMetricsEventName.SettingsUpdated,
1072-
properties: {
1073-
settings_group: 'security_privacy',
1074-
settings_type: 'basic_functionality',
1075-
old_value: false,
1076-
new_value: true,
1077-
// these values will always be set to false
1078-
// when basic functionality is re-enabled
1079-
was_notifications_on: false,
1080-
was_profile_syncing_on: false,
1081-
},
1082-
});
1083-
}
1084-
}}
1085-
offLabel={t('off')}
1086-
onLabel={t('on')}
1087-
/>
1088-
</div>
1097+
<div className="settings-page__content-item-col"></div>
10891098
</Box>
10901099
);
10911100
}

0 commit comments

Comments
 (0)