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

Minimal component render #53

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

sergei-maertens
Copy link
Member

@sergei-maertens sergei-maertens commented Dec 22, 2024

  • Set up registry
  • Set up simple textfield + fieldset recursion example
  • Add top-level FormioForm component (public API)
  • Render the form fields with Formik for state management
  • Include Open Forms theme styles (storybook)

Closes #11
Closes #12

Otherwise the types of @open-formulieren/types are
broken/unusable.
The bare minimum is rendering the formio definition in place given
its component type. This sets up the minimum stories to support
different Formio component types.
Similar to the formio-builder, we must use a registry approach so that
each component type can get proper type-checked inputs and only needs
to concern itself with its own rendering logic.

In the future, this will also hold some logic evaluation implementation
details if they turn out to be component type specific.
The component type is used as lookup key to render the component. Each
render component implementation is responsible for managing its own
presentation logic.

Unknown/not-implemented components render a fallback, similar to what
Formio.js does.
Fieldsets primary purpose is rendering the children contained inside.
Uses the underlying NL DS utrecht components, but without any styling
for now. This sets up the MVP pure-react form rendering to be used with
the Formio component definitions.
The nature of our component tree requires recursion, but importing the
generic render component in specific files causes circular import
errors that webpack can't handle.

To mitigate this, a plugin is added to detect and prevent circular
imports, and the code is restructured to pass the generic component
itself as a prop instead for rendering child components.

This may get reworked in the future, but it may also not, depending on
how (technical) requirements evolve.
@sergei-maertens sergei-maertens force-pushed the feature/minimal-component-render branch from 68d85cf to e9c768f Compare December 23, 2024 13:20
Added the library containing the SCSS for the form fields and our own
design tokens package that give 'meaning' to the SCSS to document
components in our own theme.

Currently using the same pinned versions as the open-forms-sdk does so
that we can transition easily and later upgrade the NL DS components
used once the 'hard' problems have been solved.
Similar config as formio-builder
* import the relevant styles for utrecht-form-label
* import the compiled design tokens for the OF theme
* ensure everything is wired up in storybook

This doesn't render the correct font yet because the font assets aren't
loaded/included, but the fallback is acceptable to avoid that
complexity at this point.
Text field is now styled properly, and the pattern established for
managing (composite) component styles:

* define a single SCSS file for the component
* do the library imports in that file

The added benefit of the last bullet is that you can control the order
of imports and thus the order of how CSS is output as there are some
broken style isolation issues on the label element. This keeps the
setup sufficiently close to the SDK style organisation.
This pulls in microscope-sass as a (temporary) dependency for parity
with the SDK and making it easier to apply strict BEM selectors
without having to manually implement this again. The module is provided
internally and for now forwards the library module and will at some
point be extracted into a standalone library again.

The validation error styles from the SDK are copied over.
The Form component will set up and manage the Formik state (internal
implementation detail), and make sure the form configuration gets
rendered properly.

The caller is responsibel for providing the submit button to make it
match the required layout/styling/positioning.
This is the easy bit... the hard part is setting up the initial values
correctly *and* making sure the types are sorted out correctly.
This makes it possible to add non-React component utilities to the
registry.
Formio form data is limited to JSON types, not any Javascript type. We
can use this information to narrow the types as much as possible.
Extract the default values from the component definitions or fall back
to the appropriate empty value matching the component schema type.
Taken from Open Forms SDK and slightly adapted.
@sergei-maertens sergei-maertens marked this pull request as ready for review December 24, 2024 20:28
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.

Formio renderer: implement NLDS for textfield. Formio renderer: add existing styling from SDK.
1 participant