mirror of
https://github.com/Orasund/elm-ui-widgets.git
synced 2024-11-25 01:56:57 +03:00
radio: document & test
This commit is contained in:
parent
0d42b95bdf
commit
0ab3ba9f17
BIN
docs/assets/radio.png
Normal file
BIN
docs/assets/radio.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
@ -372,8 +372,31 @@ button =
|
||||
----------------------------------------------------------}
|
||||
|
||||
|
||||
{-| Radio style type
|
||||
-}
|
||||
type alias RadioStyle msg =
|
||||
Radio.RadioStyle msg
|
||||
{ elementButton : List (Attribute msg)
|
||||
, ifDisabled : List (Attribute msg)
|
||||
, ifSelected : List (Attribute msg)
|
||||
, ifDisabledSelected : List (Attribute msg)
|
||||
, otherwise : List (Attribute msg)
|
||||
, content :
|
||||
{ element : List (Attribute msg)
|
||||
, ifDisabled : List (Attribute msg)
|
||||
, ifSelected : List (Attribute msg)
|
||||
, ifDisabledSelected : List (Attribute msg)
|
||||
, otherwise : List (Attribute msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{-| Radio widget type
|
||||
-}
|
||||
type alias Radio msg =
|
||||
{ description : String
|
||||
, onPress : Maybe msg
|
||||
, selected : Bool
|
||||
}
|
||||
|
||||
|
||||
{-| A radio button
|
||||
@ -386,7 +409,7 @@ type alias RadioStyle msg =
|
||||
radio (Material.radio Material.defaultPalette)
|
||||
{ description = "Dark Mode"
|
||||
, onPress = Just Activate
|
||||
, active = False
|
||||
, selected = False
|
||||
}
|
||||
|> always "Ignore this line" --> "Ignore this line"
|
||||
|
||||
|
@ -330,7 +330,7 @@ iconButton =
|
||||
|
||||
{-| A radio button
|
||||
|
||||
![switch](https://orasund.github.io/elm-ui-widgets/assets/material/radio.png)
|
||||
![radio](https://orasund.github.io/elm-ui-widgets/assets/material/radio.png)
|
||||
|
||||
-}
|
||||
radio : Palette -> RadioStyle msg
|
||||
|
@ -21,7 +21,7 @@ selected =
|
||||
|
||||
spec0 : Test.Test
|
||||
spec0 =
|
||||
Test.test "#buttonRow: \n\n Widget.select\n { selected = selected\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just (Select i ))\n }\n |> Widget.buttonRow\n { elementRow = Material.row\n , content = Material.toggleButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
Test.test "#buttonRow: \n\n Widget.select\n { selected = selected\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just (Select i ))\n }\n |> Widget.buttonRow\n { elementRow = Material.row\n , content = Material.outlinedButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
\() ->
|
||||
Expect.equal
|
||||
(
|
||||
@ -39,7 +39,7 @@ spec0 =
|
||||
}
|
||||
|> Widget.buttonRow
|
||||
{ elementRow = Material.row
|
||||
, content = Material.toggleButton Material.defaultPalette
|
||||
, content = Material.outlinedButton Material.defaultPalette
|
||||
}
|
||||
|> always "Ignore this line"
|
||||
)
|
||||
|
34
tests/VerifyExamples/Widget/Radio0.elm
Normal file
34
tests/VerifyExamples/Widget/Radio0.elm
Normal file
@ -0,0 +1,34 @@
|
||||
module VerifyExamples.Widget.Radio0 exposing (..)
|
||||
|
||||
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
|
||||
-- Please don't modify this file by hand!
|
||||
|
||||
import Test
|
||||
import Expect
|
||||
|
||||
import Widget exposing (..)
|
||||
import Widget.Material as Material
|
||||
|
||||
type Msg
|
||||
= Activate
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
spec0 : Test.Test
|
||||
spec0 =
|
||||
Test.test "#radio: \n\n radio (Material.radio Material.defaultPalette)\n { description = \"Dark Mode\"\n , onPress = Just Activate\n , selected = False\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
\() ->
|
||||
Expect.equal
|
||||
(
|
||||
radio (Material.radio Material.defaultPalette)
|
||||
{ description = "Dark Mode"
|
||||
, onPress = Just Activate
|
||||
, selected = False
|
||||
}
|
||||
|> always "Ignore this line"
|
||||
)
|
||||
(
|
||||
"Ignore this line"
|
||||
)
|
@ -19,7 +19,7 @@ type Msg
|
||||
|
||||
spec0 : Test.Test
|
||||
spec0 =
|
||||
Test.test "#selectButton: \n\n { selected = Just 1\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just <| ChangedSelected i)\n }\n |> Widget.select\n |> Widget.buttonRow\n { elementRow = Material.buttonRow\n , content = Material.toggleButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
Test.test "#selectButton: \n\n { selected = Just 1\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just <| ChangedSelected i)\n }\n |> Widget.select\n |> Widget.buttonRow\n { elementRow = Material.buttonRow\n , content = Material.outlinedButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
\() ->
|
||||
Expect.equal
|
||||
(
|
||||
@ -37,7 +37,7 @@ spec0 =
|
||||
|> Widget.select
|
||||
|> Widget.buttonRow
|
||||
{ elementRow = Material.buttonRow
|
||||
, content = Material.toggleButton Material.defaultPalette
|
||||
, content = Material.outlinedButton Material.defaultPalette
|
||||
}
|
||||
|> always "Ignore this line"
|
||||
)
|
||||
|
83
tests/VerifyExamples/Widget/SortTableV20.elm
Normal file
83
tests/VerifyExamples/Widget/SortTableV20.elm
Normal file
@ -0,0 +1,83 @@
|
||||
module VerifyExamples.Widget.SortTableV20 exposing (..)
|
||||
|
||||
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
|
||||
-- Please don't modify this file by hand!
|
||||
|
||||
import Test
|
||||
import Expect
|
||||
|
||||
import Widget exposing (..)
|
||||
import Element
|
||||
import Widget.Material as Material
|
||||
|
||||
type Msg
|
||||
= ChangedSorting String
|
||||
| PressedButton String
|
||||
|
||||
asc : Bool
|
||||
asc =
|
||||
True
|
||||
sortBy : String
|
||||
sortBy =
|
||||
"Id"
|
||||
|
||||
|
||||
|
||||
spec0 : Test.Test
|
||||
spec0 =
|
||||
Test.test "#sortTableV2: \n\n Widget.sortTableV2 (Material.sortTable Material.defaultPalette)\n { content =\n [ { id = 1, name = \"Antonio\", rating = 2.456, hash = Nothing }\n , { id = 2, name = \"Ana\", rating = 1.34, hash = Just \"45jf\" }\n , { id = 3, name = \"Alfred\", rating = 4.22, hash = Just \"6fs1\" }\n , { id = 4, name = \"Thomas\", rating = 3, hash = Just \"k52f\" }\n ]\n , columns =\n [ Widget.intColumnV2\n { title = \"Id\"\n , value = .id\n , toString = \\int -> \"#\" ++ String.fromInt int\n , width = Element.fill\n }\n , Widget.stringColumnV2\n { title = \"Name\"\n , value = .name\n , toString = identity\n , width = Element.fill\n }\n , Widget.floatColumnV2\n { title = \"Rating\"\n , value = .rating\n , toString = String.fromFloat\n , width = Element.fill\n }\n , Widget.customColumnV2\n { title = \"Action\"\n , value =\n \\{name} ->\n Widget.textButton\n (Material.textButton Material.defaultPalette)\n { text = name\n , onPress = Just <| PressedButton name\n }\n , width = Element.fill\n }\n , Widget.unsortableColumnV2\n { title = \"Hash\"\n , toString = (\\{hash} -> hash |> Maybe.withDefault \"None\")\n , width = Element.fill\n }\n ]\n , asc = asc\n , sortBy = sortBy\n , onChange = ChangedSorting\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
\() ->
|
||||
Expect.equal
|
||||
(
|
||||
Widget.sortTableV2 (Material.sortTable Material.defaultPalette)
|
||||
{ content =
|
||||
[ { id = 1, name = "Antonio", rating = 2.456, hash = Nothing }
|
||||
, { id = 2, name = "Ana", rating = 1.34, hash = Just "45jf" }
|
||||
, { id = 3, name = "Alfred", rating = 4.22, hash = Just "6fs1" }
|
||||
, { id = 4, name = "Thomas", rating = 3, hash = Just "k52f" }
|
||||
]
|
||||
, columns =
|
||||
[ Widget.intColumnV2
|
||||
{ title = "Id"
|
||||
, value = .id
|
||||
, toString = \int -> "#" ++ String.fromInt int
|
||||
, width = Element.fill
|
||||
}
|
||||
, Widget.stringColumnV2
|
||||
{ title = "Name"
|
||||
, value = .name
|
||||
, toString = identity
|
||||
, width = Element.fill
|
||||
}
|
||||
, Widget.floatColumnV2
|
||||
{ title = "Rating"
|
||||
, value = .rating
|
||||
, toString = String.fromFloat
|
||||
, width = Element.fill
|
||||
}
|
||||
, Widget.customColumnV2
|
||||
{ title = "Action"
|
||||
, value =
|
||||
\{name} ->
|
||||
Widget.textButton
|
||||
(Material.textButton Material.defaultPalette)
|
||||
{ text = name
|
||||
, onPress = Just <| PressedButton name
|
||||
}
|
||||
, width = Element.fill
|
||||
}
|
||||
, Widget.unsortableColumnV2
|
||||
{ title = "Hash"
|
||||
, toString = (\{hash} -> hash |> Maybe.withDefault "None")
|
||||
, width = Element.fill
|
||||
}
|
||||
]
|
||||
, asc = asc
|
||||
, sortBy = sortBy
|
||||
, onChange = ChangedSorting
|
||||
}
|
||||
|> always "Ignore this line"
|
||||
)
|
||||
(
|
||||
"Ignore this line"
|
||||
)
|
@ -21,7 +21,7 @@ selected =
|
||||
|
||||
spec0 : Test.Test
|
||||
spec0 =
|
||||
Test.test "#tab: \n\n Widget.tab (Material.tab Material.defaultPalette)\n { tabs =\n { selected = selected\n , options =\n [ 1, 2, 3 ]\n |> List.map\n (\\int ->\n { text = \"Tab \" ++ (int |> String.fromInt)\n , icon = always Element.none\n }\n )\n , onSelect =\n (\\s ->\n if s >= 0 && s <= 2 then\n Just (ChangedTab s)\n else\n Nothing\n )\n }\n , content =\n (\\s ->\n case s of\n Just 0 ->\n \"This is Tab 1\" |> Element.text\n Just 1 ->\n \"This is the second tab\" |> Element.text\n Just 2 ->\n \"The thrid and last tab\" |> Element.text\n _ ->\n \"Please select a tab\" |> Element.text\n )\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
Test.test "#tab: \n\n Widget.tab (Material.tab Material.defaultPalette)\n { tabs =\n { selected = selected\n , options =\n [ 1, 2, 3 ]\n |> List.map\n (\\int ->\n { text = \"Tab \" ++ (int |> String.fromInt)\n , icon = always Element.none\n }\n )\n , onSelect =\n (\\s ->\n if s >= 0 && s <= 2 then\n Just (ChangedTab s)\n else\n Nothing\n )\n }\n , content =\n (\\s ->\n case s of\n Just 0 ->\n \"This is Tab 1\" |> Element.text\n Just 1 ->\n \"This is the second tab\" |> Element.text\n Just 2 ->\n \"The third and last tab\" |> Element.text\n _ ->\n \"Please select a tab\" |> Element.text\n )\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
\() ->
|
||||
Expect.equal
|
||||
(
|
||||
@ -52,7 +52,7 @@ spec0 =
|
||||
Just 1 ->
|
||||
"This is the second tab" |> Element.text
|
||||
Just 2 ->
|
||||
"The thrid and last tab" |> Element.text
|
||||
"The third and last tab" |> Element.text
|
||||
_ ->
|
||||
"Please select a tab" |> Element.text
|
||||
)
|
||||
|
46
tests/VerifyExamples/Widget/ToggleButton0.elm
Normal file
46
tests/VerifyExamples/Widget/ToggleButton0.elm
Normal file
@ -0,0 +1,46 @@
|
||||
module VerifyExamples.Widget.ToggleButton0 exposing (..)
|
||||
|
||||
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
|
||||
-- Please don't modify this file by hand!
|
||||
|
||||
import Test
|
||||
import Expect
|
||||
|
||||
import Widget exposing (..)
|
||||
import Element
|
||||
import Widget.Material as Material
|
||||
|
||||
type Msg
|
||||
= ChangedSelected Int
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
spec0 : Test.Test
|
||||
spec0 =
|
||||
Test.test "#toggleButton: \n\n { selected = Just 1\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just <| ChangedSelected i)\n }\n |> Widget.select\n |> Widget.toggleRow\n { elementRow = Material.toggleRow\n , content = Material.toggleButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
\() ->
|
||||
Expect.equal
|
||||
(
|
||||
{ selected = Just 1
|
||||
, options =
|
||||
[ 1, 2, 42 ]
|
||||
|> List.map
|
||||
(\int ->
|
||||
{ text = String.fromInt int
|
||||
, icon = always Element.none
|
||||
}
|
||||
)
|
||||
, onSelect = (\i -> Just <| ChangedSelected i)
|
||||
}
|
||||
|> Widget.select
|
||||
|> Widget.toggleRow
|
||||
{ elementRow = Material.toggleRow
|
||||
, content = Material.toggleButton Material.defaultPalette
|
||||
}
|
||||
|> always "Ignore this line"
|
||||
)
|
||||
(
|
||||
"Ignore this line"
|
||||
)
|
48
tests/VerifyExamples/Widget/ToggleRow0.elm
Normal file
48
tests/VerifyExamples/Widget/ToggleRow0.elm
Normal file
@ -0,0 +1,48 @@
|
||||
module VerifyExamples.Widget.ToggleRow0 exposing (..)
|
||||
|
||||
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
|
||||
-- Please don't modify this file by hand!
|
||||
|
||||
import Test
|
||||
import Expect
|
||||
|
||||
import Widget exposing (..)
|
||||
import Widget.Material as Material
|
||||
import Element
|
||||
|
||||
type Msg =
|
||||
Select Int
|
||||
|
||||
selected : Maybe Int
|
||||
selected =
|
||||
Just 0
|
||||
|
||||
|
||||
|
||||
spec0 : Test.Test
|
||||
spec0 =
|
||||
Test.test "#toggleRow: \n\n Widget.select\n { selected = selected\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just (Select i ))\n }\n |> Widget.buttonRow\n { elementRow = Material.row\n , content = Material.toggleButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
\() ->
|
||||
Expect.equal
|
||||
(
|
||||
Widget.select
|
||||
{ selected = selected
|
||||
, options =
|
||||
[ 1, 2, 42 ]
|
||||
|> List.map
|
||||
(\int ->
|
||||
{ text = String.fromInt int
|
||||
, icon = always Element.none
|
||||
}
|
||||
)
|
||||
, onSelect = (\i -> Just (Select i ))
|
||||
}
|
||||
|> Widget.buttonRow
|
||||
{ elementRow = Material.row
|
||||
, content = Material.toggleButton Material.defaultPalette
|
||||
}
|
||||
|> always "Ignore this line"
|
||||
)
|
||||
(
|
||||
"Ignore this line"
|
||||
)
|
48
tests/VerifyExamples/Widget/WrappedButtonRow0.elm
Normal file
48
tests/VerifyExamples/Widget/WrappedButtonRow0.elm
Normal file
@ -0,0 +1,48 @@
|
||||
module VerifyExamples.Widget.WrappedButtonRow0 exposing (..)
|
||||
|
||||
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
|
||||
-- Please don't modify this file by hand!
|
||||
|
||||
import Test
|
||||
import Expect
|
||||
|
||||
import Widget exposing (..)
|
||||
import Widget.Material as Material
|
||||
import Element
|
||||
|
||||
type Msg =
|
||||
Select Int
|
||||
|
||||
selected : Maybe Int
|
||||
selected =
|
||||
Just 0
|
||||
|
||||
|
||||
|
||||
spec0 : Test.Test
|
||||
spec0 =
|
||||
Test.test "#wrappedButtonRow: \n\n Widget.select\n { selected = selected\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just (Select i ))\n }\n |> Widget.wrappedButtonRow\n { elementRow = Material.row\n , content = Material.outlinedButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||||
\() ->
|
||||
Expect.equal
|
||||
(
|
||||
Widget.select
|
||||
{ selected = selected
|
||||
, options =
|
||||
[ 1, 2, 42 ]
|
||||
|> List.map
|
||||
(\int ->
|
||||
{ text = String.fromInt int
|
||||
, icon = always Element.none
|
||||
}
|
||||
)
|
||||
, onSelect = (\i -> Just (Select i ))
|
||||
}
|
||||
|> Widget.wrappedButtonRow
|
||||
{ elementRow = Material.row
|
||||
, content = Material.outlinedButton Material.defaultPalette
|
||||
}
|
||||
|> always "Ignore this line"
|
||||
)
|
||||
(
|
||||
"Ignore this line"
|
||||
)
|
Loading…
Reference in New Issue
Block a user