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

Add help policy #26

Open
Tracked by #54
zelenij opened this issue Sep 18, 2021 · 5 comments
Open
Tracked by #54

Add help policy #26

zelenij opened this issue Sep 18, 2021 · 5 comments

Comments

@zelenij
Copy link
Contributor

zelenij commented Sep 18, 2021

There should be a way to add detailed help/description to individual form fields

@MangelMaxime
Copy link
Owner

MangelMaxime commented Sep 19, 2021

@zelenij Do you have an exemple of what you mean?

Like having a "?" display near the input where the user can hover it?

@zelenij
Copy link
Contributor Author

zelenij commented Sep 19, 2021

I would like to have a choice - either a "Help" icon (yes, can be a ?), with a custom action, or a predefined text with description/instructions. And some field might not have anything, of course. See this example:

image

@MangelMaxime
Copy link
Owner

Ok, I see the idea.

This is definitely something we could add, we just need to find a clean API to do it.

I think it will probably go into the Attributes property of the different like the Label, Placeholder.

In your example, I can see that it could be a simple string or something more complex with a link etc.

Perhaps, we should use a custom DUs:

type Help =
   | None
   | Text of string
   | Element of ReactElement

I can't think of a good name for the Element. I don't want to name it ReactElement because Fable.Form has the potential to be renderer agnostic in the future.

I added the None case into the DUs to simplify the code from the consumer perspective. If we were to use Help option for the property the user would have to write Some (Text "Help text goes here") instead of just Text "Help text goes here.

What is your opinion?

@zelenij
Copy link
Contributor Author

zelenij commented Sep 22, 2021

Yes, this is a good start. I'd modify:

type Help =
   | None
   | Text of string
   | Component of ReactElement
   // Display a help icon and call this event on click
   // Maybe add another option, which react to on hover?
   | Action of unit -> unit // or accept the mouse click event?

@MangelMaxime
Copy link
Owner

If we allow the user to provide a ReactElement he can configure any behavior he wants, as he can register click, hover, events occurring to the ReactElement.

In general, I try to avoid providing really specialized callbacks because it quickly end up bloating the library code.

Also, it is important to remember that this is (almost?) impossible to provide an universal form logic which works for all the applications in the word. That's why Fable.Form is fully extensible so people can write their own logic and view layer to fit their needs.

For example, in all the applications I had to write at work we needed some really specific components.

Example

speciliazed_form_demo.mp4

So often I ended up writing a specific "library" for the needs of that application.

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

No branches or pull requests

2 participants