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

161 lines
7.7 KiB
Elm
Raw Normal View History

2018-03-17 01:58:00 +03:00
module Examples.Colors exposing (example)
{-|
@docs example
-}
import Color exposing (highContrast)
2018-03-17 01:58:00 +03:00
import Css
import Html.Styled as Html
import Html.Styled.Attributes as Attributes exposing (css)
import ModuleExample as ModuleExample exposing (Category(..), ModuleExample)
import Nri.Ui.Colors.Extra
2018-03-17 01:58:00 +03:00
import Nri.Ui.Colors.V1 as Colors
2019-12-17 22:54:35 +03:00
import Nri.Ui.Heading.V2 as Heading
2018-03-17 01:58:00 +03:00
2019-12-17 23:57:47 +03:00
type alias ColorExample =
( String, Css.Color, String )
2018-03-17 01:58:00 +03:00
example : ModuleExample msg
example =
2019-05-03 19:56:43 +03:00
{ name = "Nri.Ui.Colors.V1"
2018-03-17 01:58:00 +03:00
, category = Colors
, content =
[ [ ( "gray20", Colors.gray20, "Main text" )
, ( "gray45", Colors.gray45, "Secondary text, 0-69 score" )
, ( "gray75", Colors.gray75, "Border of form elements and tabs" )
, ( "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, "Practice assignments, some Premium elements" )
2019-12-14 03:15:25 +03:00
, ( "ochre", Colors.ochre, "Practice assignments background color, some Premium elements" )
, ( "ochreDark", Colors.ochreDark, "Practice assignments text color" )
2018-03-17 01:58:00 +03:00
, ( "sunshine", Colors.sunshine, "Yellow highlights, tips" )
2019-12-17 22:54:35 +03:00
]
|> viewColors
, Heading.h3 [] [ Html.text "Background Highlight Colors" ]
, Html.p [] [ Html.text "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." ]
, [ ( "highlightYellow", Colors.highlightYellow, "Yellow background highlights" )
2019-01-03 17:00:46 +03:00
, ( "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" )
2018-03-17 01:58:00 +03:00
]
2019-12-17 22:54:35 +03:00
|> viewColors
, Heading.h3 [] [ Html.text "Text Highlight Colors" ]
, Html.p [] [ Html.text "Colors for highlighting text on a white background. These colors are readable at 14px bold and bigger." ]
, [ ( "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
]
}
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
]
]
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)
2018-03-17 01:58:00 +03:00
, Css.margin (Css.px 4)
, Css.padding (Css.px 8)
2018-03-17 02:14:36 +03:00
, Css.borderRadius (Css.px 4)
-- 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
[ css [ Css.fontSize (Css.px 20) ]
]
[ Html.text name ]
, Html.div
[ css
[ Css.fontSize (Css.px 10)
, Css.flexGrow (Css.num 1)
, Css.textAlign Css.center
]
]
[ Html.text description ]
, Html.div
[ css
[ Css.fontSize (Css.px 20)
, Css.flexGrow (Css.num 2)
]
]
[ Html.text color.value ]
2018-03-17 01:58:00 +03:00
]