Style the dropdown

This commit is contained in:
Hardy Jones 2018-04-16 13:12:17 -07:00
parent 1b86ec442f
commit 199689abd0
No known key found for this signature in database
GPG Key ID: 53FEB62789F62A82
2 changed files with 34 additions and 2 deletions

View File

@ -1,24 +1,32 @@
module Nri.Ui.Dropdown.V1 module Nri.Ui.Dropdown.V1
exposing exposing
( ViewOptionEntry ( CssClasses
, ViewOptionEntry
, styles
, view , view
, viewWithoutLabel , viewWithoutLabel
) )
{-| {-|
@docs CssClasses
@docs ViewOptionEntry @docs ViewOptionEntry
@docs styles
@docs view @docs view
@docs viewWithoutLabel @docs viewWithoutLabel
-} -}
import Accessibility.Style exposing (invisible) import Accessibility.Style exposing (invisible)
import Css
import Css.Foreign
import Dict import Dict
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (on, targetValue) import Html.Events exposing (on, targetValue)
import Json.Decode import Json.Decode
import Nri.Ui.Colors.V1
import Nri.Ui.Styles.V1
import Nri.Ui.Util exposing (dashify) import Nri.Ui.Util exposing (dashify)
import String import String
@ -110,7 +118,8 @@ viewWithLabelMarkup displayLabel defaultDisplayText optionEntries onSelect =
) )
[ text defaultDisplayText ] [ text defaultDisplayText ]
, select , select
([ id identifier ([ styles.class [ Dropdown ]
, id identifier
, {- , {-
NOTE: form controls are also being styled on a global CSS that NOTE: form controls are also being styled on a global CSS that
sets a margin. sets a margin.
@ -144,3 +153,24 @@ viewOption defaultDisplayText { isSelected, val, displayText } =
, selected isSelected , selected isSelected
] ]
[ text displayText ] [ text displayText ]
{-| -}
type CssClasses
= Dropdown
{-| -}
styles : Nri.Ui.Styles.V1.Styles Never CssClasses c
styles =
Nri.Ui.Styles.V1.styles "Nri-Ui-Dropdown-V1-"
[ Css.Foreign.class Dropdown
[ Css.backgroundColor Nri.Ui.Colors.V1.white
, Css.border3 (Css.px 1) Css.solid Nri.Ui.Colors.V1.gray75
, Css.borderRadius (Css.px 8)
, Css.color Nri.Ui.Colors.V1.gray20
, Css.cursor Css.pointer
, Css.fontSize (Css.px 15)
, Css.height (Css.px 45)
]
]

View File

@ -15,6 +15,7 @@ import Html.Attributes exposing (..)
import ModuleExample exposing (Category(..), ModuleExample) import ModuleExample exposing (Category(..), ModuleExample)
import Navigation import Navigation
import Nri.Ui.AssetPath as AssetPath exposing (Asset(Asset)) import Nri.Ui.AssetPath as AssetPath exposing (Asset(Asset))
import Nri.Ui.Dropdown.V1
import Nri.Ui.Icon.V2 import Nri.Ui.Icon.V2
import Nri.Ui.SegmentedControl.V5 import Nri.Ui.SegmentedControl.V5
import Nri.Ui.Text.V1 as Text import Nri.Ui.Text.V1 as Text
@ -140,6 +141,7 @@ styles =
] ]
, (Examples.Icon.styles |> .css) () , (Examples.Icon.styles |> .css) ()
, (Examples.SegmentedControl.styles |> .css) () , (Examples.SegmentedControl.styles |> .css) ()
, (Nri.Ui.Dropdown.V1.styles |> .css) ()
, (Nri.Ui.Icon.V2.styles |> .css) () , (Nri.Ui.Icon.V2.styles |> .css) ()
, (Nri.Ui.SegmentedControl.V5.styles |> .css) () , (Nri.Ui.SegmentedControl.V5.styles |> .css) ()
, (Text.styles |> .css) () , (Text.styles |> .css) ()