noredink-ui/styleguide-app/Examples/ClickableSvg.elm

124 lines
4.2 KiB
Elm
Raw Normal View History

2020-03-31 22:43:32 +03:00
module Examples.ClickableSvg exposing (Msg, State, example)
2020-03-09 19:38:16 +03:00
{-|
2020-03-31 22:43:32 +03:00
@docs Msg, State, example
2020-03-09 19:38:16 +03:00
-}
import Category exposing (Category(..))
2020-03-09 19:38:16 +03:00
import Color exposing (Color)
import Css
2020-03-31 23:20:03 +03:00
import Example exposing (Example)
2020-03-09 19:38:16 +03:00
import Examples.IconExamples as IconExamples
import Html.Styled as Html
import Html.Styled.Attributes as Attributes
import Html.Styled.Events as Events
import Nri.Ui.ClickableSvg.V1 as ClickableSvg
import Nri.Ui.Colors.Extra exposing (fromCssColor, toCssColor)
import Nri.Ui.Colors.V1 as Colors
import Nri.Ui.Heading.V2 as Heading
import Nri.Ui.Select.V6 as Select
import Nri.Ui.Svg.V1 as Svg
import Nri.Ui.UiIcon.V1 as UiIcon
{-| -}
2020-03-31 23:20:03 +03:00
example : Example State Msg
2020-03-31 22:43:32 +03:00
example =
2020-03-09 19:38:16 +03:00
{ name = "Nri.Ui.ClickableSvg.V1"
2020-03-31 22:43:32 +03:00
, categories = [ Buttons, Icons ]
, state = init
, update = update
2020-03-31 22:48:26 +03:00
, subscriptions = \_ -> Sub.none
2020-03-31 22:43:32 +03:00
, view =
\state ->
[ Html.div [ Attributes.css [ Css.displayFlex, Css.alignItems Css.center ] ]
[ ClickableSvg.button "Back"
UiIcon.arrowLeft
[ ClickableSvg.onClick (ShowItWorked "You clicked the back button!") ]
, viewCode
"ClickableSvg.button \"Back\" UiIcon.arrowLeft [ ClickableSvg.onClick OnClickMsg ]"
2020-03-09 21:05:28 +03:00
]
2020-03-31 22:43:32 +03:00
, Html.div [ Attributes.css [ Css.displayFlex, Css.alignItems Css.center ] ]
[ ClickableSvg.link "Back" UiIcon.arrowLeft [ ClickableSvg.linkSpa "some_link" ]
, viewCode
"ClickableSvg.link \"Back\" UiIcon.arrowLeft [ ClickableSvg.linkSpa \"some_link\" ]"
]
, Html.div [ Attributes.css [ Css.displayFlex, Css.alignItems Css.center ] ]
[ ClickableSvg.button "Disabled" UiIcon.arrowLeft [ ClickableSvg.disabled True ]
, viewCode
"ClickableSvg.button \"Disabled\" UiIcon.arrowLeft [ ClickableSvg.disabled True ]"
]
, Html.div [ Attributes.css [ Css.displayFlex, Css.alignItems Css.center ] ]
[ ClickableSvg.link "Disabled" UiIcon.arrowLeft [ ClickableSvg.disabled True ]
, viewCode
"ClickableSvg.link \"Disabled\" UiIcon.arrowLeft [ ClickableSvg.disabled True ]"
]
, Html.div [ Attributes.css [ Css.displayFlex, Css.alignItems Css.center ] ]
[ ClickableSvg.button "Go to tutorial"
UiIcon.footsteps
[ ClickableSvg.width (Css.px 80)
, ClickableSvg.height (Css.px 80)
, ClickableSvg.onClick (ShowItWorked "You clicked the tutorials button!")
, ClickableSvg.custom [ Attributes.id "clickable-svg-customized-example-id" ]
, ClickableSvg.css
[ Css.border3 (Css.px 3) Css.dashed Colors.purple
]
]
, viewCode
"""
2020-03-09 21:05:28 +03:00
ClickableSvg.button "Go to tutorial"
UiIcon.footsteps
[ ClickableSvg.width (Css.px 80)
, ClickableSvg.height (Css.px 80)
2020-03-31 22:43:32 +03:00
, ClickableSvg.onClick (ShowItWorked "You clicked the tutorials button!")
2020-03-09 21:05:28 +03:00
, ClickableSvg.custom [ Attributes.id "clickable-svg-customized-example-id" ]
, ClickableSvg.css
[ Css.border3 (Css.px 3) Css.dashed Colors.purple
]
]
"""
2020-03-31 22:43:32 +03:00
]
2020-03-09 21:05:28 +03:00
]
2020-03-09 19:38:16 +03:00
}
2020-03-09 20:55:43 +03:00
viewCode : String -> Html.Html msg
viewCode renderStrategy =
2020-03-09 20:50:00 +03:00
Html.code
2020-03-09 19:38:16 +03:00
[ Attributes.css
[ Css.width (Css.px 400)
, Css.marginRight (Css.px 20)
2020-03-09 19:38:16 +03:00
]
]
2020-03-09 20:55:43 +03:00
[ Html.pre [] [ Html.text renderStrategy ] ]
2020-03-09 19:38:16 +03:00
{-| -}
type alias State =
{}
2020-03-09 19:38:16 +03:00
{-| -}
init : State
init =
{}
2020-03-09 19:38:16 +03:00
{-| -}
type Msg
2020-03-31 22:43:32 +03:00
= ShowItWorked String
2020-03-09 19:38:16 +03:00
{-| -}
update : Msg -> State -> ( State, Cmd Msg )
update msg state =
2020-03-31 22:43:32 +03:00
case msg of
ShowItWorked message ->
let
_ =
Debug.log "ClickableSvg" message
in
( state, Cmd.none )