Skip to content

Commit

Permalink
Documentation (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
rflagreca authored Jan 28, 2020
1 parent 0d91b46 commit be71747
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 2 deletions.
59 changes: 58 additions & 1 deletion src/DoubleSlider.elm
Original file line number Diff line number Diff line change
@@ -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 (..)
Expand All @@ -8,6 +43,8 @@ import Json.Decode
import RangeSlider


{-| Type representing the DoubleSlider component
-}
type DoubleSlider msg
= DoubleSlider
{ commonAttributes : RangeSlider.CommonAttributes
Expand Down Expand Up @@ -178,6 +215,8 @@ defaultCurrentRangeFormatter values =
-- API


{-| Initializes a DoubleSlider
-}
init :
{ min : Float
, max : Float
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -306,6 +361,8 @@ updateHighValue value (DoubleSlider ({ lowValueAttributes, highValueAttributes,
}


{-| DoubleSlider view
-}
view : DoubleSlider msg -> Html msg
view (DoubleSlider slider) =
div []
Expand Down
51 changes: 50 additions & 1 deletion src/SingleSlider.elm
Original file line number Diff line number Diff line change
@@ -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 (..)
Expand All @@ -8,6 +43,8 @@ import Json.Decode
import RangeSlider


{-| Type representing the SingleSlider component
-}
type SingleSlider msg
= SingleSlider
{ commonAttributes : RangeSlider.CommonAttributes
Expand Down Expand Up @@ -142,6 +179,8 @@ inputDecoder =
-- API


{-| Initializes a SingleSlider
-}
init :
{ min : Float
, max : Float
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -199,6 +246,8 @@ update value (SingleSlider ({ valueAttributes } as slider)) =
}


{-| SingleSlider view
-}
view : SingleSlider msg -> Html msg
view (SingleSlider slider) =
div []
Expand Down

0 comments on commit be71747

Please sign in to comment.