arowM / elm-neat-layout / Neat

Main module for elm-neat-layout.

Core


type alias View gap msg =
View gap msg

A gap-sensible Html msg alternative.


type alias Boundary msg =
Boundary msg

A bounded View without gap.

Convert to/from View by setGap/setBoundary.

Render

render : Renderer -> Boundary msg -> Mixin.Html.Html msg

Render the View into Html so that it spreads across the screen.


type alias Renderer =
Internal.Renderer

Settings for rendering View.

defaultRenderer : Renderer

setBaseSizeInRem : Basics.Float -> Renderer -> Renderer

Set the base size in rem.

Represents the font-size of the root element (typically ).

All gap sizes are determined relative to this value.

Handle conditions

when : Basics.Bool -> (a -> a) -> a -> a

Apply a modifier only when a condition is met.

unless : Basics.Bool -> (a -> a) -> a -> a

Apply a modifier unless a condition is met.

withMaybe : Maybe a -> (a -> b -> b) -> b -> b

Apply a modifier only if the given value is Just.

Custom gaps

You can use custom gaps just by declaring new types and IsGap values for them.

import Neat exposing (IsGap)

type ButtonGroup
    = ButtonGroup Never

buttonGroup : IsGap ButtonGroup
buttonGroup =
    IsGap
        { horizontal = 0.6
        , vertical = 0.6
        }


type alias IsGap p =
Internal.IsGap p

Information about your custom gaps.

e.g., If the base size is 2rem, IsGap { horizontal = 1.2, vertical = 2 } becomes gap with "2.4rem" horizontally and "4rem" vertically.

customGap : Gap -> IsGap p


type alias Gap =
{ horizontal : Basics.Float
, vertical : Basics.Float 
}