Open upsiflu opened 1 year ago
Html
:wrapper | Link | Filter | Toggle |
---|---|---|---|
"a#b" { bounce=""} |
List "?category=" |
"?flag" |
|
"a#b" { bounce="c#d" } |
List "?category=subcat=" |
"?parameter=value" |
|
Html tag | aaria-current="page" attr label |
label ++ input current type_ "search" value attr |
a role "switch" aria-checked.. attr label |
Contingent | Ui |
List String -> Ui |
( Ui, Ui ) |
Attribute | href"a#b?bounce=c%23d" |
onInput(Filtered [categories]) |
href"?flag&toggle=flag" |
Style | isInline | isInline | isInline |
Ui.Wrapper |
---|
Stateful (State -> { label : html, isInline : Bool, contingent : Ui )) |
At Ui.view
, the given layout unwraps the Link/Filter/Toggle
wrapper into a Stateful
; and then the html
part is put smewhere according to .isInline
, and the Ui
part of it is rendered at the current region.
Both the Ui and the label are checked for emptiness (like in the current implementation) and wrapped in layout.removed etc.
Advantages:
Link/Filter/Toggle
constructor and its complete view
Disadvantages:
Ui.Stateful
Question:
Where should the Url and href management live?
(a) Completely within Restrictive
; we'd need a separate State
or Msg
module to provide defunc primitives for building transitions, including for the onInput Msg case
(b) Completely within Ui
, i.e. Ui would provide these primitives
(c) In Html
, i.e. Apps and Ui
s would remain stateless, and state would be routed through the Layout
exclusively.
Answer:
Since Restrictive.AppState
owns the Url, we want to cram all parsing and serializing functions into that module.
Otoh, Html
already covers all link types, and link types may not generalize across layout types... which would favor (c)... but then, where to place the codecs?
Question: Where should the Link and Filter types live?
ToDo:
Stateful
constructor of Ui.Wrapper
state
parameter at Ui.view
by a switch in Layout
such that there is a stateless layout and one where the state is applied, namely to any Stateful
wrapper.Restrictive.mapDocument
Html
link creation functions as outlined in the tableMsg
(apply relative changes)LinkClicked
(apply relative changes)init
(replace Url)UrlChanged
(replace Url)Question: After 2 refactorings and lots of little edge cases yet to cover, I wonder which approach is more future-proof: (a) (Re)Introduce a declarative builder/codec with opaque types. Less general than elm-url-codec and with some features features that elm-app-url is missing. Perhaps such a library exists already. (b) Use tests, preferably directly in the comments, instead of types, to "describe" the functionality and cover all edge cases
Situation: Links and Urls are needlessly parsed and serialized. The serialization format is not declaratively stated. Filters and Links don't fit well in a single type.
Desires:
Link
type and the potentialFilter
type should embody clear use patterns of the Ui state.\[]->...
in Filter should be replaced by a defunctionalised constructor (sth. likePredicate
)Related issues in order of decreasing relevance:
50
47
38
33
27
20
12
2
Questions:
elm-app-url
which happens to treat "a=" as "a" but "=" as (""="")? How does it treat "a=b=c" which is relevant for making filters selectors? Is it a good basis for the link encoder and queryer and for the url*state parser? A: No.Api and Invariants
href
s are always minimal, i.e. they represent only the intended transition from the current state to the new one.makeAbsolute
isTrue
:Toggle
becomesturn on
;Bounce { there, here }
becomesGoTo there
When to use links
The Url is a state shared by all interactive elements in a tab. It is very easy to manually edit, to share and to reproduce, but its utility diminishes when the Url gets too long:
Sample patterns
Token
Set