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

Commit 464eb93

Browse files
authored
Fix visual bugs on AccessSecretStorageDialog (#8160)
* Remove duplicate mx_Dialog_buttons Signed-off-by: Suguru Hirahara <[email protected]> * Group buttons on mx_Dialog with span - Cancel default styling for elements inside .mx_AccessSecretStorageDialog_primaryContainer Signed-off-by: Suguru Hirahara <[email protected]> * Move common rules of mx_Dialog_buttons_row to _common.scss - Set 16px gap between buttons per element-hq/element-web#19426 (comment) Signed-off-by: Suguru Hirahara <[email protected]> * Spacing variables Signed-off-by: Suguru Hirahara <[email protected]> * Nesting - .mx_AccessSecretStorageDialog_reset - Fix the reset link color - Set $spacingStart variable Signed-off-by: Suguru Hirahara <[email protected]> * Remove unnecessary rule Signed-off-by: Suguru Hirahara <[email protected]>
1 parent e2a612b commit 464eb93

File tree

5 files changed

+255
-179
lines changed

5 files changed

+255
-179
lines changed

res/css/_common.scss

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ limitations under the License.
2020
@import "./_font-sizes.scss";
2121
@import "./_font-weights.scss";
2222
@import "./_animations.scss";
23+
@import "./_spacing.scss";
2324
@import url("maplibre-gl/dist/maplibre-gl.css");
2425

2526
$hover-transition: 0.08s cubic-bezier(.46, .03, .52, .96); // quadratic
@@ -414,7 +415,8 @@ legend {
414415
}
415416

416417
.mx_Dialog_buttons {
417-
margin-top: 20px;
418+
margin-top: $spacing-20;
419+
margin-inline-start: auto;
418420
text-align: right;
419421

420422
.mx_Dialog_buttons_additive {
@@ -423,6 +425,22 @@ legend {
423425
}
424426
}
425427

428+
.mx_Dialog_buttons_row {
429+
display: flex;
430+
flex-wrap: wrap;
431+
justify-content: flex-end;
432+
text-align: initial;
433+
margin-inline-start: auto;
434+
435+
// default gap among elements
436+
column-gap: $spacing-8; // See margin-right below inside the button style
437+
row-gap: 5px; // See margin-bottom below inside the button style
438+
439+
button {
440+
margin: 0 !important; // override the margin settings
441+
}
442+
}
443+
426444
/* XXX: Our button style are a mess: buttons that happen to appear in dialogs get special styles applied
427445
* to them that no button anywhere else in the app gets by default. In practice, buttons in other places
428446
* in the app look the same by being AccessibleButtons, or possibly by having explict button classes.

res/css/views/dialogs/security/_AccessSecretStorageDialog.scss

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

17-
.mx_AccessSecretStorageDialog_reset {
18-
position: relative;
19-
padding-left: 24px; // 16px icon + 8px padding
20-
margin-top: 7px; // vertical alignment to buttons
21-
margin-bottom: 7px; // space between the buttons and the text when float is activated
22-
text-align: left;
23-
24-
&::before {
25-
content: "";
26-
display: inline-block;
27-
position: absolute;
28-
height: 16px;
29-
width: 16px;
30-
left: 0;
31-
top: 2px; // alignment
32-
background-image: url("$(res)/img/element-icons/warning-badge.svg");
33-
background-size: contain;
34-
}
35-
36-
.mx_AccessSecretStorageDialog_reset_link {
37-
color: $alert;
38-
}
39-
}
40-
4117
.mx_AccessSecretStorageDialog_titleWithIcon::before {
4218
content: '';
4319
display: inline-block;
4420
width: 24px;
4521
height: 24px;
46-
margin-right: 8px;
22+
margin-inline-end: $spacing-8;
4723
position: relative;
48-
top: 5px;
24+
top: 5px; // TODO: spacing variable
4925
background-color: $primary-content;
5026
}
5127

@@ -84,7 +60,7 @@ limitations under the License.
8460
}
8561

8662
.mx_AccessSecretStorageDialog_recoveryKeyEntry_entryControlSeparatorText {
87-
margin: 16px;
63+
margin: $spacing-16;
8864
}
8965

9066
.mx_AccessSecretStorageDialog_recoveryKeyFeedback {
@@ -97,7 +73,7 @@ limitations under the License.
9773
mask-repeat: no-repeat;
9874
mask-position: center;
9975
mask-size: 20px;
100-
margin-right: 5px;
76+
margin-inline-end: 5px; // TODO: spacing variable
10177
}
10278
}
10379

@@ -120,3 +96,44 @@ limitations under the License.
12096
.mx_AccessSecretStorageDialog_recoveryKeyEntry_fileInput {
12197
display: none;
12298
}
99+
100+
.mx_AccessSecretStorageDialog_primaryContainer {
101+
.mx_Dialog_buttons {
102+
$spacingStart: $spacing-24; // 16px icon + 8px padding
103+
104+
text-align: initial;
105+
display: flex;
106+
flex-flow: column;
107+
gap: 14px; // TODO: spacing variable
108+
109+
.mx_Dialog_buttons_additive {
110+
float: none;
111+
112+
.mx_AccessSecretStorageDialog_reset {
113+
position: relative;
114+
padding-inline-start: $spacingStart;
115+
116+
&::before {
117+
content: "";
118+
display: inline-block;
119+
position: absolute;
120+
height: 16px;
121+
width: 16px;
122+
left: 0;
123+
top: 2px; // alignment
124+
background-image: url("$(res)/img/element-icons/warning-badge.svg");
125+
background-size: contain;
126+
}
127+
128+
.mx_AccessSecretStorageDialog_reset_link {
129+
color: $alert;
130+
}
131+
}
132+
}
133+
134+
.mx_Dialog_buttons_row {
135+
gap: $spacing-16; // TODO: needs normalization
136+
padding-inline-start: $spacingStart;
137+
}
138+
}
139+
}

src/async-components/views/dialogs/security/CreateKeyBackupDialog.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,12 @@ export default class CreateKeyBackupDialog extends React.PureComponent<IProps, I
455455
if (this.state.error) {
456456
content = <div>
457457
<p>{ _t("Unable to create key backup") }</p>
458-
<div className="mx_Dialog_buttons">
459-
<DialogButtons primaryButton={_t('Retry')}
460-
onPrimaryButtonClick={this.createBackup}
461-
hasCancel={true}
462-
onCancel={this.onCancel}
463-
/>
464-
</div>
458+
<DialogButtons
459+
primaryButton={_t('Retry')}
460+
onPrimaryButtonClick={this.createBackup}
461+
hasCancel={true}
462+
onCancel={this.onCancel}
463+
/>
465464
</div>;
466465
} else {
467466
switch (this.state.phase) {

src/components/views/elements/DialogButtons.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,19 @@ export default class DialogButtons extends React.Component<IProps> {
100100
return (
101101
<div className="mx_Dialog_buttons">
102102
{ additive }
103-
{ cancelButton }
104-
{ this.props.children }
105-
<button type={this.props.primaryIsSubmit ? 'submit' : 'button'}
106-
data-test-id="dialog-primary-button"
107-
className={primaryButtonClassName}
108-
onClick={this.props.onPrimaryButtonClick}
109-
autoFocus={this.props.focus}
110-
disabled={this.props.disabled || this.props.primaryDisabled}
111-
>
112-
{ this.props.primaryButton }
113-
</button>
103+
<span className="mx_Dialog_buttons_row">
104+
{ cancelButton }
105+
{ this.props.children }
106+
<button type={this.props.primaryIsSubmit ? 'submit' : 'button'}
107+
data-test-id="dialog-primary-button"
108+
className={primaryButtonClassName}
109+
onClick={this.props.onPrimaryButtonClick}
110+
autoFocus={this.props.focus}
111+
disabled={this.props.disabled || this.props.primaryDisabled}
112+
>
113+
{ this.props.primaryButton }
114+
</button>
115+
</span>
114116
</div>
115117
);
116118
}

0 commit comments

Comments
 (0)