rundis / elm-bootstrap.info

User documentation for Elm Bootstrap
BSD 3-Clause "New" or "Revised" License
11 stars 19 forks source link

Navbar examples reference state.basicState, but state is undefined #8

Open mrozbarry opened 7 years ago

mrozbarry commented 7 years ago

I presume it's supposed to be model.navbarState.basicState, not state.basicState for the basic example, and the custom one has a similar variable issue.

slavaromanov commented 7 years ago

Also accordion base example need to update for Elm Platform 0.18.0. Attached a corrected example

module AccordionExample exposing (..)

import Bootstrap.Accordion as Accordion
import Bootstrap.Card as Card
import Bootstrap.Grid as Grid
import Bootstrap.Text as Text
import Html exposing (..)
import Html.Attributes exposing (..)

main : Program Never Model Msg
main =
    Html.program
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        }

type Msg
    = AccordionMsg Accordion.State

type alias Model =
    { accordionState : Accordion.State }  -- replaced = with :

init : ( Model, Cmd Msg ) 
init =         -- in example missed this line
    ( { accordionState = Accordion.initialState }, Cmd.none )

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        AccordionMsg state ->
            ( { model | accordionState = state }
            , Cmd.none
            )

view : Model -> Html Msg
view model =
    Accordion.config AccordionMsg -- AccordionMsg was skipped too 
        |> Accordion.withAnimation
        |> Accordion.cards
            [ Accordion.card
                { id = "card1"
                , options = []
                , header =
                    Accordion.header [] <| Accordion.toggle [] [ text "Card 1" ]
                , blocks =
                    [ Accordion.block []
                        [ Card.text [] [ text "Lorem ipsum etc" ] ]
                    ]
                }
            , Accordion.card
                { id = "card2"
                , options = []
                , header =
                    Accordion.header [] <| Accordion.toggle [] [ text "Card 2" ]
                , blocks =
                    [ Accordion.block []
                        [ Card.text [] [ text "Lorem ipsum etc" ] ]
                    ]
                }
            ]
        |> Accordion.view model.accordionState

-- You need to do this wiring when you use animations !

subscriptions : Model -> Sub Msg
subscriptions model =
    Accordion.subscriptions model.accordionState AccordionMsg
mrozbarry commented 7 years ago

@slavaromanov You'll probably want to create a new issue so it's easier for rundis to track.

slavaromanov commented 7 years ago

Actually I think that the themes of issues are similar, but but if you insist..