PaackEng/paack-ui/1.0.0

NOTE: the latest version is 7.23.0

UI.Utils.Element

Utilities and functionality that are not covered by Elm UI.

Color

colorSetOpacity : Float -> Color -> Color

Overwrite alpha value in an Element.Color.

colorTransition : Int -> List (Attribute msg)

Enable CSS transition for HTML's color, background-color, border-color. Time is set in miliseconds.

Element.el
    (Background.color someVariatingColor :: Element.colorTransition 200)
    someChildElement

Responsiveness

desktopMaximum : RenderConfig -> Int -> Length

Limit Element.fill only when on desktop.

Element.width (Element.desktopMaximum 640)

HTML features

svg : String -> List (Attribute msg) -> List (Svg msg) -> Element msg

The SVG element, with ARIA attributes applied.

svg "Alt text" svgAttributes svgContent
title : String -> Attribute msg

"The title attribute specifies extra information about an element.

The information is most often shown as a tooltip text when the mouse moves over the element." - W3Schools

Element.el [ Element.title "Some text" ] someChildElement
ellipsis : List (Attribute msg)

Applies required CSS values to have ellipsis on an element's text when width is not enough for displaying the whole content.

Element.el
    (Element.width (px 200) :: Element.ellipsis)
    (Element.text "Lorem ipsum dolor sit amet, consectetur adipiscing elit")
maxHeightVH : Int -> Attribute msg

Wrapper for CSS's max-height: {{vaue}}vh.

Element.el [ Element.maxHeightVH 100 ] someChildElement
maxHeightPct : Float -> Attribute msg

Wrapper for CSS's max-height: {{vaue}}%.

Element.el [ Element.maxHeightPct 100 ] someChildElement

Input

disabled : List (Attribute msg)

All the attributes that define an element as disabled for modifying.

Element.el Element.disabled <| Element.text "Some content"
onEnterPressed : msg -> Attribute msg

Trigger message when the users press return-key while element is on-focus.

Element.el [ Element.onEnterPressed Msg.ActivateSomething ] someChildElement
onIndividualClick : msg -> Attribute msg

Equivalent to Element.onClick with stopPropagation and preventDefault applied.

Element.el
    [ Element.onIndividualClick Msg.CoolTextClicked ]
    (Element.text "Cool text")

Padding, borders and size

type alias RectangleSides =
{ top : Int
, left : Int
, right : Int
, bottom : Int
}

The classic top, left, right and bottom as integers record.

zeroPadding : RectangleSides

Zero-initialized record for paddings and borders.

Element.paddingEach
    { zeroPadding | bottom = 20 }