Editor modifier to provide feedback (e.g. error icons)
We currently have the following editor modifiers to easily add error icons/tooltips on editors:
mapEditorWriteError :: !(wb -> MaybeErrorString w) !(Editor r wb) -> Editor r (?w) withDynamicHintAttributesWithError :: !String !(Editor r (MaybeError String w)) -> Editor r (?w)
There is one clear difference in the API: the first takes a mapping function while the second works on a MaybeError String w
editor. This may be useful when working directly on a custom leaf editor, although to be honest I just didn't think about the signature when I added it.
More importantly the behaviour is different: the first will set only error icons, while the second creates an editor that always has an icon and is more like the generic editors in its behaviour: when the value is valid a success icon; when the value is invalid but untouched an info icon; otherwise an error icon. The behaviour of the first is useful to avoid having an enormous amount of icons. However, when there is content right of the editor it is UI-wise better to always show an icon to avoid moving that content when adding/removing the icon. So I think it would be nice to have both behaviours available, but it is not clear from the signatures which function has which behaviour.
Can we try to synchronize these two (and withDynamicHintAttributes
as well)? Perhaps with an option parameter to withDynamicHintAttributesWithError
:
:: DynamicTooltipOptions = OnlyErrorTooltip | AllTooltips !String // The string is a description of the type, for in the success and info tooltip withDynamicHintAttributesWithError :: !DynamicTooltipOptions !(Editor r (MaybeError String w)) -> Editor r (?w) mapEditorWriteError :: !DynamicTooltipOptions !(wb -> MaybeErrorString w) !(Editor r wb) -> Editor r (?w)
(At this point mapEditorWriteError
would be a simple wrapper around mapEditorWrite
and withDynamicHintAttributesWithError
.)
There are of course other ways to encode the options, e.g.:
:: DynamicTooltipOption | AllTooltips | NoInfoTooltip | NoSuccessTooltip | NoErrorTooltip | OnlyInfoTooltip | OnlySuccessTooltip | OnlyErrorTooltip | TypeDescription !String withDynamicHintAttributesWithError :: ![DynamicTooltipOption] !(Editor r (MaybeError String w)) -> Editor r (?w)
This particular one seems overly complicated to me though.
@baslijns @smichels
(Side note: if we're going to change the type of withDynamicHintAttributes(WithError)
that may also be a good moment to rename it to use Tooltip
instead of Hint
(https://gitlab.science.ru.nl/clean-and-itasks/iTasks-SDK/-/merge_requests/510). I think we can also drop Dynamic
and Attributes
: withTooltips(WithError)
.)