Component Explorers and Style Guides have been around for a while now. We don't build pages anymore but components that are assembled together to build systems.
In the Elm world, components are just called views, and are defined as pure functions. Elm UI Explorer takes advantage of the composability and the purity of Elm and offers a way to showcase your views and their states in a single tool.
This project is inspired by React Storybook and styled with Bulma.
Renders Stories of a given UI. A story represents a state of a view such as (Loading, Error, Success, NoNetwork ...)
stories : List ( String, Model )
stories =
[ ( "Loading", { isLoading = True } ), ( "Loading", { isLoading = False } ) ]
viewStories = renderStories (view model) storiesA UI represents a view and lists a set of stories. For Example : A Button with following stories (Loading, Disabled)
Represents a familly of related views. For example using Atomic Design, we can have the following categories : Atoms, Molecules etc..
Adds a UI Category to a list of categories Convenient for running a UI Explorer devided into categories
emptyUICategories
|> addUICategory
"A Great Category"
[ createUI
"My View"
MyView.viewStories
]Creates an empty list of UI Categories
Create a UI given an ID and Story Views
stories : List ( String, ButtonModel )
stories =
[ ( "LargePrimary", { label = "Primary", isLarge = True, isPrimary = True } )
, ( "TinyPrimary", { label = "Primary", isLarge = False, isPrimary = True } )
, ( "LargeSecondary", { label = "Secondary", isLarge = True, isPrimary = False } )
, ( "TinySecondary", { label = "Secondary", isLarge = False, isPrimary = False } )
]
viewStories =
renderStories customButton stories
createUI "Button" viewStoriesCreate a UI with a description
createUI "Button" "A Simple Button :-)" viewStoriesCreate a list of UICategories from a list of UI and Add them in a Default Category. This is the simplest way to initialize the UI Explorer app.
main =
app
(fromUIList
[ createUI
"PlayPause"
PlayPause.viewStories
, createUI
"Controls"
Controls.viewStories
, createUI
"TrackList"
TrackList.viewStories
]
)
Launches a UI Explorer Applicaton given a list of UI Categories