Option to color menu using the primary color
Renamed to aDifferentJT/elm-bootstrap. That is where the repository lives now. It has not been published as a package under the new name.
Versions published as nixCodeX/elm-bootstrap still install under that name. 13 versions of 13 come from the new location (see their notes).
Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/aDifferentJT/elm-bootstrap.
What we checked: The repo moved to github.com/aDifferentJT/elm-bootstrap. Rebuilt with git archive from commit 4b19ac3ec941 of https://github.com/aDifferentJT/elm-bootstrap (zip prefix nixCodeX-elm-bootstrap-4b19ac3/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 ade0e3cc3a34a0e45f9c7b60d27e5d8f435cb89a.
The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.
Details · package.elm-lang.org's zip: https://github.com/nixCodeX/elm-bootstrap/zipball/2.0.3/
The navbar is a wrapper that positions branding, navigation, and other elements in a concise header. The navbar is designed to be responsive by default and made interactive with a tiny sprinkle of Elm.
import Bootstrap.Navbar as Navbar
-- You need to keep track of the view state for the navbar in your model
type alias Model =
{ navbarState : Navbar.State }
-- The navbar needs to know the initial window size, so the inital state for a navbar requires a command to be run by the Elm runtime
initialState : ( Model, Cmd Msg )
initialState =
let
( navbarState, navbarCmd ) =
Navbar.initialState NavbarMsg
in
( { navbarState = navbarState }, navbarCmd )
-- Define a message for the navbar
type Msg
= NavbarMsg Navbar.State
-- You need to handle navbar messages in your update function to step the navbar state forward
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
NavbarMsg state ->
( { model | navbarState = state }, Cmd.none )
view : Model -> Html Msg
view model =
Navbar.config NavbarMsg
|> Navbar.withAnimation
|> Navbar.brand [ href "#" ] [ text "Brand" ]
|> Navbar.items
[ Navbar.itemLink [ href "#" ] [ text "Item 1" ]
, Navbar.itemLink [ href "#" ] [ text "Item 2" ]
]
|> Navbar.view model.navbarState
-- If you use animations as above or you use dropdowns in your navbar you need to configure subscriptions too
subscriptions : Model -> Sub Msg
subscriptions model =
Navbar.subscriptions model.navbarState NavbarMsgCreates a default navbar view configuration. Providing a starting point to set up your navbar how you'd like.
Configuration information for describing the view of the Navbar
options List of configuration optionstoMsg Message function used for stepping the viewstate of the navbar forwardwithAnimation Set to True if you wish the menu to slide up/down with an animation effectbrand Optional brand element (typically a logo)items List of menu items that the user can select fromcustomItems List of custom (inline) items that you may place to the right of the std. navigation itemsUse a slide up/down animation for toggling the navbar menu when collapsed.
**NOTE: ** Do remember to set up the subscriptions function when using this option.
Option to fix the menu to the top of the viewport
**Note: You probably need to add some margin-top to the content element following the navbar when using this option **
Option to color menu using a light custom background color (see avh4/elm-color)
Option to color menu using a dark custom background color (see avh4/elm-color)
Option to color menu using a light custom background color defined by css class(es)
Option to color menu using a dark custom background color defined by css class(es)
Collapse the menu at the small media breakpoint
Collapse the menu at the medium media breakpoint
Collapse the menu at the large media breakpoint
Collapse the menu at the extra large media breakpoint
Use this option when you want a fixed width menu (typically because your main content is also configured to be fixed width)
Add a custom Html.Attribute to the navbar element using this function
Create a brand element for your navbar
Navbar.brand
[ href "#" ]
-- (and perhaps use onWithOptions for custom handling of clicks !)
[ img [ src "assets/logo.svg" ] [ text "MyCompany" ] ]
configattributes List of attributeschildren List of childrenconfig Navbar config record to add/modify brand forOpaque type representing a brand element
Configure your navbar with a list of navigation links and/or dropdowns.
NOTE If you call this function several times, the last time "wins".
Create a menu item (as an a element)
attributes List of attributeschildren List of childrenCreate a menu item that is styled as active (as an a element)
attributes List of attributeschildren List of childrenOpaque type representing a selectable menu item
Create a dropdown menu for use in a navbar
config A record with the following propertiesid A unique id for your dropdown. It's important, because it's used to keep track of the state of the dropdown!toggle The main item (toggle) that toggles the dropdown menu up or downitems List of menu items for the dropdownFunction to construct a toggle for a dropdown
Creates an a element appropriate for use in a nav dropdown
attributes List of attributeschildren List of child elementsCreates a divider element appropriate for use in dropdowns. Handy when you want to visually separate groups of menu items in a dropdown menu
Creates an header element appropriate for use in dropdowns. Handy when you want to provide a heading for a group of menu items in a dropdown menu
children List of child elementsOpaque type representing the toggle element for a dropdown menu
Opaque type representing an item in a dropdown menu
You can add custom items to a navbar too. These are placed after any navigation items.
NOTE If you call this function several times, the last time "wins".
Create a custom inline text element, which will float to the right when the menu isn't collapsed
attributes List of attributeschildren List of children**Note: If you have multiple custom items you will need to provide spacing between them yourself **
Create a custom inline form element, which will float to the right when the menu isn't collapsed
Navbar.formItem []
[ TextInput.text
[ TextInput.small ]
, Button.button
[ Button.roleSuccess, Button.small]
[ text "Submit"]]
]attributes List of attributeschildren List of children**Note: If you have multiple custom items you will need to provide spacing between them yourself **
Create a completely custom item, which will float to the right when the menu isn't collapsed. You should ensure that you create inline elements or else your menu will break in unfortunate ways!
attributes List of attributeschildren List of children**Note: If you have multiple custom items you will need to provide spacing between them yourself **
Opaque type representing a custom (inline) navbar item
You need to call this function to initialize the view state for the navbar and store the state in your main model.
init : ( Model, Cmd Msg )
init =
let
( navbarState, navCmd ) =
Navbar.initialState NavbarMsg
in
( { navbarState = navbarState }
, navCmd
)The Cmd part is needed, because the navbar as implemented currently needs the window size. Hopefully a smoother solution can be devised in the future.
Opaque type representing the view state of the navbar and any navbar dropdown menus
To support animations and managing the state of dropdown you need to wire up this function in your main subscriptions function.
subscriptions : Model -> Sub Msg
subscriptions model =
Navbar.subscriptions model.navbarState NavbarMsg**Note: ** If you are NOT using dropdowns in your navbar AND you are using a navbar without animation you can skip this. But it's not that much work, so maybe you are better off doing it anyway.
The main view function for displaying a navbar.
stateRequired view state the navbar uses to support interactive behaviorconfigThe viewconfigurationthat determines to look and feel of the navbar