This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Outline

Outline contains everything about outline rendering.

Types

type alias Outline = { color : Maybe Color , thickness : Maybe SizeUnit , style : Maybe OutlineStyle }

The Outline record contains everything about one outline side. You probably won't use it as is, but instead using Elegant.outline which automatically generate an empty Outline record. You can then use modifiers. I.E.

Elegant.outline
    [ Outline.solid
    , Elegant.color Color.blue
    ]
type OutlineStyle = Solid | Dashed | None

Represents the possible styles of the outline. It can be Solid or Dashed. They are created by solid and dashed.

Default border

default : Outline

Generate an empty Outline record, with every field equal to Nothing. You are free to use it as you wish, but it is instanciated automatically by Elegant.outline.

Border modifiers

Appearance

thickness : SizeUnit -> Modifier Outline

Set the thickness of the outline.

none : Modifier Outline

Set the outline to none.

solid : Modifier Outline

Set the outline as solid.

dashed : Modifier Outline

Set the outline as dashed.

Compilation

outlineToCouples : Outline -> List ( String, String )

Compiles an Outline record to the corresponding CSS list of tuples. Compiles only styles which are defined, ignoring Nothing fields.

module Outline
    exposing
        ( Outline
        , default
        , OutlineStyle
        , none
        , solid
        , dashed
        , thickness
        , outlineToCouples
        )

{-| Outline contains everything about outline rendering.


# Types

@docs Outline
@docs OutlineStyle


# Default border

@docs default


# Border modifiers


## Appearance

@docs thickness
@docs none
@docs solid
@docs dashed


# Compilation

@docs outlineToCouples

-}

import Color exposing (Color)
import Elegant.Setters exposing (..)
import Helpers.Shared exposing (..)
import Modifiers exposing (..)


{-| The `Outline` record contains everything about one outline side.
You probably won't use it as is, but instead using `Elegant.outline`
which automatically generate an empty `Outline` record. You
can then use modifiers. I.E.

    Elegant.outline
        [ Outline.solid
        , Elegant.color Color.blue
        ]

-}
type alias Outline =
    { color : Maybe Color
    , thickness : Maybe SizeUnit
    , style : Maybe OutlineStyle
    }


{-| Generate an empty `Outline` record, with every field equal to Nothing.
You are free to use it as you wish, but it is instanciated automatically by `Elegant.outline`.
-}
default : Outline
default =
    Outline Nothing Nothing Nothing


{-| Represents the possible styles of the outline.
It can be Solid or Dashed. They are created by `solid` and `dashed`.
-}
type OutlineStyle
    = Solid
    | Dashed
    | None


{-| Set the outline to none.
-}
none : Modifier Outline
none =
    setStyle <| Just None


{-| Set the outline as solid.
-}
solid : Modifier Outline
solid =
    setStyle <| Just Solid


{-| Set the outline as dashed.
-}
dashed : Modifier Outline
dashed =
    setStyle <| Just Dashed


{-| Set the thickness of the outline.
-}
thickness : SizeUnit -> Modifier Outline
thickness =
    setThickness << Just


{-| Compiles an `Outline` record to the corresponding CSS list of tuples.
Compiles only styles which are defined, ignoring `Nothing` fields.
-}
outlineToCouples : Outline -> List ( String, String )
outlineToCouples outline =
    [ unwrapToCouple .thickness thicknessToCouple
    , unwrapToCouple .style styleToCouple
    , unwrapToCouple .color colorToCouple
    ]
        |> List.concatMap (callOn outline)



-- Internals


thicknessToCouple : SizeUnit -> ( String, String )
thicknessToCouple value =
    ( "outline-width", sizeUnitToString value )


styleToCouple : OutlineStyle -> ( String, String )
styleToCouple style =
    ( "outline-style", styleToString style )


styleToString : OutlineStyle -> String
styleToString val =
    case val of
        Solid ->
            "solid"

        Dashed ->
            "dashed"

        None ->
            "none"