Skip to content

Commit

Permalink
Fix layout of mutually exclusive when its wrapped in a question compo…
Browse files Browse the repository at this point in the history
…nent (#424)

* Fix layout of mutually exclusive when its wrapped in a question component

* Fix mutually exclusive field wrapping when in a question
  • Loading branch information
bameyrick authored Jun 13, 2019
1 parent c220867 commit bc242a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/components/checkboxes/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

{% call onsField({
"id": params.id,
"legend": params.legend,
"description": params.description,
"classes": params.classes,
"mutuallyExclusive": params.mutuallyExclusive,
"legendClasses": params.legendClasses
"legendClasses": params.legendClasses,
"noField": params.noField
}) %}
<div class="field__label">{{ params.checkboxesLabel }}</div>
<div class="field__items">
<span class="field__label">{{ params.checkboxesLabel }}</span>
<span class="field__items">
{% for checkbox in params.checkboxes %}
{% set labelHTML = checkbox.label.text %}
{% if params.mutuallyExclusive %}
Expand Down Expand Up @@ -54,6 +54,6 @@
<br>
{% endif %}
{% endfor %}
</div>
</span>
{% endcall %}
{% endmacro %}
7 changes: 5 additions & 2 deletions src/components/field/_field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
margin-top: -1rem;
}

&__items {
display: block;
}

&__item {
display: inline-block;
position: relative;
}

& > &,
&__items > & {
*:not(.field__group) > & {
&__item {
margin: 0 0 0.5rem;
width: 100%;
Expand Down
7 changes: 4 additions & 3 deletions src/components/field/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@
</fieldset>
{% endif %}
{% else %}
{% set tag = "div" if params.mutuallyExclusive else "p" %}
{% if not params.noField %}
<p{% if params.id %} id="{{ params.id }}"{% endif %} class="field{% if params.mutuallyExclusive %} js-mutually-exclusive{% endif %}{% if params.classes %} {{ params.classes }}{% endif %}">
<{{ tag }}{% if params.id %} id="{{ params.id }}"{% endif %} class="field{% if params.mutuallyExclusive %} js-mutually-exclusive{% endif %}{% if params.classes %} {{ params.classes }}{% endif %}">
{% endif %}
{% if params.description %}
<div class="field__description">{{ params.description }}</div>
<span class="field__description">{{ params.description }}</span>
{% endif %}
{{ caller() }}
{{ mutuallyExclusive | safe }}
{% if not params.noField %}
</p>
</{{ tag }}>
{% endif %}
{% endif %}
{% endmacro %}

0 comments on commit bc242a9

Please sign in to comment.