Skip to content

Commit 2c56115

Browse files
committed
Dense select wrappers apply dense styling to their child form elements
1 parent 7b5ebb4 commit 2c56115

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

scss/_base_forms.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
color: $colors--theme--text-muted;
6363
}
6464

65-
&.is-dense {
65+
&.is-dense,
66+
.p-form-validation__select-wrapper.is-dense & {
6667
margin: 0 0 $spv-nudge-compensation 0;
6768
padding-bottom: calc($spv-nudge - $spv--x-small - $input-border-thickness);
6869
padding-top: calc($spv-nudge - $spv--x-small - $input-border-thickness);

templates/docs/base/forms.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ Descriptive text relating to the element's validation status should use the clas
189189
View example of form validation patterns
190190
</a></div>
191191

192+
### Dense form validation select wrapper
193+
194+
To create a [dense input](#dense-form-elements) inside a `p-form-validation__select-wrapper`, add the `.is-dense` class to the select wrapper, not the input.
195+
196+
<div class="embedded-example"><a href="/docs/examples/patterns/forms/form-validation-select-wrapper-dense" class="js-example">
197+
View example of form validation patterns
198+
</a></div>
199+
192200
## Required
193201

194202
Apply the class `.is-required` to mandatory input fields. You should also add a legend to the form to be explicit about the meaning of the asterisk.

templates/docs/examples/patterns/forms/combined.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<section>{% include 'docs/examples/patterns/forms/form-stacked.html' %}</section>
1919
<section>{% include 'docs/examples/patterns/forms/form-validation.html' %}</section>
2020
<section>{% include 'docs/examples/patterns/forms/form-validation-dense.html' %}</section>
21+
<section>{% include 'docs/examples/patterns/forms/form-validation-select-wrapper-dense.html' %}</section>
2122
<section>{% include 'docs/examples/patterns/forms/forms-required.html' %}</section>
2223
<section>{% include 'docs/examples/patterns/forms/password-toggle.html' %}</section>
2324
<section>{% include 'docs/examples/patterns/forms/radio.html' %}</section>

templates/docs/examples/patterns/forms/form-validation-dense.html

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,6 @@
2929
<p class="p-form-validation__message" id="exampleInputSuccessMessage">Verified.</p>
3030
</div>
3131

32-
<div class="p-form-validation is-error">
33-
<label for="exampleSelectInputError">Ubuntu releases</label>
34-
<div class="p-form-validation__select-wrapper is-dense">
35-
<select class="p-form-validation__input is-dense" id="exampleSelectInputError" name="exampleSelectInputError"
36-
aria-invalid="true" aria-describedby="exampleSelectErrorMessage">
37-
<option value="">--Select an option--</option>
38-
<option value="1">Cosmic Cuttlefish</option>
39-
<option value="2">Bionic Beaver</option>
40-
<option value="3">Xenial Xerus</option>
41-
</select>
42-
</div>
43-
<p class="p-form-validation__message" id="exampleSelectErrorMessage">You need to select an OS to complete your
44-
install.</p>
45-
</div>
32+
{% include "docs/examples/patterns/forms/form-validation-select-wrapper-dense.html" %}
4633
</form>
4734
{% endblock %}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% extends "_layouts/examples.html" %}
2+
{% block title %}Forms / Validation / Dense select wrapper{% endblock %}
3+
4+
{% block standalone_css %}patterns_forms{% endblock %}
5+
6+
{% block content %}
7+
<div class="p-form-validation is-error">
8+
<label for="exampleSelectInputError">Ubuntu releases</label>
9+
<div class="p-form-validation__select-wrapper is-dense">
10+
<select class="p-form-validation__input" id="exampleSelectInputError" name="exampleSelectInputError"
11+
aria-invalid="true" aria-describedby="exampleSelectErrorMessage">
12+
<option value="">--Select an option--</option>
13+
<option value="1">Cosmic Cuttlefish</option>
14+
<option value="2">Bionic Beaver</option>
15+
<option value="3">Xenial Xerus</option>
16+
</select>
17+
</div>
18+
<p class="p-form-validation__message" id="exampleSelectErrorMessage">You need to select an OS to complete your
19+
install.</p>
20+
</div>
21+
{% endblock %}

0 commit comments

Comments
 (0)