diff --git a/src/DoubleSlider.elm b/src/DoubleSlider.elm index 23a8294..f554d5c 100644 --- a/src/DoubleSlider.elm +++ b/src/DoubleSlider.elm @@ -1,4 +1,39 @@ -module DoubleSlider exposing (DoubleSlider, init, updateHighValue, updateLowValue, view) +module DoubleSlider exposing + ( DoubleSlider + , init + , view + , updateHighValue, updateLowValue + , withCurrentRangeFormatter, withHighValueFormatter, withLowValueFormatter, withMaxFormatter, withMinFormatter, withOverlapThreshold + ) + +{-| A slider component, with two track thumbs. + + +# Definition + +@docs DoubleSlider + + +# Init + +@docs init + + +# View + +@docs view + + +# Updaters + +@docs updateHighValue, updateLowValue + + +# Config + +@docs withCurrentRangeFormatter, withHighValueFormatter, withLowValueFormatter, withMaxFormatter, withMinFormatter, withOverlapThreshold + +-} import DOM exposing (boundingClientRect) import Html exposing (..) @@ -8,6 +43,8 @@ import Json.Decode import RangeSlider +{-| Type representing the DoubleSlider component +-} type DoubleSlider msg = DoubleSlider { commonAttributes : RangeSlider.CommonAttributes @@ -178,6 +215,8 @@ defaultCurrentRangeFormatter values = -- API +{-| Initializes a DoubleSlider +-} init : { min : Float , max : Float @@ -212,6 +251,8 @@ init attrs = } +{-| Allows for customization of the minimum value label +-} withMinFormatter : (Float -> String) -> DoubleSlider msg -> DoubleSlider msg withMinFormatter formatter (DoubleSlider ({ commonAttributes } as slider)) = DoubleSlider @@ -223,6 +264,8 @@ withMinFormatter formatter (DoubleSlider ({ commonAttributes } as slider)) = } +{-| Allows for customization of the maximum value label +-} withMaxFormatter : (Float -> String) -> DoubleSlider msg -> DoubleSlider msg withMaxFormatter formatter (DoubleSlider ({ commonAttributes } as slider)) = DoubleSlider @@ -234,6 +277,8 @@ withMaxFormatter formatter (DoubleSlider ({ commonAttributes } as slider)) = } +{-| Allows for customization of the current low value label +-} withLowValueFormatter : (Float -> Float -> String) -> DoubleSlider msg -> DoubleSlider msg withLowValueFormatter formatter (DoubleSlider ({ lowValueAttributes } as slider)) = DoubleSlider @@ -245,6 +290,8 @@ withLowValueFormatter formatter (DoubleSlider ({ lowValueAttributes } as slider) } +{-| Allows for customization of the current high value label +-} withHighValueFormatter : (Float -> Float -> String) -> DoubleSlider msg -> DoubleSlider msg withHighValueFormatter formatter (DoubleSlider ({ highValueAttributes } as slider)) = DoubleSlider @@ -256,6 +303,8 @@ withHighValueFormatter formatter (DoubleSlider ({ highValueAttributes } as slide } +{-| The overlap threshold determines the minimum difference between the two thumbs. By default it is set to 1.0 +-} withOverlapThreshold : Float -> DoubleSlider msg -> DoubleSlider msg withOverlapThreshold overlapThreshold (DoubleSlider slider) = DoubleSlider @@ -267,6 +316,8 @@ withOverlapThreshold overlapThreshold (DoubleSlider slider) = } +{-| Allows for customization of the slider's range label +-} withCurrentRangeFormatter : ({ lowValue : Float, highValue : Float, min : Float, max : Float } -> String) -> DoubleSlider msg -> DoubleSlider msg withCurrentRangeFormatter currentRangeFormatter (DoubleSlider slider) = DoubleSlider @@ -278,6 +329,8 @@ withCurrentRangeFormatter currentRangeFormatter (DoubleSlider slider) = } +{-| Update the slider's low value +-} updateLowValue : Float -> DoubleSlider msg -> DoubleSlider msg updateLowValue value (DoubleSlider ({ lowValueAttributes, highValueAttributes, commonAttributes } as slider)) = DoubleSlider @@ -292,6 +345,8 @@ updateLowValue value (DoubleSlider ({ lowValueAttributes, highValueAttributes, c } +{-| Update the slider's value +-} updateHighValue : Float -> DoubleSlider msg -> DoubleSlider msg updateHighValue value (DoubleSlider ({ lowValueAttributes, highValueAttributes, commonAttributes } as slider)) = DoubleSlider @@ -306,6 +361,8 @@ updateHighValue value (DoubleSlider ({ lowValueAttributes, highValueAttributes, } +{-| DoubleSlider view +-} view : DoubleSlider msg -> Html msg view (DoubleSlider slider) = div [] diff --git a/src/SingleSlider.elm b/src/SingleSlider.elm index 0a89771..b2a782e 100644 --- a/src/SingleSlider.elm +++ b/src/SingleSlider.elm @@ -1,4 +1,39 @@ -module SingleSlider exposing (SingleSlider, init, update, view, withMaxFormatter, withMinFormatter, withValueFormatter) +module SingleSlider exposing + ( SingleSlider + , init + , view + , update + , withMaxFormatter, withMinFormatter, withValueFormatter + ) + +{-| A slider component, with one track thumb. + + +# Definition + +@docs SingleSlider + + +# Init + +@docs init + + +# View + +@docs view + + +# Update + +@docs update + + +# Config + +@docs withMaxFormatter, withMinFormatter, withValueFormatter + +-} import DOM exposing (boundingClientRect) import Html exposing (..) @@ -8,6 +43,8 @@ import Json.Decode import RangeSlider +{-| Type representing the SingleSlider component +-} type SingleSlider msg = SingleSlider { commonAttributes : RangeSlider.CommonAttributes @@ -142,6 +179,8 @@ inputDecoder = -- API +{-| Initializes a SingleSlider +-} init : { min : Float , max : Float @@ -167,6 +206,8 @@ init attrs = } +{-| Allows for customization of the minimum value label +-} withMinFormatter : (Float -> String) -> SingleSlider msg -> SingleSlider msg withMinFormatter formatter (SingleSlider ({ commonAttributes } as slider)) = SingleSlider @@ -175,6 +216,8 @@ withMinFormatter formatter (SingleSlider ({ commonAttributes } as slider)) = } +{-| Allows for customization of the maximum value label +-} withMaxFormatter : (Float -> String) -> SingleSlider msg -> SingleSlider msg withMaxFormatter formatter (SingleSlider ({ commonAttributes } as slider)) = SingleSlider @@ -183,6 +226,8 @@ withMaxFormatter formatter (SingleSlider ({ commonAttributes } as slider)) = } +{-| Allows for customization of the current value label +-} withValueFormatter : (Float -> Float -> String) -> SingleSlider msg -> SingleSlider msg withValueFormatter formatter (SingleSlider ({ valueAttributes } as slider)) = SingleSlider @@ -191,6 +236,8 @@ withValueFormatter formatter (SingleSlider ({ valueAttributes } as slider)) = } +{-| Update the slider's value +-} update : Float -> SingleSlider msg -> SingleSlider msg update value (SingleSlider ({ valueAttributes } as slider)) = SingleSlider @@ -199,6 +246,8 @@ update value (SingleSlider ({ valueAttributes } as slider)) = } +{-| SingleSlider view +-} view : SingleSlider msg -> Html msg view (SingleSlider slider) = div []