Closed dpinn closed 5 years ago
Why is this a problem? It's an internal type, no need for the user to bother with.
I'd like to write functions to create my list items. The return type of such functions would reference an internal type, which just seems weird.
OK let me know if this works for you. Given that ListItem are new, I appreciate any feedback. Let me know your use case!
I'm planning to use them everywhere, i.e. Drawer and Menu at this stage too, that's the only way I can see that would keep the user experience simple while still providing keyboard navigation and ripples.
I did some quick experiment myself, and exposing ListItem does not give you the ability to write your own functions I believe. Not sure yet what needs to happen to make this work.
Hi @berenddeboer, as far as I understood, the original issue was that you could not write the type myListItem : String -> Material.List.ListItem msg
, but instead you had to write myListItem : String -> Material.Internal.List.ListItem msg
.
So I think your commit ac7a42a solves that. Or am I missing something? @dpinn
PS. @berenddeboer, have you considered making ListItem
an opaque type?
type ListItem = ListItem { options : {- etc. -} }
as far as I understood ... you had to write
myListItem : String -> Material.Internal.List.ListItem msg
.
Yes, if that's the case I fixed it.
But I did some kind of experiment if I could write a thing like li
outside list's Implementation.elm. I couldn't get to work easily.
I.e. you want in your list not just Lists.li
, but also SuperLists.li
, where you try to do the same trick, i.e. returning a ListItem yourself.
have you considered making
ListItem
an opaque type?
Actually the reverse :-) I was trying to expose the constructor to see if you write things like li in another module. But it said there was no ListItem constructor.
@berenddeboer What would be a use-case to construct a ListItem
directly? I am assuming that you could write any custom list items in terms of the functions exposed that return a ListItem
such as li
.
An example for a custom list item would be a list item that always sets a graphic icon and a text:
myListItem : String -> String -> ListItem msg
myListItem iconName label =
Lists.li [ Lists.graphicIcon [] iconName, text label ]
Hi @berenddeboer, as far as I understood, the original issue was that you could not write the type
myListItem : String -> Material.List.ListItem msg
, but instead you had to writemyListItem : String -> Material.Internal.List.ListItem msg
.So I think your commit ac7a42a solves that. Or am I missing something? @dpinn
That's it exactly. I my case, I want to construct list items by mapping over a list of thingamebobs that I fetch from the server.
A new piece of functionality is coming in #203: you can now include any HTML in a list if you prefix it with Lists.asListItem.
The Material.List module defines ul as:
where
List.ListItem
refers toInternal.List.Implementation.ListItem
.