Skip to content

Commit fd48399

Browse files
Stack password input button on mobile
1 parent 631833d commit fd48399

2 files changed

Lines changed: 8 additions & 32 deletions

File tree

packages/nhsuk-frontend/src/nhsuk/components/password-input/_index.scss

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@
1111
////
1212

1313
@include nhsuk-exports("nhsuk/components/password-input") {
14-
.nhsuk-password-input__wrapper {
15-
// This element inherits styles from .nhsuk-input__wrapper, including:
16-
// - being display: block with contents in a stacked column below the mobile
17-
// breakpoint
18-
// - being display: flex above the mobile breakpoint
19-
20-
@include nhsuk-media-query($from: mobile) {
21-
flex-direction: row;
22-
23-
// The default of `stretch` makes the toggle button appear taller than the
24-
// input, due to using box-shadow, which we don't particularly want in
25-
// this situation
26-
align-items: flex-start;
27-
}
28-
}
29-
3014
.nhsuk-password-input__input {
3115
// IE 11 and Microsoft Edge comes with its own password reveal function. We
3216
// want to hide it, so that there aren't two controls presented to the user
@@ -36,30 +20,22 @@
3620
&::-ms-reveal {
3721
display: none;
3822
}
23+
24+
@include nhsuk-media-query($until: tablet) {
25+
// Set max-width to override potential width override class on the input
26+
max-width: 100%;
27+
}
3928
}
4029

4130
.nhsuk-password-input__toggle {
42-
// Add top margin so the button doesn't obscure the input's focus style
43-
margin-top: nhsuk-spacing(1);
44-
45-
// Remove default margin-bottom from button
46-
margin-bottom: 0;
47-
4831
// Hide the button by default, JS removes this attribute
4932
&[hidden] {
5033
display: none;
5134
}
5235

53-
@include nhsuk-media-query($from: mobile) {
36+
@include nhsuk-media-query($from: tablet) {
5437
flex-basis: 5em;
5538
flex-shrink: 0;
56-
57-
// Buttons are normally 100% wide on mobile, but we don't want that here
58-
width: auto;
59-
60-
// Move the spacing from top to the left
61-
margin-top: 0;
62-
margin-left: nhsuk-spacing(1);
6339
}
6440
}
6541
}

packages/nhsuk-frontend/src/nhsuk/components/password-input/template.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
{%- set buttonHtml %}
4848
{{ button({
4949
type: "button",
50-
classes: "nhsuk-button--secondary nhsuk-password-input__toggle nhsuk-js-password-input-toggle" + (" " + params.button.classes if params.button.classes),
50+
classes: "nhsuk-button--secondary nhsuk-button--small nhsuk-password-input__toggle nhsuk-js-password-input-toggle" + (" " + params.button.classes if params.button.classes),
5151
text: params.showPasswordText | default("Show"),
5252
attributes: {
5353
"aria-controls": id,
@@ -73,7 +73,7 @@
7373
}
7474
},
7575
inputWrapper: {
76-
"classes": "nhsuk-password-input__wrapper"
76+
classes: "nhsuk-form-group nhsuk-form-group--inline"
7777
},
7878
label: params.label,
7979
hint: params.hint,

0 commit comments

Comments
 (0)