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

209 lines
9.3 KiB
Elm
Raw Normal View History

2020-04-01 02:00:29 +03:00
module Examples.Colors exposing (example, State, Msg)
2018-03-17 01:58:00 +03:00
{-|
2020-04-01 02:00:29 +03:00
@docs example, State, Msg
2018-03-17 01:58:00 +03:00
-}
import Category exposing (Category(..))
2018-03-17 01:58:00 +03:00
import Css
2020-03-31 23:33:05 +03:00
import Example exposing (Example)
2018-03-17 01:58:00 +03:00
import Html.Styled as Html
import Html.Styled.Attributes as Attributes exposing (css)
import Nri.Ui.Colors.Extra
2018-03-17 01:58:00 +03:00
import Nri.Ui.Colors.V1 as Colors
2022-03-22 21:00:59 +03:00
import Nri.Ui.Fonts.V1 as Fonts
2019-12-17 22:54:35 +03:00
import Nri.Ui.Heading.V2 as Heading
2022-03-22 21:00:59 +03:00
import Nri.Ui.Text.V6 as Text
2021-05-28 04:23:27 +03:00
import SolidColor exposing (highContrast)
2018-03-17 01:58:00 +03:00
2019-12-17 23:57:47 +03:00
type alias ColorExample =
( String, Css.Color, String )
2020-04-01 02:00:29 +03:00
type alias State =
()
{-| -}
type alias Msg =
()
{-| -}
example : Example State Msg
2018-03-17 01:58:00 +03:00
example =
2020-09-09 21:43:10 +03:00
{ name = "Colors"
, version = 1
2021-11-12 01:48:31 +03:00
, categories = [ Atoms ]
, keyboardSupport = []
2020-03-31 23:33:05 +03:00
, state = ()
, update = \_ state -> ( state, Cmd.none )
, subscriptions = \_ -> Sub.none
2021-11-05 22:28:37 +03:00
, preview =
[ ( "green", Colors.green )
, ( "purple", Colors.purple )
, ( "mustard", Colors.mustard )
]
|> List.map viewPreviewSwatch
2020-03-31 23:33:05 +03:00
, view =
\ellieLinkConfig _ ->
2020-03-31 23:33:05 +03:00
[ [ ( "gray20", Colors.gray20, "Main text" )
, ( "gray45", Colors.gray45, "Secondary text, 0-69 score" )
, ( "gray75", Colors.gray75, "Border of form elements and tabs" )
2020-05-20 00:54:06 +03:00
, ( "gray85", Colors.gray85, "Alternate for divider lines and container borders" )
2020-03-31 23:33:05 +03:00
, ( "gray92", Colors.gray92, "Dvdrs/rules, incomplete assmt, inactive tabs/dsbld buttons" )
, ( "gray96", Colors.gray96, "backgrounds/alternating rows" )
, ( "navy", Colors.navy, "Headings, indented compts, labels, tooltip bckgrnds" )
, ( "azure", Colors.azure, "Buttons, other clickable stuff, links" )
, ( "azureDark", Colors.azureDark, "Azure button shadow" )
, ( "frost", Colors.frost, "Blue backgrounds pairing with Navy and Azure" )
, ( "glacier", Colors.glacier, "Blue highlights/selected elements" )
, ( "lichen", Colors.lichen, "70-79 score" )
, ( "grassland", Colors.grassland, "80-89 score" )
, ( "green", Colors.green, "90-100 score" )
, ( "greenDark", Colors.greenDark, "Green button, swathes of green" )
, ( "greenDarkest", Colors.greenDarkest, "Green text, green button shadow" )
, ( "greenLight", Colors.greenLight, "Green backgrounds" )
, ( "greenLightest", Colors.greenLightest, "Green backgrounds" )
, ( "cornflower", Colors.cornflower, "Mastery level 1" )
, ( "cornflowerDark", Colors.cornflowerDark, "Mastery level 1 text" )
, ( "cornflowerLight", Colors.cornflowerLight, "Background to pair with Cornflower elements" )
, ( "aqua", Colors.aqua, "Master level 2" )
, ( "aquaDark", Colors.aquaDark, "Text to pair with Aqua elements" )
, ( "aquaLight", Colors.aquaLight, "Background to pair with Aqua elements" )
, ( "turquoise", Colors.turquoise, "Master level 3, writing cycles" )
, ( "turquoiseDark", Colors.turquoiseDark, "Text to pair with turquoise elements" )
, ( "turquoiseLight", Colors.turquoiseLight, "Background to pair with turquoise elements" )
, ( "purple", Colors.purple, "Wrong, form errors, diagnostics, purple button" )
, ( "purpleDark", Colors.purpleDark, "Purple text, purple button shadow" )
, ( "purpleLight", Colors.purpleLight, "Purple backgrounds" )
, ( "red", Colors.red, "NoRedInk red, form warnings, practice" )
, ( "redDark", Colors.redDark, "Red links/text, red button shadow" )
, ( "redLight", Colors.redLight, "Red backgrounds" )
, ( "cyan", Colors.cyan, "Blue Highlighter" )
, ( "magenta", Colors.magenta, "Pink highlighter" )
, ( "mustard", Colors.mustard, "Diagnostic assignments, some Premium elements" )
, ( "ochre", Colors.ochre, "Practice assignments background color, some Premium elements" )
, ( "ochreDark", Colors.ochreDark, "Practice assignments text color" )
, ( "sunshine", Colors.sunshine, "Yellow highlights, tips" )
]
|> viewColors
2022-04-14 23:38:33 +03:00
, Heading.h2 [ Heading.style Heading.Subhead ] [ Html.text "Background Highlight Colors" ]
2022-03-22 21:00:59 +03:00
, Text.mediumBody [ Text.plaintext "Background highlights should be used as the default highlight style because they are more noticeable and readable. The dark colors should be used in the case where headings need to harmonize with highlighted containers, such as in Guided Drafts." ]
2020-03-31 23:33:05 +03:00
, [ ( "highlightYellow", Colors.highlightYellow, "Yellow background highlights" )
, ( "highlightYellowDark", Colors.highlightYellowDark, "Dark yellow background highlights" )
, ( "highlightCyan", Colors.highlightCyan, "Cyan background highlights" )
, ( "highlightCyanDark", Colors.highlightCyanDark, "Dark cyan background highlights" )
, ( "highlightMagenta", Colors.highlightMagenta, "Magenta background highlights" )
, ( "highlightMagentaDark", Colors.highlightMagentaDark, "Dark magenta background highlights" )
, ( "highlightGreen", Colors.highlightGreen, "Green background highlights" )
, ( "highlightGreenDark", Colors.highlightGreenDark, "Dark green background highlights" )
, ( "highlightBlue", Colors.highlightBlue, "Blue background highlights" )
, ( "highlightBlueDark", Colors.highlightBlueDark, "Dark blue background highlights" )
, ( "highlightPurple", Colors.highlightPurple, "Purple background highlights" )
, ( "highlightPurpleDark", Colors.highlightPurpleDark, "Dark purple background highlights" )
, ( "highlightBrown", Colors.highlightBrown, "Brown background highlights" )
, ( "highlightBrownDark", Colors.highlightBrownDark, "Dark brown background highlights" )
]
|> viewColors
2022-04-14 23:38:33 +03:00
, Heading.h2 [ Heading.style Heading.Subhead ] [ Html.text "Text Highlight Colors" ]
2022-03-22 21:00:59 +03:00
, Text.mediumBody [ Text.plaintext "Colors for highlighting text on a white background. These colors are readable at 14px bold and bigger." ]
2020-03-31 23:33:05 +03:00
, [ ( "textHighlightYellow", Colors.textHighlightYellow, "Neutral text highlight #1" )
, ( "textHighlightCyan", Colors.textHighlightCyan, "Neutral text highlight #2" )
, ( "textHighlightMagenta", Colors.textHighlightMagenta, "Neutral text highlight #3" )
, ( "textHighlightGreen", Colors.textHighlightGreen, "Neutral text highlight #4, Positive text highlight #1" )
, ( "textHighlightBlue", Colors.textHighlightBlue, "Neutral text highlight #5, Positive text highlight #2" )
, ( "textHighlightPurple", Colors.textHighlightPurple, "Negative text highlight #1" )
, ( "textHighlightBrown", Colors.textHighlightBrown, "Negative text highlight #2" )
]
|> viewColors
]
2018-03-17 01:58:00 +03:00
}
2021-11-05 22:28:37 +03:00
viewPreviewSwatch : ( String, Css.Color ) -> Html.Html msg
viewPreviewSwatch ( name, color ) =
Html.div
[ Attributes.css
[ Css.textAlign Css.center
, Css.padding2 (Css.px 8) Css.zero
, Css.margin2 (Css.px 4) Css.zero
, Css.borderRadius (Css.px 4)
, Css.backgroundColor color
2021-11-05 22:35:01 +03:00
, Css.color color
, Css.fontSize (Css.px 14)
2021-11-05 22:28:37 +03:00
]
]
[ Html.text name ]
2019-12-17 23:57:47 +03:00
viewColors : List ColorExample -> Html.Html msg
2019-12-17 22:54:35 +03:00
viewColors colors =
colors
|> List.map viewColor
|> Html.div
[ css
[ Css.maxWidth (Css.px 12000)
, Css.displayFlex
, Css.flexWrap Css.wrap
2022-03-22 21:00:59 +03:00
, Css.property "gap" "20px"
, Css.margin3 (Css.px 10) Css.zero (Css.px 30)
2019-12-17 22:54:35 +03:00
]
]
2019-12-17 23:57:47 +03:00
viewColor : ColorExample -> Html.Html msg
2018-03-17 01:58:00 +03:00
viewColor ( name, color, description ) =
Html.div
[ css
2018-03-17 02:14:36 +03:00
[ -- Dimensions
Css.minWidth (Css.px 250)
, Css.maxWidth (Css.px 250)
, Css.minHeight (Css.px 160)
, Css.maxHeight (Css.px 160)
2022-03-22 21:00:59 +03:00
, Css.padding (Css.px 20)
, Css.borderRadius (Css.px 20)
2018-03-17 02:14:36 +03:00
-- Interior spacing
, Css.displayFlex
, Css.flexDirection Css.column
, Css.justifyContent Css.center
, Css.alignItems Css.center
-- Colors
, Css.backgroundColor color
, Nri.Ui.Colors.Extra.fromCssColor color
|> highContrast
|> Nri.Ui.Colors.Extra.toCssColor
|> Css.color
2018-03-17 01:58:00 +03:00
]
]
2018-03-17 02:14:36 +03:00
[ Html.div
2022-03-22 21:00:59 +03:00
[ css
[ Css.fontSize (Css.px 20)
, Css.fontWeight (Css.int 700)
, Fonts.baseFont
]
2018-03-17 02:14:36 +03:00
]
[ Html.text name ]
, Html.div
[ css
2022-03-22 21:00:59 +03:00
[ Css.fontSize (Css.px 15)
2018-03-17 02:14:36 +03:00
, Css.textAlign Css.center
2022-03-22 21:00:59 +03:00
, Css.margin2 (Css.px 10) Css.zero
, Fonts.baseFont
2018-03-17 02:14:36 +03:00
]
]
[ Html.text description ]
, Html.div
[ css
[ Css.fontSize (Css.px 20)
2022-03-22 21:00:59 +03:00
, Fonts.baseFont
2018-03-17 02:14:36 +03:00
]
]
[ Html.text color.value ]
2018-03-17 01:58:00 +03:00
]