Skip to content

Commit

Permalink
Merge pull request #664 from open-formulieren/feature/483-description…
Browse files Browse the repository at this point in the history
…-per-option

✨ [#483] add description to selectboxes and radio option
  • Loading branch information
nikkiysendoorn1 authored Mar 19, 2024
2 parents c73fa85 + bd3d49b commit c771da7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/formio/components/Checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
}
}

.utrecht-form-field__label {
.utrecht-form-field__label,
.utrecht-form-description--openforms {
background-color: var(--_of-utrecht-form-field-checkbox-background-color);
--_of-checkbox-label-shift: calc(
var(--of-utrecht-form-label-checkbox-padding-block-start) + var(--utrecht-checkbox-size)
Expand All @@ -48,6 +49,14 @@
--of-utrecht-form-field-checkbox-label-margin-block-end
);
}

.utrecht-form-description--openforms {
padding-inline-start: calc(
var(--_of-checkbox-label-shift) +
var(--of-utrecht-form-label-checkbox-padding-inline-start)
);
padding-block-end: var(--of-utrecht-form-label-radio-padding-block-end);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/formio/components/Radio.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default {
label:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
value: 'radioC',
description: 'Description optie C',
},
],
},
Expand Down
1 change: 1 addition & 0 deletions src/formio/components/Selectboxes.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default {
{
label: 'Optie B',
value: 'selectB',
description: 'Description optie B',
},
{
label:
Expand Down
9 changes: 9 additions & 0 deletions src/formio/templates/radio.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
{% if (ctx.value && (ctx.value === item.value || (typeof ctx.value === 'object' && ctx.value.hasOwnProperty(item.value) && ctx.value[item.value]))) { %}
checked=true
{% } %}

{% if (item.description) { %}
aria-describedby="{{ctx.id}}{{ctx.row}}-{{item.value}}-description"
{% } %}
>
{% if (item.description) { %}
<div class="utrecht-description utrecht-form-description--openforms" id="{{ctx.id}}{{ctx.row}}-{{item.value}}-description">
{{ item.description }}
</div>
{% } %}
</div>
{% }) %}
5 changes: 5 additions & 0 deletions src/scss/components/_radio-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
);
}

.utrecht-form-description--openforms {
padding-inline-start: var(--of-utrecht-form-label-radio-padding-inline-start);
padding-block-end: var(--of-utrecht-form-label-radio-padding-block-end);
}

&:focus-within {
outline: var(--of-utrecht-form-label-radio-focus-within-outline);
}
Expand Down

0 comments on commit c771da7

Please sign in to comment.