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

Consider inverting theme structure #825

Closed
alexkreidler opened this issue Nov 9, 2020 · 1 comment
Closed

Consider inverting theme structure #825

alexkreidler opened this issue Nov 9, 2020 · 1 comment
Assignees
Labels
Type: Question Questions and other discussions

Comments

@alexkreidler
Copy link

alexkreidler commented Nov 9, 2020

Currently, users must choose between uniforms-<style> packages.

As implemented, most of the logical components simply calls parent classes. The only differences are really in the display/field components.

If you were to move all the display components into a big map of their names, then that object could be passed into each type of Form instance. This would allow users to

  1. implement form themes with their own component libraries
  2. use a different theme for different forms a little more easily

No. 1 is the most important for me personally. I would have to copy and maintain a whole separate package with a lot of boilerplate to implement the forms I want to.

But with this change, I would implement the <Type>Field components from the autofield algorithm, pass those in an object like:

interface FormTheme = {
    RadioField: React.FC<Props>
    DateField: ....
}

then I could use autoform like

const myTheme: FormTheme = //impl
<AutoForm schema={schema} onSubmit={console.log} theme={myTheme} />

And users could simply import the appropriate already-implemented ones like

import bootstrapTheme from "uniforms-bootstrap4"
<AutoForm schema={schema} onSubmit={console.log} theme={bootstrapTheme} />

This would definitely be a breaking change and you'd have to change the default export of those different theme packages, but it might be worthwhile.

Let me know what you think!

@radekmie radekmie self-assigned this Nov 12, 2020
@radekmie radekmie added the Type: Question Questions and other discussions label Nov 12, 2020
@radekmie
Copy link
Contributor

Hi @alexkreidler. First of all, a static component map would not work, as most apps require custom field components for the same types, e.g. NestField can render an address form correctly, but a custom AddressField may have a different layout. Anyway, this and a few other arguments, as well as the approach I'm working on, are in #640.

@radekmie radekmie moved this to Closed in Open Source Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Questions and other discussions
Projects
Archived in project
Development

No branches or pull requests

2 participants