Minor tweaks after reviewing diff

This commit is contained in:
chris 2020-08-11 15:04:44 -07:00
parent c410b918d5
commit bb71703f15
5 changed files with 21 additions and 49 deletions

View File

@ -9,9 +9,4 @@ circularProgressIndicator :
-> { maybeProgressPercent : Maybe Int }
-> Element msg
circularProgressIndicator style { maybeProgressPercent } =
-- TODO determinate indicator based on progressPercent
style.icon maybeProgressPercent
-- TODO linear progress indicator

View File

@ -119,6 +119,15 @@ You can create you own widgets by sticking widgets types together.
@docs Dialog, ExpansionPanel
# Progress Indicator
![ProgressIndicator](TODO)
[Open in Ellie](TODO)
@docs ProgressIndicator, progressIndicator
-}
import Element exposing (Attribute, Element, Length)

View File

@ -1,6 +1,4 @@
module Widget.Style exposing
( ButtonStyle, ColumnStyle, DialogStyle, ExpansionPanelStyle, LayoutStyle, RowStyle, SnackbarStyle, SortTableStyle, TabStyle, TextInputStyle, ProgressIndicatorStyle
)
module Widget.Style exposing (ButtonStyle, ColumnStyle, DialogStyle, ExpansionPanelStyle, LayoutStyle, RowStyle, SnackbarStyle, SortTableStyle, TabStyle, TextInputStyle, ProgressIndicatorStyle)
{-| This module contains style types for every widget.
@ -136,6 +134,7 @@ type alias LayoutStyle msg =
}
{-| -}
type alias ProgressIndicatorStyle msg =
{ icon : (Maybe Int -> Element msg)
}

View File

@ -1215,8 +1215,8 @@ expansionPanel palette =
-------------------------------------------------------------------------------}
indeterminateCircIcon : Color.Color -> List (Attribute msg) -> Element msg
indeterminateCircIcon color attribs =
indeterminateCircularIcon : Color.Color -> List (Attribute msg) -> Element msg
indeterminateCircularIcon color attribs =
-- Based on example at https://codepen.io/FezVrasta/pen/oXrgdR
Svg.svg
[ Svg.Attributes.height "48px"
@ -1272,8 +1272,8 @@ indeterminateCircIcon color attribs =
|> Element.el attribs
determinateCircIcon : Color.Color -> List (Attribute msg) -> Int -> Element msg
determinateCircIcon color attribs progressPercent =
determinateCircularIcon : Color.Color -> List (Attribute msg) -> Int -> Element msg
determinateCircularIcon color attribs progressPercent =
-- With help from https://css-tricks.com/building-progress-ring-quickly/
let
strokeDashoffset =
@ -1290,17 +1290,7 @@ determinateCircIcon color attribs progressPercent =
, Svg.Attributes.xmlSpace "http://www.w3.org/2000/svg"
]
[ Svg.g []
[ {- Svg.animateTransform
[ Svg.Attributes.attributeName "transform"
, Svg.Attributes.type_ "rotate"
, Svg.Attributes.values "0 33 33;270 33 33"
, Svg.Attributes.begin "0s"
, Svg.Attributes.dur "1.4s"
, Svg.Attributes.fill "freeze"
, Svg.Attributes.repeatCount "indefinite"
]
[]
, -}Svg.circle
[ Svg.circle
[ Svg.Attributes.fill "none"
, Svg.Attributes.stroke (Color.toCssString color)
, Svg.Attributes.strokeWidth "5"
@ -1312,26 +1302,7 @@ determinateCircIcon color attribs progressPercent =
, Svg.Attributes.strokeDashoffset (String.fromInt strokeDashoffset)
, Svg.Attributes.transform "rotate(-90 33 33)"
]
[ {- Svg.animateTransform
[ Svg.Attributes.attributeName "transform"
, Svg.Attributes.type_ "rotate"
, Svg.Attributes.values "0 33 33;135 33 33;450 33 33"
, Svg.Attributes.begin "0s"
, Svg.Attributes.dur "1.4s"
, Svg.Attributes.fill "freeze"
, Svg.Attributes.repeatCount "indefinite"
]
[]
, Svg.animate
[ Svg.Attributes.attributeName "stroke-dashoffset"
, Svg.Attributes.values "187;46.75;187"
, Svg.Attributes.begin "0s"
, Svg.Attributes.dur "1.4s"
, Svg.Attributes.fill "freeze"
, Svg.Attributes.repeatCount "indefinite"
]
[] -}
]
[]
]
]
|> Element.html
@ -1344,9 +1315,9 @@ progressIndicator palette =
\maybeProgressPercent ->
case maybeProgressPercent of
Nothing ->
indeterminateCircIcon palette.primary []
indeterminateCircularIcon palette.primary []
Just progressPercent ->
determinateCircIcon palette.primary [] progressPercent
determinateCircularIcon palette.primary [] progressPercent
}

View File

@ -1,7 +1,6 @@
module Widget.Style.Template exposing
( box, decoration, icon
, button, column, dialog, expansionPanel, layout, row, snackbar, sortTable, tab, textInput
, progressIndicator
, button, column, dialog, expansionPanel, layout, progressIndicator, row, snackbar, sortTable, tab, textInput
)
{-| ![Example using the Template style](https://orasund.github.io/elm-ui-widgets/assets/template-style.png)
@ -346,8 +345,7 @@ sortTable string =
```
progressIndicator : String -> ProgressIndicatorStyle msg
progressIndicator string =
{ track = box <| string ++ ":track"
, indicator = box <| string ++ ":box"
{ icon = (\_ -> icon <| string ++ ":icon")
}
```