From 0ab3ba9f17942e48e3db44511485106f3e564932 Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Wed, 13 Jul 2022 19:10:37 +0200 Subject: [PATCH] radio: document & test --- docs/assets/radio.png | Bin 0 -> 2366 bytes src/Widget.elm | 27 +++++- src/Widget/Material.elm | 2 +- tests/VerifyExamples/Widget/ButtonRow0.elm | 4 +- tests/VerifyExamples/Widget/Radio0.elm | 34 +++++++ tests/VerifyExamples/Widget/SelectButton0.elm | 4 +- tests/VerifyExamples/Widget/SortTableV20.elm | 83 ++++++++++++++++++ tests/VerifyExamples/Widget/Tab0.elm | 4 +- tests/VerifyExamples/Widget/ToggleButton0.elm | 46 ++++++++++ tests/VerifyExamples/Widget/ToggleRow0.elm | 48 ++++++++++ .../Widget/WrappedButtonRow0.elm | 48 ++++++++++ 11 files changed, 291 insertions(+), 9 deletions(-) create mode 100644 docs/assets/radio.png create mode 100644 tests/VerifyExamples/Widget/Radio0.elm create mode 100644 tests/VerifyExamples/Widget/SortTableV20.elm create mode 100644 tests/VerifyExamples/Widget/ToggleButton0.elm create mode 100644 tests/VerifyExamples/Widget/ToggleRow0.elm create mode 100644 tests/VerifyExamples/Widget/WrappedButtonRow0.elm diff --git a/docs/assets/radio.png b/docs/assets/radio.png new file mode 100644 index 0000000000000000000000000000000000000000..f216365c67b3b96004b42d08bf3ae00e57c97a60 GIT binary patch literal 2366 zcmb7`c{tSD8^FJ^jWL=bN|s@)Ly|F)kTHWSQLuG3k8DlA0 zj9-f-q!KDisVi4xO&W2jxw4e}zW4XveV*Sxzw?}P-se5%eV_L{@AG-jIl1nxj&e{H zC;$L*&QA6uP^N&x1tJB`rP~w}P)NiPoXHTdB|}c;fcjphgAda)I)s@J6iWv}qoNt~ z{c*vubb3@=STu84ywe6WGWgrbE|wm|43Cb|B!@HT0D~TDtck&DMw||hG}bgVF*Vi1 zSXdrBY>6?y>bUU=03cjvdpwy{zQko5^CTkAr!k)FFsuyAmHb#+Ij;OWI*&#?XZR>x z1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oRKLvxq8aKw8qkF+(KP7yl z3jzz1lfw%}X1nwE06?z&j_M(c2#3_E$70NcgrvwlC<$?Kaj=Lo-O={Z(FYo+Z9Sh3 z1Uyp9$jE3(-Y^9!+uBq|1OXs$0|NuEBOU}QOWkn2_7r6B(xpq&n4Ue!!_yZ?^;x5l z*?z{MZxx}E{UM^3H+0jzt~?v|eoB+3wzfD};KVXxx@dNG)`LoA|NNQkq@&P&MkJNL zdw-^nk^{-gF{jtD^?d4M@#?X z&W^E3(#UU8*@xT;>DK5R3pyjTR_7`i*e|-smqu~258{rCK8<)-%#`e>P}oY|J5vH3 zl4xEv2uh&@X``s$o4CCySRRUvfB*>I!uj9Z!`Jb1($4LodB?ay^=kvLKP#H6<{L!P z7cX?s7JvTuSb-C91ea|{tO<@LIw8Mze_C5CWPbY_5>Uc%VoE2xg1d3?ayx)u*SQ%E zoL>QoYs+b)l@lxaK;;zgt&oh9i7EA0J_z&?d+X#U{D14d^Acqpo!~lm${^LJjdGz_ zPe};FuEE>}P8slUL+bzPQTlQ-f5ytybEtA}kKa always "Ignore this line" --> "Ignore this line" diff --git a/src/Widget/Material.elm b/src/Widget/Material.elm index 1f9af60..c17e555 100644 --- a/src/Widget/Material.elm +++ b/src/Widget/Material.elm @@ -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 diff --git a/tests/VerifyExamples/Widget/ButtonRow0.elm b/tests/VerifyExamples/Widget/ButtonRow0.elm index 88f8db9..ee371ac 100644 --- a/tests/VerifyExamples/Widget/ButtonRow0.elm +++ b/tests/VerifyExamples/Widget/ButtonRow0.elm @@ -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" ) diff --git a/tests/VerifyExamples/Widget/Radio0.elm b/tests/VerifyExamples/Widget/Radio0.elm new file mode 100644 index 0000000..75964d1 --- /dev/null +++ b/tests/VerifyExamples/Widget/Radio0.elm @@ -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" + ) \ No newline at end of file diff --git a/tests/VerifyExamples/Widget/SelectButton0.elm b/tests/VerifyExamples/Widget/SelectButton0.elm index ca5dc36..b74645d 100644 --- a/tests/VerifyExamples/Widget/SelectButton0.elm +++ b/tests/VerifyExamples/Widget/SelectButton0.elm @@ -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" ) diff --git a/tests/VerifyExamples/Widget/SortTableV20.elm b/tests/VerifyExamples/Widget/SortTableV20.elm new file mode 100644 index 0000000..925ad66 --- /dev/null +++ b/tests/VerifyExamples/Widget/SortTableV20.elm @@ -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" + ) \ No newline at end of file diff --git a/tests/VerifyExamples/Widget/Tab0.elm b/tests/VerifyExamples/Widget/Tab0.elm index 8448d84..c13b486 100644 --- a/tests/VerifyExamples/Widget/Tab0.elm +++ b/tests/VerifyExamples/Widget/Tab0.elm @@ -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 ) diff --git a/tests/VerifyExamples/Widget/ToggleButton0.elm b/tests/VerifyExamples/Widget/ToggleButton0.elm new file mode 100644 index 0000000..e771cea --- /dev/null +++ b/tests/VerifyExamples/Widget/ToggleButton0.elm @@ -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" + ) \ No newline at end of file diff --git a/tests/VerifyExamples/Widget/ToggleRow0.elm b/tests/VerifyExamples/Widget/ToggleRow0.elm new file mode 100644 index 0000000..a890875 --- /dev/null +++ b/tests/VerifyExamples/Widget/ToggleRow0.elm @@ -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" + ) \ No newline at end of file diff --git a/tests/VerifyExamples/Widget/WrappedButtonRow0.elm b/tests/VerifyExamples/Widget/WrappedButtonRow0.elm new file mode 100644 index 0000000..7b7160e --- /dev/null +++ b/tests/VerifyExamples/Widget/WrappedButtonRow0.elm @@ -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" + ) \ No newline at end of file