Skip to content

Commit

Permalink
💄 [open-formulieren/open-forms#4546] Add alert styling to the soft re…
Browse files Browse the repository at this point in the history
…quired errors component

This enables it to be customized via NL DS design tokens, and provides
some escape hatches to make it different from the standard warning
alert appearance.
  • Loading branch information
sergei-maertens committed Oct 28, 2024
1 parent e729aea commit f3a8030
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/formio/components/SoftRequiredErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ class SoftRequiredErrors extends FormioContentField {
missingFields: missingFieldsMarkup,
});

return `<div id="${this.id}-content">${content}</div>`;
return `
<div id="${this.id}-content" class="utrecht-alert utrecht-alert--warning openforms-soft-required-errors">
<div class="utrecht-alert__icon">
<i class="fa fas fa-exclamation-triangle"></i>
</div>
<div class="utrecht-alert__message">
${content}
</div>
</div>
`;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/formio/templates/missingFields.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<span class="sr-only" id="{{ctx.id}}-missing-fields-header">
{{ ctx.t('Empty fields') }}
</span>
<ul class="utrecht-unordered-list" aria-labelledby="{{ctx.id}}-missing-fields-header">
<ul class="utrecht-unordered-list openforms-soft-required-errors__missing-fields" aria-labelledby="{{ctx.id}}-missing-fields-header">
{% for (const label of ctx.labels) { %}
<li class="utrecht-unordered-list__item">{{ label }}</li>
{% } %}
Expand Down
17 changes: 17 additions & 0 deletions src/scss/components/_soft-required-errors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@use 'microscope-sass/lib/bem';

@import '~microscope-sass/lib/typography';

.openforms-soft-required-errors {
// apply all wysiwyg styling
// TODO: parametrize this with design tokens -> check with NL DS how to approach this
@include wysiwyg;

// unset, takes the utrecht-alert--warning by default, but can be overridden if desired
color: var(--of-soft-required-errors-color);
background-color: var(--of-soft-required-errors-background-color);

@include bem.element('missing-fields') {
font-weight: var(--of-soft-required-errors-missing-fields-font-weight, 600);
}
}
1 change: 1 addition & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@
@import './scss/components/input-container';
@import './scss/components/authentication-errors';
@import './scss/components/govmetric_snippet';
@import './scss/components/soft-required-errors';

0 comments on commit f3a8030

Please sign in to comment.