Skip to content

Commit f168ebc

Browse files
Fix for inline button group (#509)
This has got broken somehow. Have added in a quick fix whilst awaiting this being merged and released upstream in NHS frontend.
1 parent 09eddef commit f168ebc

File tree

5 files changed

+62
-41
lines changed

5 files changed

+62
-41
lines changed

app/assets/sass/components/_button.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
// This button is slightly shorter than the usual one,
44
// so that when it sits to the right of a text input
55
// (eg a search box) it is the same height.
6+
//
7+
// Remove this when https://github.com/nhsuk/nhsuk-frontend/pull/1643 has
8+
// been merged and released.
69
.app-button--small {
710
@include nhsuk-font-size(16);
8-
padding: nhsuk-spacing(2) 12px;
11+
padding: 5px 12px;
912
}
1013

1114
.app-button--min-width {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Inline form box-flex-group:
2+
// Used to group inputs with buttons.
3+
//
4+
// Remove this when https://github.com/nhsuk/nhsuk-frontend/pull/1643 has
5+
// been merged and released.
6+
.app-form-group--inline {
7+
display: block;
8+
9+
.nhsuk-form-group {
10+
// Set max-width to override potential width override class on the input
11+
max-width: 100%;
12+
margin-bottom: nhsuk-spacing(2);
13+
}
14+
15+
@include nhsuk-media-query($until: tablet) {
16+
// Unlike GOV.UK Frontend, always stack on small screens
17+
// stylelint-disable-next-line declaration-no-important
18+
display: block !important;
19+
}
20+
21+
@include nhsuk-media-query($from: tablet) {
22+
display: flex;
23+
gap: nhsuk-spacing(2);
24+
align-items: flex-end;
25+
26+
.nhsuk-form-group {
27+
flex-grow: 1;
28+
margin-bottom: 0; // Remove margin when nested groups are inline
29+
}
30+
31+
.nhsuk-button,
32+
.nhsuk-button-group {
33+
flex-grow: 0;
34+
}
35+
36+
// Remove inline button margin but reserve space for button shadow,
37+
// making sure 44px box maintains alignment with other form controls
38+
// https://nhsuk.github.io/nhsuk-frontend/examples/form-alignment/
39+
.nhsuk-button {
40+
margin-bottom: $nhsuk-button-shadow-size + $nhsuk-border-width-form-element;
41+
}
42+
}
43+
}

app/assets/sass/components/_search.scss

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

app/assets/sass/main.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@import 'components/table';
1919
@import 'components/button';
2020
@import 'components/filters';
21-
@import 'components/search';
21+
@import 'components/form-group';
2222
@import 'components/section';
2323
@import 'components/tag';
2424
@import 'components/numbered-heading';

app/views/records/index.html

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,22 @@ <h1 class="nhsuk-heading-xl">Records</h1>
2020

2121
<form action="/records" method="get" novalidate>
2222

23-
<div class="app-search">
24-
25-
<div class="app-search--input">
26-
{{ input({
27-
type: "search",
28-
name: "nameOrNhsNumber",
29-
value: data.nameOrNhsNumber,
30-
label: {
31-
text: "Patient name or NHS number"
32-
}
33-
}) }}
34-
</div>
35-
36-
<div class="app-search--button">
37-
{{ button({
38-
classes: "nhsuk-u-margin-left-4 app-button--small",
39-
text: "Search"
40-
}) }}
41-
</div>
23+
<div class="app-form-group--inline nhsuk-u-margin-bottom-4">
24+
{{ input({
25+
type: "search",
26+
name: "nameOrNhsNumber",
27+
value: data.nameOrNhsNumber,
28+
label: {
29+
text: "Patient name or NHS number"
30+
}
31+
}) }}
32+
{{ button({
33+
classes: "nhsuk-button--secondary app-button--small",
34+
text: "Search"
35+
}) }}
4236
</div>
4337

38+
4439
{% set additionalFiltersHtml %}
4540
{% set vaccineItems = [] %}
4641
{% for vaccine in (vaccinesRecorded | sort(false, false)) %}

0 commit comments

Comments
 (0)