mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-20 04:01:40 +03:00
Merge pull request #882 from NoRedInk/bat/text-and-heading
Bat/text and heading
This commit is contained in:
commit
443ade9484
8
package-lock.json
generated
8
package-lock.json
generated
@ -2469,13 +2469,13 @@
|
|||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -2484,7 +2484,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||||
"dev": true
|
"dev": true
|
||||||
}
|
}
|
||||||
@ -2933,7 +2933,7 @@
|
|||||||
},
|
},
|
||||||
"readable-stream": {
|
"readable-stream": {
|
||||||
"version": "2.3.6",
|
"version": "2.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -7,33 +7,35 @@ module Examples.Heading exposing (example, State, Msg)
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
import Category exposing (Category(..))
|
import Category exposing (Category(..))
|
||||||
import Css
|
import CommonControls
|
||||||
|
import Debug.Control as Control exposing (Control)
|
||||||
|
import Debug.Control.Extra as ControlExtra
|
||||||
|
import Debug.Control.View as ControlView
|
||||||
import Example exposing (Example)
|
import Example exposing (Example)
|
||||||
import Html.Styled as Html
|
import Html.Styled as Html
|
||||||
import Nri.Ui.Colors.V1 as Colors
|
|
||||||
import Nri.Ui.Heading.V2 as Heading
|
import Nri.Ui.Heading.V2 as Heading
|
||||||
import ViewHelpers exposing (viewExamples)
|
import ViewHelpers exposing (viewExamples)
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
moduleName : String
|
||||||
type alias State =
|
moduleName =
|
||||||
()
|
"Heading"
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
version : Int
|
||||||
type alias Msg =
|
version =
|
||||||
()
|
2
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
example : Example State Msg
|
example : Example State Msg
|
||||||
example =
|
example =
|
||||||
{ name = "Heading"
|
{ name = moduleName
|
||||||
, version = 2
|
, version = version
|
||||||
, categories = [ Text, Layout ]
|
, categories = [ Text, Layout ]
|
||||||
, keyboardSupport = []
|
, keyboardSupport = []
|
||||||
, state = ()
|
, state = init
|
||||||
, update = \_ state -> ( state, Cmd.none )
|
, update = update
|
||||||
, subscriptions = \_ -> Sub.none
|
, subscriptions = \_ -> Sub.none
|
||||||
, preview =
|
, preview =
|
||||||
[ Heading.h1 [] [ Html.text "h1" ]
|
[ Heading.h1 [] [ Html.text "h1" ]
|
||||||
@ -42,16 +44,97 @@ example =
|
|||||||
, Heading.h4 [] [ Html.text "h4" ]
|
, Heading.h4 [] [ Html.text "h4" ]
|
||||||
]
|
]
|
||||||
, view =
|
, view =
|
||||||
\_ ->
|
\state ->
|
||||||
[ viewExamples
|
let
|
||||||
[ ( "h1", Heading.h1 [] [ Html.text "This is the main page heading." ] )
|
examples =
|
||||||
, ( "h2", Heading.h2 [] [ Html.text "This is a tagline" ] )
|
[ ( "h1", Heading.h1, "This is the main page heading." )
|
||||||
, ( "h3", Heading.h3 [] [ Html.text "This is a subHeading" ] )
|
, ( "h2", Heading.h2, "This is a tagline" )
|
||||||
, ( "h4", Heading.h4 [] [ Html.text "This is a smallHeading" ] )
|
, ( "h3", Heading.h3, "This is a subHeading" )
|
||||||
|
, ( "h4", Heading.h4, "This is a smallHeading" )
|
||||||
|
, ( "h5", Heading.h5, "This is also a smallHeading" )
|
||||||
]
|
]
|
||||||
, Heading.h2 [ Heading.style Heading.Top ]
|
|
||||||
[ Html.text "Heading.h2 [ Heading.style Heading.Top ]" ]
|
attributes =
|
||||||
, Heading.h2 [ Heading.css [ Css.color Colors.highlightPurpleDark ] ]
|
List.map Tuple.second (Control.currentValue state.control)
|
||||||
[ Html.text "Heading.h2 [ Heading.css [ Css.color Colors.highlightPurpleDark ] ]" ]
|
in
|
||||||
|
[ ControlView.view
|
||||||
|
{ name = moduleName
|
||||||
|
, version = version
|
||||||
|
, update = UpdateControl
|
||||||
|
, settings = state.control
|
||||||
|
, toExampleCode =
|
||||||
|
\settings ->
|
||||||
|
let
|
||||||
|
toExampleCode ( name, _, content ) =
|
||||||
|
{ sectionName = name
|
||||||
|
, code =
|
||||||
|
moduleName
|
||||||
|
++ "."
|
||||||
|
++ name
|
||||||
|
++ "\n [ "
|
||||||
|
++ String.join "\n , " (List.map Tuple.first settings)
|
||||||
|
++ "\n ]"
|
||||||
|
++ ("\n [ Html.text \"" ++ content ++ "\" ]")
|
||||||
|
}
|
||||||
|
in
|
||||||
|
List.map toExampleCode examples
|
||||||
|
}
|
||||||
|
, examples
|
||||||
|
|> List.map
|
||||||
|
(\( name, view, content ) ->
|
||||||
|
( name, view attributes [ Html.text content ] )
|
||||||
|
)
|
||||||
|
|> viewExamples
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
|
type alias State =
|
||||||
|
{ control : Control Settings
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
init : State
|
||||||
|
init =
|
||||||
|
{ control =
|
||||||
|
ControlExtra.list
|
||||||
|
|> CommonControls.css { moduleName = moduleName, use = Heading.css }
|
||||||
|
|> ControlExtra.optionalBoolListItem "error" ( "Heading.error", Heading.error )
|
||||||
|
|> ControlExtra.optionalListItem "style" controlStyle
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
controlStyle : Control ( String, Heading.Attribute msg )
|
||||||
|
controlStyle =
|
||||||
|
[ ( "Top", Heading.Top )
|
||||||
|
, ( "Tagline", Heading.Tagline )
|
||||||
|
, ( "Subhead", Heading.Subhead )
|
||||||
|
, ( "Small", Heading.Small )
|
||||||
|
]
|
||||||
|
|> List.map
|
||||||
|
(\( name, val ) ->
|
||||||
|
( name
|
||||||
|
, Control.value
|
||||||
|
( "Heading.style Heading." ++ name
|
||||||
|
, Heading.style val
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|> Control.choice
|
||||||
|
|
||||||
|
|
||||||
|
type alias Settings =
|
||||||
|
List ( String, Heading.Attribute Msg )
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
|
type Msg
|
||||||
|
= UpdateControl (Control Settings)
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> State -> ( State, Cmd Msg )
|
||||||
|
update msg state =
|
||||||
|
case msg of
|
||||||
|
UpdateControl settings ->
|
||||||
|
( { state | control = settings }, Cmd.none )
|
||||||
|
@ -11,41 +11,76 @@ import CommonControls
|
|||||||
import Css
|
import Css
|
||||||
import Debug.Control as Control exposing (Control)
|
import Debug.Control as Control exposing (Control)
|
||||||
import Debug.Control.Extra as ControlExtra
|
import Debug.Control.Extra as ControlExtra
|
||||||
|
import Debug.Control.View as ControlView
|
||||||
import Example exposing (Example)
|
import Example exposing (Example)
|
||||||
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.Colors.V1 as Colors
|
|
||||||
import Nri.Ui.Heading.V2 as Heading
|
import Nri.Ui.Heading.V2 as Heading
|
||||||
import Nri.Ui.Text.V6 as Text
|
import Nri.Ui.Text.V6 as Text
|
||||||
|
|
||||||
|
|
||||||
|
moduleName : String
|
||||||
|
moduleName =
|
||||||
|
"Text"
|
||||||
|
|
||||||
|
|
||||||
|
version : Int
|
||||||
|
version =
|
||||||
|
6
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
example : Example State Msg
|
example : Example State Msg
|
||||||
example =
|
example =
|
||||||
{ name = "Text"
|
{ name = moduleName
|
||||||
, version = 6
|
, version = version
|
||||||
, categories = [ Text ]
|
, categories = [ Text ]
|
||||||
, keyboardSupport = []
|
, keyboardSupport = []
|
||||||
, state = init
|
, state = init
|
||||||
, update = update
|
, update = update
|
||||||
, subscriptions = \_ -> Sub.none
|
, subscriptions = \_ -> Sub.none
|
||||||
, preview =
|
, preview =
|
||||||
[ ( "caption", Text.caption )
|
[ Text.caption [ Text.plaintext "caption" ]
|
||||||
, ( "smallBody", Text.smallBody )
|
, Text.smallBody [ Text.plaintext "smallBody" ]
|
||||||
, ( "mediumBody", Text.mediumBody )
|
, Text.mediumBody [ Text.plaintext "mediumBody" ]
|
||||||
, ( "ugMediumBody", Text.ugMediumBody )
|
, Text.ugMediumBody [ Text.plaintext "ugMediumBody" ]
|
||||||
]
|
]
|
||||||
|> List.map viewPreview
|
|
||||||
, view =
|
, view =
|
||||||
\state ->
|
\state ->
|
||||||
let
|
let
|
||||||
attributes =
|
attributes =
|
||||||
Control.currentValue state.control
|
List.map Tuple.second (Control.currentValue state.control)
|
||||||
in
|
in
|
||||||
[ Text.caption [ Text.plaintext "NOTE: When using these styles, please read the documentation in the Elm module about \"Understanding spacing\"" ]
|
[ Text.caption [ Text.plaintext "NOTE: When using these styles, please read the documentation in the Elm module about \"Understanding spacing\"" ]
|
||||||
, Control.view UpdateControl state.control
|
, ControlView.view
|
||||||
|> Html.fromUnstyled
|
{ name = moduleName
|
||||||
, Heading.h2 [ Heading.style Heading.Top ] [ Html.text "Paragraph styles" ]
|
, version = version
|
||||||
|
, update = UpdateControl
|
||||||
|
, settings = state.control
|
||||||
|
, toExampleCode =
|
||||||
|
\settings ->
|
||||||
|
let
|
||||||
|
toExampleCode name =
|
||||||
|
{ sectionName = name
|
||||||
|
, code =
|
||||||
|
moduleName
|
||||||
|
++ "."
|
||||||
|
++ name
|
||||||
|
++ "\n [ "
|
||||||
|
++ String.join "\n , " (List.map Tuple.first settings)
|
||||||
|
++ "\n ]"
|
||||||
|
}
|
||||||
|
in
|
||||||
|
[ toExampleCode "mediumBody"
|
||||||
|
, toExampleCode "smallBody"
|
||||||
|
, toExampleCode "smallBodyGray"
|
||||||
|
, toExampleCode "caption"
|
||||||
|
, toExampleCode "ugMediumBody"
|
||||||
|
, toExampleCode "ugSmallBody"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
, Heading.h2 [] [ Html.text "Examples" ]
|
||||||
|
, Heading.h3 [] [ Html.text "Paragraph styles" ]
|
||||||
, viewExamples
|
, viewExamples
|
||||||
[ ( "mediumBody", Text.mediumBody )
|
[ ( "mediumBody", Text.mediumBody )
|
||||||
, ( "smallBody", Text.smallBody )
|
, ( "smallBody", Text.smallBody )
|
||||||
@ -53,7 +88,7 @@ example =
|
|||||||
, ( "caption", Text.caption )
|
, ( "caption", Text.caption )
|
||||||
]
|
]
|
||||||
attributes
|
attributes
|
||||||
, Heading.h2 [ Heading.style Heading.Top ] [ Html.text "Paragraph styles for user-authored content" ]
|
, Heading.h3 [] [ Html.text "Paragraph styles for user-authored content" ]
|
||||||
, viewExamples
|
, viewExamples
|
||||||
[ ( "ugMediumBody", Text.ugMediumBody )
|
[ ( "ugMediumBody", Text.ugMediumBody )
|
||||||
, ( "ugSmallBody", Text.ugSmallBody )
|
, ( "ugSmallBody", Text.ugSmallBody )
|
||||||
@ -63,11 +98,6 @@ example =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
viewPreview : ( String, List (Text.Attribute msg) -> Html msg ) -> Html msg
|
|
||||||
viewPreview ( name, view ) =
|
|
||||||
view [ Text.plaintext name ]
|
|
||||||
|
|
||||||
|
|
||||||
viewExamples : List ( String, List (Text.Attribute msg) -> Html msg ) -> List (Text.Attribute msg) -> Html msg
|
viewExamples : List ( String, List (Text.Attribute msg) -> Html msg ) -> List (Text.Attribute msg) -> Html msg
|
||||||
viewExamples examples attributes =
|
viewExamples examples attributes =
|
||||||
let
|
let
|
||||||
@ -85,7 +115,7 @@ viewExamples examples attributes =
|
|||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
type alias State =
|
type alias State =
|
||||||
{ control : Control (List (Text.Attribute Msg))
|
{ control : Control (List ( String, Text.Attribute Msg ))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,20 +125,13 @@ init =
|
|||||||
{ control =
|
{ control =
|
||||||
ControlExtra.list
|
ControlExtra.list
|
||||||
|> ControlExtra.listItem "content" controlContent
|
|> ControlExtra.listItem "content" controlContent
|
||||||
|> ControlExtra.listItem "noBreak"
|
|> ControlExtra.optionalBoolListItem "noBreak"
|
||||||
(Control.map Text.noBreak (Control.bool False))
|
( "Text.noBreak True", Text.noBreak True )
|
||||||
|> ControlExtra.optionalListItem "css"
|
|> CommonControls.css { moduleName = "Text", use = Text.css }
|
||||||
(Control.value
|
|
||||||
(Text.css
|
|
||||||
[ Css.border3 (Css.px 1) Css.solid Colors.aqua
|
|
||||||
, Css.color Colors.aquaDark
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
controlContent : Control (Text.Attribute msg)
|
controlContent : Control ( String, Text.Attribute msg )
|
||||||
controlContent =
|
controlContent =
|
||||||
CommonControls.content
|
CommonControls.content
|
||||||
{ moduleName = "Text"
|
{ moduleName = "Text"
|
||||||
@ -117,12 +140,11 @@ controlContent =
|
|||||||
, html = Text.html
|
, html = Text.html
|
||||||
, httpError = Nothing
|
, httpError = Nothing
|
||||||
}
|
}
|
||||||
|> Control.map Tuple.second
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
type Msg
|
type Msg
|
||||||
= UpdateControl (Control (List (Text.Attribute Msg)))
|
= UpdateControl (Control (List ( String, Text.Attribute Msg )))
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
|
Loading…
Reference in New Issue
Block a user