A rating component in Elm.
The Rating need a Rating Model on your model like this:
type alias Model =
{ rating : Rating.Model }The view will be update based on this rating. Rating expose defaultModel.
I recomend only change the variable: quantity, colorDefault ,colorSelected, colorOver, readOnly.
If need show rating defined, change rating and rating Percent.
Dont Touch isOver, ratingOver.
initial : Model
initial =
Model Rating.defaultModelThe Rating can be displayed in a view using the Rating.view function. It returns its own message type so you should wrap it in one of your own messages using Html.map:
type Msg
= ...
| RatingMessage Rating.Msg
| ...
view : Model -> Html Msg
view model =
...
div [] [
Html.map RatingMessage (Rating.view model.rating)
]In order handle Msg in your update function, you should unwrap the Rating.Msg and pass it
down to the Rating.update function. The Rating.update function returns the Rating Model updated.
update : Msg -> Model -> ( Model, Cmd, Msg )
update msg model =
case msg of
...
RatingMessage msg ->
let
( updateRating, subCmd ) =
Rating.update msg model.rating
in
{ model | rating = updateRating } ! [ Cmd.map RatingMessage subCmd ]See the examples folder