primait/pyxis-components/6.0.0

NOTE: the latest version is 9.0.3

Prima.Pyxis.Modal

Allows to create a Modal component using predefined Html syntax.

Modal Configuration

type Config msg

Represents the configuration of a Modal component. The Modal will trigger a "closed" Msg when the overlay is clicked. Is up to you to intercept and manage this Msg.

-> ModalHeader msg
-> List (Html msg)
-> ModalFooter msg
-> msg
-> Config msg

Creates a Modal.Config.

--
import Prima.Pyxis.Modal as Modal
import Html exposing (Html, p, text)


...


type Msg =
    ModalClosed


...


myModalConfig : Modal.Config
myModalConfig =
    let
        modalHeader : Modal.ModalHeader Msg
        modalHeader =
            Modal.defaultHeader "My modal title"


        modalFooter : Modal.ModalFooter Msg
        modalFooter =
            Modal.emptyFooter


        modalContent : List (Html Msg)
        modalContent =
            p [] [ text "Lorem ipsum dolor sit amet."]
    in
    Modal.config Modal.medium modalHeader  modalContent modalFooter ModalClosed

Modal Size

Represents the Modal size.

Creates a Small ModalSize

Creates a Medium ModalSize

Creates a Large ModalSize

Modal Header

type ModalHeader msg

Represents the Header configuration of a Modal.

defaultHeader : String -> ModalHeader msg

Creates a Header config with a simple title.

customHeader : List (Html msg) -> ModalHeader msg

Creates a Header config with custom Html content.

Modal Footer

type ModalFooter msg

Represents the Footer configuration of a Modal.

Represents a Footer without content.

withButtonsFooter : List (Html msg) -> ModalFooter msg

Represents a Footer with a list of Prima.Pyxis.Button instances. All the buttons will be wrapper in a btnGroup, so no more than 4 buttons are allowed.

customFooter : List (Html msg) -> ModalFooter msg

Represents a Footer with custom Html content.

Rendering

view : Bool -> Config msg -> Html msg

Renders the Modal by passing isVisible flag and a Modal.Config

--
import Prima.Pyxis.Modal as Modal
import Html exposing (Html, p, text)


...


type Msg =
    ModalClosed


...


myModalConfig : Modal.Config
myModalConfig =
    let
        modalHeader : Modal.ModalHeader Msg
        modalHeader =
            Modal.defaultHeader "My modal title"


        modalFooter : Modal.ModalFooter Msg
        modalFooter =
            Modal.emptyFooter


        modalContent : List (Html Msg)
        modalContent =
            p [] [ text "Lorem ipsum dolor sit amet."]
    in
    Modal.config Modal.medium modalHeader  modalContent modalFooter ModalClosed


renderModal : Html Msg
renderModal =
    let
        isVisible =
            True
    in
    Modal.view isVisible myModalConfig