-
Notifications
You must be signed in to change notification settings - Fork 93
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
Field decorators #36
Comments
This is a good idea. However, I think we should postpone this to post the MVP launch.
The above being said, I think the problem of wanting to change something very slightly resulting in having to build the whole theme yourself is deeper issue that may require a different solution. Happy to discuss this after the MVP release. |
Decorators are interactive. They update every time their respective value changes. They are inserted before the error field.
That's a fair point! That means using decorators implies that you have to disable the default implementation. That was the reason why we moved everything to the
That's why we need to identify that strategic UI places where users might want to add custom UI to make sure that we provide enough flexibility so that they don't have to write the whole thing themselves. |
If you are adding decorators, I don't think you would mind not using the default implementation. It doesn't add too much work.
Agreed. Strategic places would change based on themes. This is another reason to not add this in the init and make it a theme specific "feature". There are two ways to find out the strategic places:
|
Let's discuss this over a call. |
A better idea could be that the provided component is a wrapper to the actual text input and its label. This way, we can control not only what's below the text input, but above / next to etc.. as well.. |
TODOs
Tests for CustomFields
Docs changes:
|
Field decorators
We want to allow to extend the default EmailPassword theme to add custom behaviour such as :
We want to do this without having to:
Solution
The idea is to add an optional property called
decorators
toformFields
. This decorator consists of a React element that will be inserted below the input field and that will take its value as props.Example:
With
PasswordStrengthMeterDecorator
a React element that takes a value as props (the pasword which is updated on each changes), and displays a UI below the input.We can provide few decorators as examples but the idea is that the developers can implement their own to extend the default theme easily if they like.
Implementation
Implementation is straightforward, we simply need to:
decorator?: JSX.Element
toFormFieldBaseConfig
type.onChange in
input.tsx` to make sure that the state is updated each time the value is updated (as opposed to using React refs).decorator
element, give it inputvalue
as props.The text was updated successfully, but these errors were encountered: