PaackEng/paack-ui/7.10.0

NOTE: the latest version is 7.23.0

UI.Utils.Action

Describes a clickable element for components with customizable clickable action.

Building

type Action msg
= DispatchMsg msg
| TriggerRedirect Link

Either a message to be dispatched, or an link to be followed.

Helpers

type alias WithIcon msg =
{ action : Action msg
, icon : String -> Icon
, label : String
}

WithIcon assembles the required configuration for having an action element.

{ label = "Create new element"
, icon = Icon.add
, action =
    DialogMsg.OpenElementCreation
        |> Msg.ForDialog
        |> Action.DispatchMsg
}
iconMap : (a -> b) -> WithIcon a -> WithIcon b

Applies a transformation to the message in a WithIcon msg, when it exists.

Action.iconMap
    PageMsg.ForDialog
    { action = Action.DispatchMsg DialogMsg.Close
    , icon = Icon.close
    , label = "Close"
    }
iconWith : (Icon -> Icon) -> WithIcon msg -> WithIcon msg

Applies a transformation to the icon in a WithIcon msg.

Action.iconWith
    (Icon.withSize Size.small)
    { action = Action.DispatchMsg DialogMsg.Close
    , icon = Icon.close
    , label = "Close"
    }