Fix missing label in example

This commit is contained in:
Tessa Kelly 2022-04-14 13:57:31 -07:00
parent bbd61c20d8
commit b7f33bc50c
2 changed files with 26 additions and 24 deletions

View File

@ -71,7 +71,7 @@ describe('UI tests', function () {
const skippedRules = { const skippedRules = {
'Accordion': ['heading-order', 'region'], 'Accordion': ['heading-order', 'region'],
'Balloon': ['color-contrast', 'label'], 'Balloon': ['color-contrast'],
'Checkbox': ['region'], 'Checkbox': ['region'],
'Loading': ['color-contrast'], 'Loading': ['color-contrast'],
'Menu': ['region'], 'Menu': ['region'],

View File

@ -12,7 +12,7 @@ import Debug.Control.Extra as ControlExtra
import Debug.Control.View as ControlView import Debug.Control.View as ControlView
import EllieLink import EllieLink
import Example exposing (Example) import Example exposing (Example)
import Html.Styled exposing (Html, fromUnstyled, text) import Html.Styled exposing (Html, text)
import Nri.Ui.Balloon.V1 as Balloon import Nri.Ui.Balloon.V1 as Balloon
@ -50,18 +50,27 @@ example =
{-| -} {-| -}
type alias State = type alias State =
{ copy : Control String Control Settings
, attributes : Control (List ( String, Balloon.Attribute ))
}
init : State init : State
init = init =
{ copy = Control.string "Hello, world!" controlSettings
, attributes = controlAttributes
type alias Settings =
{ copy : String
, attributes : List ( String, Balloon.Attribute )
} }
controlSettings : Control Settings
controlSettings =
Control.record Settings
|> Control.field "copy" (Control.string "Hello, world!")
|> Control.field "attributes" controlAttributes
controlAttributes : Control (List ( String, Balloon.Attribute )) controlAttributes : Control (List ( String, Balloon.Attribute ))
controlAttributes = controlAttributes =
ControlExtra.list ControlExtra.list
@ -117,20 +126,14 @@ paddingOptions =
{-| -} {-| -}
type Msg type Msg
= SetCopy (Control String) = SetAttributes (Control Settings)
| SetAttributes (Control (List ( String, Balloon.Attribute )))
update : Msg -> State -> ( State, Cmd Msg ) update : Msg -> State -> ( State, Cmd Msg )
update msg state = update msg state =
case msg of case msg of
SetCopy copy ->
( { state | copy = copy }
, Cmd.none
)
SetAttributes attributes -> SetAttributes attributes ->
( { state | attributes = attributes } ( attributes
, Cmd.none , Cmd.none
) )
@ -138,22 +141,21 @@ update msg state =
view : EllieLink.Config -> State -> List (Html Msg) view : EllieLink.Config -> State -> List (Html Msg)
view ellieLinkConfig state = view ellieLinkConfig state =
let let
copy = currentValue =
Control.currentValue state.copy Control.currentValue state
in in
[ Control.view SetCopy state.copy |> fromUnstyled [ ControlView.view
, ControlView.view
{ ellieLinkConfig = ellieLinkConfig { ellieLinkConfig = ellieLinkConfig
, name = moduleName , name = moduleName
, version = version , version = version
, update = SetAttributes , update = SetAttributes
, settings = state.attributes , settings = state
, toExampleCode = , toExampleCode =
\attrs -> \{ copy, attributes } ->
[ { sectionName = "Balloon" [ { sectionName = "Balloon"
, code = , code =
"Balloon.balloon\n [ " "Balloon.balloon\n [ "
++ String.join "\n , " (List.map Tuple.first attrs) ++ String.join "\n , " (List.map Tuple.first attributes)
++ "\n ] " ++ "\n ] "
++ "\n (text \"" ++ "\n (text \""
++ copy ++ copy
@ -162,6 +164,6 @@ view ellieLinkConfig state =
] ]
} }
, Balloon.balloon , Balloon.balloon
(List.map Tuple.second (Control.currentValue state.attributes)) (List.map Tuple.second currentValue.attributes)
(text copy) (text currentValue.copy)
] ]