katalyst-govuk-formbuilder 1.10.2 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -0
- data/app/assets/builds/katalyst/govuk/formbuilder.css +30 -30
- data/app/assets/stylesheets/katalyst/govuk/components/combobox/_index.scss +100 -0
- data/app/assets/stylesheets/katalyst/govuk/components/richtextarea/_index.scss +3 -4
- data/lib/katalyst/govuk/formbuilder/builder.rb +41 -1
- data/lib/katalyst/govuk/formbuilder/elements/combobox.rb +60 -0
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +35 -31
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss +4 -4
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss +6 -1
- data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss +16 -13
- data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss +1 -2
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_index.scss +3 -5
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +8 -9
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +8 -0
- data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +7 -4
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +3 -2
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +24 -37
- data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +13 -9
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +12 -9
- data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +0 -8
- data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +7 -5
- data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +5 -5
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +162 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss +6 -4
- data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +2 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +11 -8
- data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +12 -10
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +3 -3
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +44 -8
- data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/helpers/_shape-arrow.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +17 -0
- data/node_modules/govuk-frontend/dist/govuk/helpers/_visually-hidden.scss +30 -62
- data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +5 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +235 -9
- metadata +7 -4
- data/app/assets/stylesheets/katalyst/govuk/components/richtextarea/_richtextarea.scss +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d371dc77a725f4e009f3a0a61e75d085f3080bad8cb64857299a3a7264fb95e
|
4
|
+
data.tar.gz: 392fcc8460909ba2a4190352a15cdd536a5e5e6e3d3ce896ae874a56a5aebef6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cefbeb3e8423be0a86e33b324f59a3745aab8fd7e8a150a9e0be5dc4f874378108253db1f722c68b67defc3d96606db4dcef6576684f895445463cd905bf7f43
|
7
|
+
data.tar.gz: 8d688517167cc77a120aa50ac7d5e101524e8478c381071d603f650e303cc17ed9b0ea802cb6be15859717a2555f30589868768e55f7848df5c4072cdec87c04
|
data/README.md
CHANGED
@@ -27,6 +27,12 @@ Add the stylesheet to your default layout:
|
|
27
27
|
<%= stylesheet_link_tag "katalyst/govuk/formbuilder" %>
|
28
28
|
```
|
29
29
|
|
30
|
+
You can also add it to your SASS build:
|
31
|
+
|
32
|
+
```scss
|
33
|
+
@use "katalyst/govuk/formbuilder";
|
34
|
+
```
|
35
|
+
|
30
36
|
Some GOVUK components require javascript enhancements
|
31
37
|
(see [GOVUK docs](https://frontend.design-system.service.gov.uk/get-started/#5-get-the-javascript-working)).
|
32
38
|
|
@@ -43,6 +49,30 @@ You'll need to include the helper to make this method available, which you can a
|
|
43
49
|
helper Katalyst::GOVUK::Formbuilder::Frontend
|
44
50
|
```
|
45
51
|
|
52
|
+
## Extensions
|
53
|
+
|
54
|
+
We include some optional extensions for integrating with gems that we (Katalyst) commonly use.
|
55
|
+
|
56
|
+
These require additional steps to use.
|
57
|
+
|
58
|
+
### Hotwire Combobox
|
59
|
+
|
60
|
+
[Hotwire Combobox](https://hotwirecombobox.com) is a promising option for adding asynchronous multi-select inputs to
|
61
|
+
Rails forms. We're assuming importmaps and Turbo if this option is used.
|
62
|
+
|
63
|
+
There's no explicit dependency so if you want to use this input you'll need to add:
|
64
|
+
|
65
|
+
```
|
66
|
+
gem "hotwire_combobox"
|
67
|
+
```
|
68
|
+
|
69
|
+
JS is added by the gem automatically (via importmaps), but you'll need to explicitly add CSS:
|
70
|
+
|
71
|
+
```scss
|
72
|
+
@use "katalyst/govuk/formbuilder";
|
73
|
+
@use "katalyst/govuk/components/combobox";
|
74
|
+
```
|
75
|
+
|
46
76
|
## Contributing
|
47
77
|
|
48
78
|
Bug reports and pull requests are welcome on GitHub at https://github.com/katalyst/govuk-formbuilder.
|
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
|
45
45
|
:root {
|
46
|
-
--govuk-frontend-version: "5.
|
46
|
+
--govuk-frontend-version: "5.6.0";
|
47
47
|
--govuk-frontend-breakpoint-mobile: 20rem;
|
48
48
|
--govuk-frontend-breakpoint-tablet: 40.0625rem;
|
49
49
|
--govuk-frontend-breakpoint-desktop: 48.0625rem;
|
@@ -1365,7 +1365,7 @@
|
|
1365
1365
|
border-radius: 0;
|
1366
1366
|
color: #ffffff;
|
1367
1367
|
background-color: #00703c;
|
1368
|
-
box-shadow: 0 2px 0
|
1368
|
+
box-shadow: 0 2px 0 rgb(0, 44.8, 24);
|
1369
1369
|
text-align: center;
|
1370
1370
|
vertical-align: top;
|
1371
1371
|
cursor: pointer;
|
@@ -1407,7 +1407,7 @@
|
|
1407
1407
|
border: 0;
|
1408
1408
|
}
|
1409
1409
|
.govuk-button:hover {
|
1410
|
-
background-color:
|
1410
|
+
background-color: rgb(0, 89.6, 48);
|
1411
1411
|
}
|
1412
1412
|
.govuk-button:active {
|
1413
1413
|
top: 2px;
|
@@ -1446,18 +1446,18 @@
|
|
1446
1446
|
}
|
1447
1447
|
.govuk-button[disabled]:active {
|
1448
1448
|
top: 0;
|
1449
|
-
box-shadow: 0 2px 0
|
1449
|
+
box-shadow: 0 2px 0 rgb(0, 44.8, 24);
|
1450
1450
|
}
|
1451
1451
|
|
1452
1452
|
.govuk-button--secondary {
|
1453
1453
|
background-color: #f3f2f1;
|
1454
|
-
box-shadow: 0 2px 0
|
1454
|
+
box-shadow: 0 2px 0 rgb(145.8, 145.2, 144.6);
|
1455
1455
|
}
|
1456
1456
|
.govuk-button--secondary, .govuk-button--secondary:link, .govuk-button--secondary:visited, .govuk-button--secondary:active, .govuk-button--secondary:hover {
|
1457
1457
|
color: #0b0c0c;
|
1458
1458
|
}
|
1459
1459
|
.govuk-button--secondary:hover {
|
1460
|
-
background-color:
|
1460
|
+
background-color: rgb(218.7, 217.8, 216.9);
|
1461
1461
|
}
|
1462
1462
|
.govuk-button--secondary:hover[disabled] {
|
1463
1463
|
background-color: #f3f2f1;
|
@@ -1465,13 +1465,13 @@
|
|
1465
1465
|
|
1466
1466
|
.govuk-button--warning {
|
1467
1467
|
background-color: #d4351c;
|
1468
|
-
box-shadow: 0 2px 0
|
1468
|
+
box-shadow: 0 2px 0 rgb(84.8, 21.2, 11.2);
|
1469
1469
|
}
|
1470
1470
|
.govuk-button--warning, .govuk-button--warning:link, .govuk-button--warning:visited, .govuk-button--warning:active, .govuk-button--warning:hover {
|
1471
1471
|
color: #ffffff;
|
1472
1472
|
}
|
1473
1473
|
.govuk-button--warning:hover {
|
1474
|
-
background-color:
|
1474
|
+
background-color: rgb(169.6, 42.4, 22.4);
|
1475
1475
|
}
|
1476
1476
|
.govuk-button--warning:hover[disabled] {
|
1477
1477
|
background-color: #d4351c;
|
@@ -1479,13 +1479,13 @@
|
|
1479
1479
|
|
1480
1480
|
.govuk-button--inverse {
|
1481
1481
|
background-color: #ffffff;
|
1482
|
-
box-shadow: 0 2px 0
|
1482
|
+
box-shadow: 0 2px 0 rgb(20.3, 78.4, 128.8);
|
1483
1483
|
}
|
1484
1484
|
.govuk-button--inverse, .govuk-button--inverse:link, .govuk-button--inverse:visited, .govuk-button--inverse:active, .govuk-button--inverse:hover {
|
1485
1485
|
color: #1d70b8;
|
1486
1486
|
}
|
1487
1487
|
.govuk-button--inverse:hover {
|
1488
|
-
background-color:
|
1488
|
+
background-color: rgb(232.4, 240.7, 247.9);
|
1489
1489
|
}
|
1490
1490
|
.govuk-button--inverse:hover[disabled] {
|
1491
1491
|
background-color: #ffffff;
|
@@ -1958,8 +1958,8 @@
|
|
1958
1958
|
|
1959
1959
|
.govuk-checkboxes__conditional {
|
1960
1960
|
margin-bottom: 15px;
|
1961
|
-
margin-left:
|
1962
|
-
padding-left:
|
1961
|
+
margin-left: 20px;
|
1962
|
+
padding-left: 35px;
|
1963
1963
|
border-left: 4px solid #b1b4b6;
|
1964
1964
|
}
|
1965
1965
|
@media (min-width: 40.0625em) {
|
@@ -2003,6 +2003,10 @@
|
|
2003
2003
|
margin-left: 10px;
|
2004
2004
|
padding-left: 20px;
|
2005
2005
|
}
|
2006
|
+
.govuk-checkboxes--small .govuk-checkboxes__divider {
|
2007
|
+
width: 24px;
|
2008
|
+
margin-bottom: 5px;
|
2009
|
+
}
|
2006
2010
|
.govuk-checkboxes--small .govuk-checkboxes__item:hover .govuk-checkboxes__input:not(:disabled) + .govuk-checkboxes__label::before {
|
2007
2011
|
outline: 3px dashed transparent;
|
2008
2012
|
outline-offset: 1px;
|
@@ -2330,6 +2334,9 @@
|
|
2330
2334
|
margin-top: 20px;
|
2331
2335
|
}
|
2332
2336
|
}
|
2337
|
+
.govuk-error-summary__body > :last-child {
|
2338
|
+
margin-bottom: 5px;
|
2339
|
+
}
|
2333
2340
|
|
2334
2341
|
.govuk-error-summary__list {
|
2335
2342
|
margin-bottom: 0;
|
@@ -2373,7 +2380,7 @@
|
|
2373
2380
|
color: #d4351c;
|
2374
2381
|
}
|
2375
2382
|
.govuk-error-summary__list a:hover {
|
2376
|
-
color:
|
2383
|
+
color: rgb(148.4, 37.1, 19.6);
|
2377
2384
|
}
|
2378
2385
|
.govuk-error-summary__list a:active {
|
2379
2386
|
color: #d4351c;
|
@@ -2592,8 +2599,8 @@
|
|
2592
2599
|
|
2593
2600
|
.govuk-radios__conditional {
|
2594
2601
|
margin-bottom: 15px;
|
2595
|
-
margin-left:
|
2596
|
-
padding-left:
|
2602
|
+
margin-left: 20px;
|
2603
|
+
padding-left: 35px;
|
2597
2604
|
border-left: 4px solid #b1b4b6;
|
2598
2605
|
}
|
2599
2606
|
@media (min-width: 40.0625em) {
|
@@ -2817,34 +2824,22 @@
|
|
2817
2824
|
content: " ";
|
2818
2825
|
}
|
2819
2826
|
|
2820
|
-
.govuk-visually-hidden-focusable {
|
2827
|
+
.govuk-visually-hidden-focusable:not(:active):not(:focus) {
|
2821
2828
|
position: absolute !important;
|
2822
2829
|
width: 1px !important;
|
2823
2830
|
height: 1px !important;
|
2824
2831
|
margin: 0 !important;
|
2832
|
+
padding: 0 !important;
|
2825
2833
|
overflow: hidden !important;
|
2826
2834
|
clip: rect(0 0 0 0) !important;
|
2827
2835
|
-webkit-clip-path: inset(50%) !important;
|
2828
2836
|
clip-path: inset(50%) !important;
|
2837
|
+
border: 0 !important;
|
2829
2838
|
white-space: nowrap !important;
|
2830
2839
|
-webkit-user-select: none;
|
2831
2840
|
-ms-user-select: none;
|
2832
2841
|
user-select: none;
|
2833
2842
|
}
|
2834
|
-
.govuk-visually-hidden-focusable:active, .govuk-visually-hidden-focusable:focus {
|
2835
|
-
position: static !important;
|
2836
|
-
width: auto !important;
|
2837
|
-
height: auto !important;
|
2838
|
-
margin: inherit !important;
|
2839
|
-
overflow: visible !important;
|
2840
|
-
clip: auto !important;
|
2841
|
-
-webkit-clip-path: none !important;
|
2842
|
-
clip-path: none !important;
|
2843
|
-
white-space: inherit !important;
|
2844
|
-
-webkit-user-select: text;
|
2845
|
-
-ms-user-select: text;
|
2846
|
-
user-select: text;
|
2847
|
-
}
|
2848
2843
|
|
2849
2844
|
|
2850
2845
|
|
@@ -4132,6 +4127,11 @@
|
|
4132
4127
|
font-variant-numeric: tabular-nums !important;
|
4133
4128
|
}
|
4134
4129
|
|
4130
|
+
.govuk-\!-text-break-word {
|
4131
|
+
word-wrap: break-word !important;
|
4132
|
+
overflow-wrap: break-word !important;
|
4133
|
+
}
|
4134
|
+
|
4135
4135
|
|
4136
4136
|
.govuk-\!-width-full {
|
4137
4137
|
width: 100% !important;
|
@@ -0,0 +1,100 @@
|
|
1
|
+
// assumes that hotwire_combobox is in the load paths, implies dartsass-rails is the compiler
|
2
|
+
@use "hotwire_combobox";
|
3
|
+
|
4
|
+
@import "govuk-frontend/dist/govuk/base";
|
5
|
+
@import "govuk-frontend/dist/govuk/components/error-message/index";
|
6
|
+
@import "govuk-frontend/dist/govuk/components/hint/index";
|
7
|
+
@import "govuk-frontend/dist/govuk/components/label/index";
|
8
|
+
|
9
|
+
// Based on components/select
|
10
|
+
@include govuk-exports("govuk/component/combobox") {
|
11
|
+
.hw-combobox:has(.govuk-combobox) {
|
12
|
+
--hw-border-radius: 0;
|
13
|
+
--hw-border-width--slim: #{$govuk-border-width-form-element};
|
14
|
+
--hw-border-color: #{$govuk-input-border-colour};
|
15
|
+
--hw-focus-color: #{$govuk-focus-colour};
|
16
|
+
--hw-combobox-width: 100%;
|
17
|
+
--hw-combobox-width--multiple: 100%;
|
18
|
+
--hw-active-bg-color: #{govuk-colour("blue")};
|
19
|
+
--hw-padding--slim: #{govuk-spacing(1)};
|
20
|
+
--hw-padding--slimmer: #{govuk-spacing(1)};
|
21
|
+
--hw-padding--thick: #{govuk-spacing(1)};
|
22
|
+
--hw-font-size: 1rem;
|
23
|
+
--hw-line-height: 1.25;
|
24
|
+
|
25
|
+
display: flex;
|
26
|
+
|
27
|
+
.hw-combobox__main__wrapper {
|
28
|
+
// This min-width was chosen because:
|
29
|
+
// - it makes the Select wider than it is tall (which is what users expect)
|
30
|
+
// - 11.5em matches the 'length-10' variant of the input component
|
31
|
+
// - it fits comfortably on screens as narrow as 240px wide
|
32
|
+
min-width: 11.5em;
|
33
|
+
max-width: var(--text-width, 100%);
|
34
|
+
|
35
|
+
display: flex;
|
36
|
+
min-height: 2.5rem;
|
37
|
+
align-items: center;
|
38
|
+
|
39
|
+
// Default user agent colours for selects can have low contrast,
|
40
|
+
// and may look disabled (#2435)
|
41
|
+
color: $govuk-text-colour;
|
42
|
+
background-color: govuk-colour("white");
|
43
|
+
}
|
44
|
+
|
45
|
+
.hw-combobox__main__wrapper:focus-within {
|
46
|
+
outline: $govuk-focus-width solid $govuk-focus-colour;
|
47
|
+
// Ensure outline appears outside of the element
|
48
|
+
outline-offset: 0;
|
49
|
+
// Double the border by adding its width again. Use `box-shadow` to do
|
50
|
+
// this instead of changing `border-width` (which changes element size)
|
51
|
+
// and since `outline` is already used for the yellow focus state.
|
52
|
+
box-shadow: inset 0 0 0 $govuk-border-width-form-element;
|
53
|
+
}
|
54
|
+
|
55
|
+
.govuk-combobox {
|
56
|
+
@include govuk-font($size: 16, $line-height: 1.25);
|
57
|
+
|
58
|
+
// override input styles from form/govuk
|
59
|
+
border: none;
|
60
|
+
outline: none;
|
61
|
+
box-shadow: none;
|
62
|
+
width: 100%;
|
63
|
+
padding: 0;
|
64
|
+
height: unset;
|
65
|
+
}
|
66
|
+
|
67
|
+
// disabled
|
68
|
+
&:has(.govuk-combobox:disabled) {
|
69
|
+
opacity: 0.5;
|
70
|
+
color: inherit;
|
71
|
+
cursor: not-allowed;
|
72
|
+
}
|
73
|
+
|
74
|
+
// extend existing hover/active styles (--hw-active-bg-color)
|
75
|
+
.hw-combobox__option:hover,
|
76
|
+
.hw-combobox__option--navigated,
|
77
|
+
.hw-combobox__option--selected {
|
78
|
+
color: govuk-colour("white");
|
79
|
+
}
|
80
|
+
|
81
|
+
.hw-combobox__dialog__input {
|
82
|
+
width: 100%;
|
83
|
+
}
|
84
|
+
|
85
|
+
.hw-combobox__listbox {
|
86
|
+
left: -$govuk-border-width-form-element;
|
87
|
+
right: -$govuk-border-width-form-element;
|
88
|
+
top: calc(100% + $govuk-border-width-form-element * 2 + 0.2rem);
|
89
|
+
width: unset;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
.govuk-combobox--error {
|
94
|
+
border-color: $govuk-error-colour;
|
95
|
+
|
96
|
+
.hw-combobox__main__wrapper:focus-within {
|
97
|
+
border-color: $govuk-input-border-colour;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
@@ -2,12 +2,11 @@
|
|
2
2
|
@import "govuk-frontend/dist/govuk/components/hint/index";
|
3
3
|
@import "govuk-frontend/dist/govuk/components/label/index";
|
4
4
|
|
5
|
-
// Based on components/textarea
|
6
5
|
@include govuk-exports("govuk/component/richtextarea") {
|
7
6
|
.govuk-richtextarea {
|
8
7
|
@include govuk-font($size: 19, $line-height: 1.25);
|
9
8
|
|
10
|
-
box-sizing: border-box;
|
9
|
+
box-sizing: border-box;
|
11
10
|
display: block;
|
12
11
|
width: 100%;
|
13
12
|
// min-height inherited from trix-editor styles
|
@@ -26,8 +25,8 @@
|
|
26
25
|
// Ensure outline appears outside of the element
|
27
26
|
outline-offset: 0;
|
28
27
|
// Double the border by adding its width again. Use `box-shadow` to do
|
29
|
-
// this instead of changing `border-width` (which changes element size)
|
30
|
-
// since `outline` is already used for the yellow focus state.
|
28
|
+
// this instead of changing `border-width` (which changes element size)
|
29
|
+
// and since `outline` is already used for the yellow focus state.
|
31
30
|
box-shadow: inset 0 0 0 $govuk-border-width-form-element;
|
32
31
|
}
|
33
32
|
|
@@ -157,7 +157,7 @@ module Katalyst
|
|
157
157
|
# @param form_group [Hash] configures the form group
|
158
158
|
# @option form_group classes [Array,String] sets the form group's classes
|
159
159
|
# @option form_group kwargs [Hash] additional attributes added to the form group
|
160
|
-
# @param
|
160
|
+
# @param & [Block] arbitrary HTML that will be rendered between the hint and the input
|
161
161
|
# @return [ActiveSupport::SafeBuffer] HTML output
|
162
162
|
#
|
163
163
|
# @example A rich text area with injected content
|
@@ -186,6 +186,46 @@ module Katalyst
|
|
186
186
|
).html
|
187
187
|
end
|
188
188
|
|
189
|
+
# Generates a +combobox+ element that uses Hotwire Combobox to generate a combobox selection element.
|
190
|
+
# @see https://hotwirecombobox.com
|
191
|
+
# @see https://github.com/josefarias/hotwire_combobox
|
192
|
+
#
|
193
|
+
# @param attribute_name [Symbol] The name of the attribute
|
194
|
+
# @param options_or_src [Array] The +option+ values or a source path for async combobox
|
195
|
+
# @param options [Hash] Options hash passed through to the +combobox+ helper
|
196
|
+
# @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+.
|
197
|
+
# When a +Proc+ is supplied the hint will be wrapped in a +div+ instead of a +span+
|
198
|
+
# @option hint text [String] the hint text
|
199
|
+
# @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
|
200
|
+
# @param label [Hash,Proc] configures or sets the associated label content
|
201
|
+
# @option label text [String] the label text
|
202
|
+
# @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
|
203
|
+
# @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
|
204
|
+
# @option label hidden [Boolean] control the visibility of the label.
|
205
|
+
# Hidden labels will still be read by screenreaders
|
206
|
+
# @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
|
207
|
+
# @param form_group [Hash] configures the form group
|
208
|
+
# @option form_group kwargs [Hash] additional attributes added to the form group
|
209
|
+
# @return [ActiveSupport::SafeBuffer] HTML output
|
210
|
+
#
|
211
|
+
# @example A combobox that allows the user to choose from a list of states
|
212
|
+
#
|
213
|
+
# = f.combobox "state", State.all
|
214
|
+
#
|
215
|
+
# @example A combobox that allows the user to choose from an asynchronous states endpoint
|
216
|
+
#
|
217
|
+
# = f.combobox "state", states_path
|
218
|
+
#
|
219
|
+
# @example A multi-select combobox that allows the user to choose multiple states
|
220
|
+
#
|
221
|
+
# = f.combobox "state", State.all, multiselect_chip_src: states_chips_path
|
222
|
+
#
|
223
|
+
def govuk_combobox(attribute_name, options_or_src = [], options: {}, label: {}, hint: {}, form_group: {},
|
224
|
+
caption: {}, **, &)
|
225
|
+
Elements::Combobox.new(self, object_name, attribute_name, options_or_src,
|
226
|
+
options:, label:, hint:, form_group:, caption:, **, &).html
|
227
|
+
end
|
228
|
+
|
189
229
|
# Keep track of whether we are inside a fieldset
|
190
230
|
# This allows labels to default to bold ("s") normally but use the default otherwise
|
191
231
|
def fieldset_context
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "govuk_design_system_formbuilder"
|
4
|
+
|
5
|
+
module Katalyst
|
6
|
+
module GOVUK
|
7
|
+
module Formbuilder
|
8
|
+
module Elements
|
9
|
+
class Combobox < GOVUKDesignSystemFormBuilder::Base
|
10
|
+
include GOVUKDesignSystemFormBuilder::Traits::Error
|
11
|
+
include GOVUKDesignSystemFormBuilder::Traits::Label
|
12
|
+
include GOVUKDesignSystemFormBuilder::Traits::Hint
|
13
|
+
include GOVUKDesignSystemFormBuilder::Traits::HTMLAttributes
|
14
|
+
|
15
|
+
def initialize(builder, object_name, attribute_name, options_or_src, options:, form_group:, label:, hint:,
|
16
|
+
caption:, **kwargs, &block)
|
17
|
+
super(builder, object_name, attribute_name)
|
18
|
+
@block = block
|
19
|
+
|
20
|
+
@form_group = form_group
|
21
|
+
@hint = hint
|
22
|
+
@label = label
|
23
|
+
@caption = caption
|
24
|
+
@options_or_src = options_or_src
|
25
|
+
@options = options
|
26
|
+
@html_attributes = kwargs
|
27
|
+
end
|
28
|
+
|
29
|
+
def html
|
30
|
+
GOVUKDesignSystemFormBuilder::Containers::FormGroup.new(*bound, **@form_group).html do
|
31
|
+
safe_join([label_element, hint_element, error_element, combobox])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def combobox
|
38
|
+
@builder.combobox(@attribute_name, @options_or_src, **@options, **attributes(@html_attributes), &@block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def options
|
42
|
+
{
|
43
|
+
id: field_id(link_errors: true),
|
44
|
+
class: classes,
|
45
|
+
aria: { describedby: combine_references(hint_id, error_id) },
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def classes
|
50
|
+
combine_references(%(#{brand}-combobox), error_class)
|
51
|
+
end
|
52
|
+
|
53
|
+
def error_class
|
54
|
+
%(#{brand}-combobox--error) if has_errors?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -102,9 +102,9 @@
|
|
102
102
|
&:hover {
|
103
103
|
color: $govuk-accordion-base-colour;
|
104
104
|
background: $govuk-accordion-hover-colour;
|
105
|
-
// The
|
106
|
-
// button. We add a grey box-shadow on hover too, to make the height of
|
107
|
-
// match the height of the focus state.
|
105
|
+
// The focus state adds a box-shadow to the top and bottom of the
|
106
|
+
// button. We add a grey box-shadow on hover too, to make the height of
|
107
|
+
// the hover state match the height of the focus state.
|
108
108
|
box-shadow:
|
109
109
|
0 -2px $govuk-accordion-hover-colour,
|
110
110
|
0 4px $govuk-accordion-hover-colour;
|
@@ -147,7 +147,7 @@
|
|
147
147
|
|
148
148
|
position: relative;
|
149
149
|
|
150
|
-
// Set size using rems
|
150
|
+
// Set size using rems so icon scales with text
|
151
151
|
width: govuk-px-to-rem(20px);
|
152
152
|
height: govuk-px-to-rem(20px);
|
153
153
|
|
@@ -184,14 +184,15 @@
|
|
184
184
|
.govuk-accordion__section-button {
|
185
185
|
width: 100%;
|
186
186
|
|
187
|
-
padding: govuk-spacing(2) 0 0
|
187
|
+
padding: govuk-spacing(2) 0 0;
|
188
188
|
|
189
189
|
border: 0;
|
190
190
|
|
191
191
|
border-top: $govuk-accordion-bottom-border-width solid $govuk-border-colour;
|
192
192
|
|
193
|
-
// Visually separate the section from the one underneath when user changes
|
194
|
-
// browser. See
|
193
|
+
// Visually separate the section from the one underneath when user changes
|
194
|
+
// colours in their browser. See
|
195
|
+
// https://github.com/alphagov/govuk-frontend/issues/2321#issuecomment-924201488
|
195
196
|
border-bottom: govuk-spacing(2) solid transparent;
|
196
197
|
|
197
198
|
color: $govuk-text-colour;
|
@@ -230,8 +231,8 @@
|
|
230
231
|
}
|
231
232
|
|
232
233
|
&:focus {
|
233
|
-
// Remove default focus border around button as
|
234
|
-
//
|
234
|
+
// Remove default focus border around button as styling is being applied
|
235
|
+
// to inner text elements that receive focus
|
235
236
|
outline: 0;
|
236
237
|
|
237
238
|
.govuk-accordion__section-heading-text-focus,
|
@@ -257,9 +258,10 @@
|
|
257
258
|
}
|
258
259
|
}
|
259
260
|
|
260
|
-
// Remove the transparent border when the section is expanded to make it
|
261
|
-
// relates to the content below. Adjust padding to
|
262
|
-
//
|
261
|
+
// Remove the transparent border when the section is expanded to make it
|
262
|
+
// clear that the heading relates to the content below. Adjust padding to
|
263
|
+
// maintain the height of the element. See
|
264
|
+
// https://github.com/alphagov/govuk-frontend/pull/2257#issuecomment-951920798
|
263
265
|
.govuk-accordion__section--expanded .govuk-accordion__section-button {
|
264
266
|
padding-bottom: govuk-spacing(3);
|
265
267
|
border-bottom: 0;
|
@@ -269,8 +271,8 @@
|
|
269
271
|
}
|
270
272
|
}
|
271
273
|
|
272
|
-
// As Chevron icon is vertically aligned it overlaps with the focus state
|
273
|
-
//
|
274
|
+
// As Chevron icon is vertically aligned it overlaps with the focus state
|
275
|
+
// bottom border – this adds some spacing
|
274
276
|
.govuk-accordion__section-button:focus .govuk-accordion__section-toggle-focus {
|
275
277
|
padding-bottom: 3px;
|
276
278
|
|
@@ -299,9 +301,9 @@
|
|
299
301
|
color: $govuk-link-colour;
|
300
302
|
}
|
301
303
|
|
302
|
-
// Add space between the icon and text.
|
303
|
-
//
|
304
|
-
//
|
304
|
+
// Add space between the icon and text. Avoid applying spacing directly to
|
305
|
+
// the icon as the use of `transform` will change the placement of any
|
306
|
+
// margins.
|
305
307
|
.govuk-accordion__show-all-text,
|
306
308
|
.govuk-accordion__section-toggle-text {
|
307
309
|
margin-left: govuk-spacing(1);
|
@@ -310,23 +312,25 @@
|
|
310
312
|
|
311
313
|
// Background colour adjustment when user changes colours in Firefox
|
312
314
|
//
|
313
|
-
// When user changes colours in Firefox, text colour inside <button> is
|
314
|
-
// (regardless of the custom colours the user has set). This is
|
315
|
-
// button is not nested inside another element
|
316
|
-
//
|
317
|
-
// custom
|
315
|
+
// When user changes colours in Firefox, text colour inside <button> is
|
316
|
+
// always black (regardless of the custom colours the user has set). This is
|
317
|
+
// fine when the text in the button is not nested inside another element
|
318
|
+
// because when user changes colours in Firefox, the immediate background
|
319
|
+
// colour of buttons is always white (again, regardless of user's custom
|
320
|
+
// colours).
|
318
321
|
//
|
319
|
-
// However, when the text inside <button> is wrapped inside another element
|
320
|
-
// sets a background colour, the text colour is still black
|
321
|
-
//
|
322
|
-
//
|
323
|
-
//
|
322
|
+
// However, when the text inside <button> is wrapped inside another element
|
323
|
+
// AND that element sets a background colour, the text colour is still black
|
324
|
+
// but the background of that nested element gets the user's custom
|
325
|
+
// background colour. When the custom background is a lighter hue, the
|
326
|
+
// contrast might be sufficient. But if the user's custom background colour
|
327
|
+
// is a darker colour, the contrast with the text might not be sufficient.
|
324
328
|
//
|
325
|
-
// To ensure sufficient contrast, override the background colour set by the
|
326
|
-
// nested elements to be transparent.
|
329
|
+
// To ensure sufficient contrast, override the background colour set by the
|
330
|
+
// focus state on the nested elements to be transparent.
|
327
331
|
//
|
328
|
-
// Also override the background colour of the Show/Hide chevrons which set a
|
329
|
-
// on hover.
|
332
|
+
// Also override the background colour of the Show/Hide chevrons which set a
|
333
|
+
// background colour on hover.
|
330
334
|
@media screen and (forced-colors: active) {
|
331
335
|
.govuk-accordion__show-all:hover,
|
332
336
|
.govuk-accordion__section-button:hover {
|
@@ -19,10 +19,10 @@
|
|
19
19
|
margin-bottom: 0;
|
20
20
|
|
21
21
|
&::after {
|
22
|
-
// Zero-width space that will reserve vertical space when no hint is
|
23
|
-
// as:
|
24
|
-
// - setting a min-height is not possible without a magic number
|
25
|
-
//
|
22
|
+
// Zero-width space that will reserve vertical space when no hint is
|
23
|
+
// provided as:
|
24
|
+
// - setting a min-height is not possible without a magic number because
|
25
|
+
// the line-height is set by the `govuk-font` call above
|
26
26
|
// - using `:empty` is not possible as the hint macro outputs line breaks
|
27
27
|
content: "\200B";
|
28
28
|
}
|
@@ -159,7 +159,7 @@
|
|
159
159
|
// to be an even number in order to be centred under the 40px checkbox or radio.
|
160
160
|
$conditional-border-width: $govuk-border-width-narrow;
|
161
161
|
// Calculate the amount of padding needed to keep the border centered against the checkbox.
|
162
|
-
$conditional-border-padding: ($govuk-
|
162
|
+
$conditional-border-padding: ($govuk-touch-target-size / 2) - ($conditional-border-width / 2);
|
163
163
|
// Move the border centered with the checkbox
|
164
164
|
$conditional-margin-left: $conditional-border-padding;
|
165
165
|
// Move the contents of the conditional inline with the label
|
@@ -255,6 +255,11 @@
|
|
255
255
|
padding-left: ($govuk-touch-target-size - $input-offset) - ($margin-left + $conditional-border-width);
|
256
256
|
}
|
257
257
|
|
258
|
+
.govuk-checkboxes__divider {
|
259
|
+
width: $govuk-small-checkboxes-size;
|
260
|
+
margin-bottom: govuk-spacing(1);
|
261
|
+
}
|
262
|
+
|
258
263
|
// Hover state for small checkboxes.
|
259
264
|
//
|
260
265
|
// We use a hover state for small checkboxes because the touch target size
|