Make noBreak setting a bit more clear

This commit is contained in:
Tessa Kelly 2021-10-27 12:26:40 -07:00
parent eb506876f6
commit ccb7f01c52
2 changed files with 10 additions and 16 deletions

View File

@ -11,6 +11,7 @@ module Nri.Ui.Text.V6 exposing
- adds helpers: `custom`, `nriDescription`,`testId`,`id`
- instead of view helpers that take HTML, offer attribute helpers supporting plaintext, markdown, and html content
- :skull: remove noWidow, which is not used
- noBreak now takes a bool
## Understanding spacing
@ -88,11 +89,14 @@ buildSettings =
List.foldl (\(Attribute f) acc -> f acc) defaultSettings
{-| Text with this attribute will never wrap.
{-| Pass True to prevent text from ever wrapping.
The default Text behavior is `noBreak False`, which means content will wrap.
-}
noBreak : Attribute msg
noBreak =
Attribute (\config -> { config | noBreak = True })
noBreak : Bool -> Attribute msg
noBreak noBreak_ =
Attribute (\config -> { config | noBreak = noBreak_ })
{-| Use this helper to add custom attributes.

View File

@ -57,18 +57,6 @@ example =
[ Text.css [ Css.padding (Css.px 20) ]
, Text.plaintext "I've got more padding than my siblings!"
]
, Html.div
[ Attributes.css
[ Css.width (Css.px 80)
, Css.border3 (Css.px 1) Css.solid (Css.hex "000")
]
]
[ Text.mediumBody
[ Text.noBreak
, Text.plaintext
"I won't ever break, no matter how narrow my container is."
]
]
]
}
@ -100,6 +88,8 @@ init =
{ control =
ControlExtra.list
|> ControlExtra.listItem "content" controlContent
|> ControlExtra.listItem "noBreak"
(Control.map Text.noBreak (Control.bool False))
}