Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove need for custom form-control CSS #572

Merged
merged 8 commits into from
Oct 26, 2023
Merged

Conversation

sergei-maertens
Copy link
Member

@sergei-maertens sergei-maertens commented Oct 20, 2023

Closes #571

Goal: getting rid of custom CSS for the form-control wrapper, which is arguably already performed by the utrecht-form-field component.

There are some challenges, in particular because formio requires the ref="component" to be present and still applying the relevant styles & design tokens.

* Validation error styling for a utrecht-form-field and utrecht-form-fieldset
* Content component customClass styling
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (156ebad) 71.04% compared to head (678a20a) 71.38%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #572      +/-   ##
==========================================
+ Coverage   71.04%   71.38%   +0.33%     
==========================================
  Files         209      208       -1     
  Lines        4321     4316       -5     
  Branches     1173     1174       +1     
==========================================
+ Hits         3070     3081      +11     
+ Misses       1217     1201      -16     
  Partials       34       34              
Files Coverage Δ
...omponents/appointments/cancel/CancelAppointment.js 86.66% <100.00%> (+26.66%) ⬆️
src/components/appointments/fields/DateSelect.js 96.42% <ø> (ø)
src/components/appointments/fields/Product.js 100.00% <ø> (ø)
...mponents/appointments/steps/LocationAndTimeStep.js 92.00% <ø> (ø)
src/components/forms/Checkbox/Checkbox.js 85.71% <100.00%> (ø)
src/components/forms/DateField/DateField.js 93.75% <100.00%> (ø)
src/components/forms/Label.js 100.00% <100.00%> (ø)
src/components/forms/NumberField/NumberField.js 93.33% <100.00%> (ø)
src/components/forms/TextField/TextField.js 93.33% <100.00%> (ø)
src/formio/components/Component.js 77.77% <ø> (ø)
... and 4 more

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

* Added some pristine state stories & tests for hidden components
* Updated zod story to use semantically correct component in favour
  of form-control div/styles to be deleted.
The class name is now set directly on the WYSIWYG container and the
custom classes are applied as modifiers instead of standalone/
utility classes, allowing us to clean up our CSS.

Additionally, design tokens (with backwards compatible fallbacks) are
introduced for the theming of each content variant.
This wrapper was applied to the formio component node rendered by the
vanilla formio renderer, and copied over (for vertical spacing
reasons) to the React implementation of form field components.

The UtrechtFormField and UtrechtFormFieldset components already act
like a wrapper/container, and we've introduced a separate class name to manage
the vertical spacing of components. For interop with formio, we do
some CSS/SASS extension gymnastics, which we'll be able to remove
once we have our own React-based formio renderer.
@sergei-maertens sergei-maertens force-pushed the refactor/571-form-control branch from dee6ae9 to 333d0af Compare October 20, 2023 15:00
@sergei-maertens sergei-maertens marked this pull request as ready for review October 20, 2023 15:00
@sergei-maertens
Copy link
Member Author

Marked ready for review to get visual regression testing, this is by no means complete 😅

AKA "Chromatic take the wheel"

@sergei-maertens sergei-maertens force-pushed the refactor/571-form-control branch from 0750427 to 7ac058d Compare October 23, 2023 09:41
@sergei-maertens sergei-maertens force-pushed the refactor/571-form-control branch from f4da9f6 to 678a20a Compare October 23, 2023 11:57
@CharString CharString self-requested a review October 23, 2023 15:16
Copy link
Contributor

@CharString CharString left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also check the questions on Chromatic

@@ -13,7 +13,7 @@ export const LabelContent = ({id, disabled = false, isRequired = false, type, ch
htmlFor={id}
disabled={disabled}
className={classNames({
'utrecht-form-label--openforms-required': isRequired,
'utrecht-form-label--openforms-required': isRequired && requiredFieldsWithAsterisk,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expected this fix to trigger a diff in chromatic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we didn't really have any stories with validate.required or the explicit config to not use asterisks for required fields, so it makes sense there's no diff.

Or do you mean markup diffs?

@CharString CharString merged commit cda0cef into main Oct 26, 2023
12 checks passed
@CharString CharString deleted the refactor/571-form-control branch October 26, 2023 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor out openforms-form-control CSS
2 participants