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 generic number/text input box #30

Closed
ortk95 opened this issue Aug 11, 2021 · 4 comments
Closed

Add generic number/text input box #30

ortk95 opened this issue Aug 11, 2021 · 4 comments

Comments

@ortk95
Copy link
Contributor

ortk95 commented Aug 11, 2021

No description provided.

@georgefst
Copy link
Owner

georgefst commented Aug 13, 2021

Made a start in 1ada83e, but:

  • I'd like to provide some control over styling, including font size.
  • Text and number inputs fire events on every keypress. We'd prefer to wait for the user to confirm, which would require a separate button for mobile devices. We could even make this configurable. (submit event introduced in ac044da - see Send current contents with submit message, and clear on submission #35 for making it more useful)
  • Checkboxes always emit "on", so we always get InputBool _ True. (fixed in e492745)
  • It would be nice to just call the inputType field "type". We can't do that in Haskell or Elm because it's a keyword, but there should be some workaround for JSON and Dhall.
  • We might want other input types, e.g. radio buttons.

@georgefst
Copy link
Owner

georgefst commented Aug 14, 2021

Checkboxes always emit "on", so we always get InputBool _ True

It's actually worse. They seem to always echo the last event. So if, say, we update a layout so that a number input changes to a checkbox, then the checkbox starts emitting numbers (which we fail to decode to Bools, so we don't send an update).

georgefst added a commit that referenced this issue Aug 15, 2021
See #30.

Easier than I expected. There's already a function in the Elm standard library for exactly this.
@georgefst
Copy link
Owner

It would be nice to just call the inputType field "type". We can't do that in Haskell or Elm because it's a keyword, but there should be some workaround for JSON and Dhall.

There may be no nice way to do this. We can use _type and add FieldLabelModifier (StripPrefix "_") to Opts.JSON (and a similar option is available for Dhall), but _type is not a valid record name in Elm. I can't even find a spec of exactly what names are valid.

@georgefst
Copy link
Owner

Ok. I don't care about the last two, and I've opened #37 to track the first (though we did make the text stylable in 6c6d222).

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