diff --git a/docs/assets/radio.png b/docs/assets/radio.png new file mode 100644 index 0000000..f216365 Binary files /dev/null and b/docs/assets/radio.png differ diff --git a/src/Widget.elm b/src/Widget.elm index 7cf60ca..33efccf 100644 --- a/src/Widget.elm +++ b/src/Widget.elm @@ -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" 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