mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-19 19:51:37 +03:00
Begin adding checkboxes
This commit is contained in:
parent
417577cb84
commit
c7ff0aba90
@ -1,15 +1,29 @@
|
|||||||
module Examples.IconExamples exposing (preview, view, viewWithCustomStyles)
|
module Examples.IconExamples exposing
|
||||||
|
( preview
|
||||||
|
, viewSettings
|
||||||
|
, view, viewWithCustomStyles
|
||||||
|
)
|
||||||
|
|
||||||
|
{-|
|
||||||
|
|
||||||
|
@docs preview
|
||||||
|
@docs viewSettings
|
||||||
|
@docs view, viewWithCustomStyles
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
import Css
|
import Css
|
||||||
import Css.Global
|
import Css.Global
|
||||||
import Html.Styled as Html exposing (Html)
|
import Html.Styled as Html exposing (Html)
|
||||||
import Html.Styled.Attributes exposing (css)
|
import Html.Styled.Attributes exposing (css)
|
||||||
|
import Nri.Ui.Checkbox.V5 as Checkbox
|
||||||
import Nri.Ui.Colors.V1 as Colors
|
import Nri.Ui.Colors.V1 as Colors
|
||||||
import Nri.Ui.Heading.V2 as Heading
|
import Nri.Ui.Heading.V2 as Heading
|
||||||
import Nri.Ui.Svg.V1 as Svg
|
import Nri.Ui.Svg.V1 as Svg
|
||||||
import Nri.Ui.Text.V6 as Text
|
import Nri.Ui.Text.V6 as Text
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
preview : List Svg.Svg -> List (Html msg)
|
preview : List Svg.Svg -> List (Html msg)
|
||||||
preview icons =
|
preview icons =
|
||||||
[ Html.div
|
[ Html.div
|
||||||
@ -27,6 +41,19 @@ preview icons =
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
|
viewSettings : (Bool -> msg) -> Bool -> Html msg
|
||||||
|
viewSettings toggle showIconName =
|
||||||
|
Checkbox.viewWithLabel
|
||||||
|
{ identifier = "show-icon-name-checkbox"
|
||||||
|
, label = "Show names"
|
||||||
|
, setterMsg = toggle
|
||||||
|
, selected = Checkbox.selectedFromBool showIconName
|
||||||
|
, disabled = False
|
||||||
|
, theme = Checkbox.Square
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
view : Bool -> String -> List ( String, Svg.Svg ) -> Html msg
|
view : Bool -> String -> List ( String, Svg.Svg ) -> Html msg
|
||||||
view showIconName headerText icons =
|
view showIconName headerText icons =
|
||||||
|
@ -12,16 +12,6 @@ import Examples.IconExamples as IconExamples
|
|||||||
import Nri.Ui.UiIcon.V1 as UiIcon
|
import Nri.Ui.UiIcon.V1 as UiIcon
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
type alias State =
|
|
||||||
{ showIconName : Bool }
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
type alias Msg =
|
|
||||||
()
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
example : Example State Msg
|
example : Example State Msg
|
||||||
example =
|
example =
|
||||||
@ -30,7 +20,7 @@ example =
|
|||||||
, categories = List.singleton Icons
|
, categories = List.singleton Icons
|
||||||
, keyboardSupport = []
|
, keyboardSupport = []
|
||||||
, state = { showIconName = False }
|
, state = { showIconName = False }
|
||||||
, update = \_ state -> ( state, Cmd.none )
|
, update = update
|
||||||
, subscriptions = \_ -> Sub.none
|
, subscriptions = \_ -> Sub.none
|
||||||
, preview =
|
, preview =
|
||||||
IconExamples.preview
|
IconExamples.preview
|
||||||
@ -53,7 +43,8 @@ example =
|
|||||||
viewExampleSection =
|
viewExampleSection =
|
||||||
IconExamples.view showIconName
|
IconExamples.view showIconName
|
||||||
in
|
in
|
||||||
[ viewExampleSection "Interface"
|
[ IconExamples.viewSettings UpdateSettings showIconName
|
||||||
|
, viewExampleSection "Interface"
|
||||||
[ ( "seeMore", UiIcon.seeMore )
|
[ ( "seeMore", UiIcon.seeMore )
|
||||||
, ( "openClose", UiIcon.openClose )
|
, ( "openClose", UiIcon.openClose )
|
||||||
, ( "download", UiIcon.download )
|
, ( "download", UiIcon.download )
|
||||||
@ -185,3 +176,22 @@ example =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
|
type alias State =
|
||||||
|
{ showIconName : Bool }
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
|
type Msg
|
||||||
|
= UpdateSettings Bool
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> State -> ( State, Cmd Msg )
|
||||||
|
update msg state =
|
||||||
|
case msg of
|
||||||
|
UpdateSettings showIconName ->
|
||||||
|
( { state | showIconName = showIconName }
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user