2018-02-13 00:32:38 +03:00
|
|
|
module View exposing (view)
|
|
|
|
|
2018-12-05 01:36:15 +03:00
|
|
|
import Browser exposing (Document)
|
2018-02-13 00:32:38 +03:00
|
|
|
import Css exposing (..)
|
2018-11-13 02:38:19 +03:00
|
|
|
import Css.Global exposing (Snippet)
|
2018-06-22 12:41:38 +03:00
|
|
|
import Headings
|
2019-03-28 20:23:37 +03:00
|
|
|
import Html as RootHtml
|
|
|
|
import Html.Attributes
|
2018-10-23 19:55:30 +03:00
|
|
|
import Html.Styled as Html exposing (Html, img)
|
|
|
|
import Html.Styled.Attributes as Attributes exposing (..)
|
2018-02-13 00:32:38 +03:00
|
|
|
import Model exposing (..)
|
|
|
|
import ModuleExample as ModuleExample exposing (Category(..), ModuleExample, categoryForDisplay)
|
2018-03-17 03:16:16 +03:00
|
|
|
import Nri.Ui.Colors.V1 as Colors
|
2018-02-13 00:32:38 +03:00
|
|
|
import Nri.Ui.Css.VendorPrefixed as VendorPrefixed
|
2018-03-17 03:15:03 +03:00
|
|
|
import Nri.Ui.Fonts.V1 as Fonts
|
2018-02-13 00:32:38 +03:00
|
|
|
import NriModules as NriModules exposing (nriThemedModules)
|
|
|
|
import Routes as Routes exposing (Route)
|
|
|
|
import Update exposing (..)
|
|
|
|
|
|
|
|
|
2018-12-05 01:36:15 +03:00
|
|
|
view : Model -> Document Msg
|
2018-02-13 00:32:38 +03:00
|
|
|
view model =
|
2019-03-28 20:23:37 +03:00
|
|
|
{ title = "Style Guide"
|
2019-04-01 21:05:15 +03:00
|
|
|
, body = [ view_ model |> Html.toUnstyled ]
|
2019-03-28 20:23:37 +03:00
|
|
|
}
|
2018-12-05 01:36:15 +03:00
|
|
|
|
|
|
|
|
|
|
|
view_ : Model -> Html Msg
|
|
|
|
view_ model =
|
2018-02-13 00:32:38 +03:00
|
|
|
Html.div []
|
2018-11-13 21:19:01 +03:00
|
|
|
[ Css.Global.global layoutFixer
|
|
|
|
, Html.styled Html.div
|
2018-10-23 19:55:30 +03:00
|
|
|
[ displayFlex
|
|
|
|
, alignItems flexStart
|
|
|
|
]
|
|
|
|
[]
|
2018-02-13 00:32:38 +03:00
|
|
|
[ navigation model.route
|
2018-10-23 19:55:30 +03:00
|
|
|
, Html.styled Html.div
|
|
|
|
[ flexGrow (int 1) ]
|
|
|
|
[]
|
2018-02-13 00:32:38 +03:00
|
|
|
(case model.route of
|
|
|
|
Routes.Doodad doodad ->
|
2018-06-22 12:41:38 +03:00
|
|
|
[ Headings.h2
|
2018-10-23 19:55:30 +03:00
|
|
|
[ Html.a [ Attributes.href "#" ] [ Html.text "(see all)" ] ]
|
2018-02-13 00:32:38 +03:00
|
|
|
, nriThemedModules model.moduleStates
|
2018-12-08 01:16:00 +03:00
|
|
|
|> List.filter (\m -> m.filename == doodad)
|
2018-02-13 00:32:38 +03:00
|
|
|
|> List.map (ModuleExample.view True)
|
|
|
|
|> Html.div []
|
|
|
|
|> Html.map UpdateModuleStates
|
|
|
|
]
|
|
|
|
|
|
|
|
Routes.Category category ->
|
2018-10-23 19:55:30 +03:00
|
|
|
[ Html.styled Html.section
|
|
|
|
[ sectionStyles ]
|
|
|
|
[]
|
2018-02-13 00:32:38 +03:00
|
|
|
[ newComponentsLink
|
2019-05-03 19:30:58 +03:00
|
|
|
, Headings.h2 [ Html.text (categoryForDisplay category) ]
|
2018-02-13 00:32:38 +03:00
|
|
|
, nriThemedModules model.moduleStates
|
|
|
|
|> List.filter (\doodad -> category == doodad.category)
|
|
|
|
|> List.map (ModuleExample.view True)
|
|
|
|
|> Html.div []
|
|
|
|
|> Html.map UpdateModuleStates
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
Routes.All ->
|
2018-10-23 19:55:30 +03:00
|
|
|
[ Html.styled Html.section
|
|
|
|
[ sectionStyles ]
|
|
|
|
[]
|
2018-02-13 00:32:38 +03:00
|
|
|
[ newComponentsLink
|
2018-06-22 12:41:38 +03:00
|
|
|
, Headings.h2 [ Html.text "NRI-Themed Modules" ]
|
|
|
|
, Headings.h3 [ Html.text "All Categories" ]
|
2018-02-13 00:32:38 +03:00
|
|
|
, nriThemedModules model.moduleStates
|
|
|
|
|> List.map (ModuleExample.view True)
|
|
|
|
|> Html.div []
|
|
|
|
|> Html.map UpdateModuleStates
|
|
|
|
]
|
|
|
|
]
|
|
|
|
)
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
newComponentsLink : Html Msg
|
|
|
|
newComponentsLink =
|
|
|
|
Html.div []
|
2018-06-22 12:41:38 +03:00
|
|
|
[ Headings.h2 [ Html.text "New Styleguide Components" ]
|
2018-02-13 00:32:38 +03:00
|
|
|
, Html.div []
|
|
|
|
[ Html.text "Future styleguide components can be found in "
|
|
|
|
, Html.a [ href "https://app.zeplin.io/project/5973fb495395bdc871ebb055" ] [ Html.text "this Zepplin" ]
|
|
|
|
, Html.text "."
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
navigation : Route -> Html Msg
|
|
|
|
navigation route =
|
|
|
|
let
|
|
|
|
isActive category =
|
|
|
|
case route of
|
|
|
|
Routes.Category routeCategory ->
|
|
|
|
category == routeCategory
|
|
|
|
|
|
|
|
_ ->
|
|
|
|
False
|
|
|
|
|
|
|
|
navLink category =
|
2019-05-03 19:39:59 +03:00
|
|
|
Html.styled Html.a
|
|
|
|
[ backgroundColor transparent
|
|
|
|
, borderStyle none
|
|
|
|
, if isActive category then
|
|
|
|
color Colors.navy
|
|
|
|
|
|
|
|
else
|
|
|
|
color Colors.azure
|
|
|
|
, textDecoration none
|
|
|
|
]
|
|
|
|
[ Attributes.href <| "#category/" ++ Debug.toString category ]
|
|
|
|
[ Html.text (categoryForDisplay category) ]
|
|
|
|
|
|
|
|
allLink =
|
|
|
|
Html.styled Html.a
|
|
|
|
[ backgroundColor transparent
|
|
|
|
, borderStyle none
|
|
|
|
, if route == Routes.All then
|
|
|
|
color Colors.navy
|
|
|
|
|
|
|
|
else
|
|
|
|
color Colors.azure
|
|
|
|
, textDecoration none
|
|
|
|
]
|
|
|
|
[ Attributes.href "#" ]
|
|
|
|
[ Html.text "All" ]
|
|
|
|
|
|
|
|
toNavLi element =
|
|
|
|
Html.li
|
|
|
|
[ css
|
|
|
|
[ margin2 (px 10) zero
|
|
|
|
, listStyle none
|
|
|
|
, textDecoration none
|
2018-02-13 00:32:38 +03:00
|
|
|
]
|
|
|
|
]
|
2019-05-03 19:39:59 +03:00
|
|
|
[ element ]
|
2018-02-13 00:32:38 +03:00
|
|
|
in
|
2018-10-23 19:55:30 +03:00
|
|
|
Html.styled Html.div
|
2019-05-03 19:39:59 +03:00
|
|
|
[ flexBasis (px 200)
|
2018-10-23 19:55:30 +03:00
|
|
|
, backgroundColor Colors.gray92
|
|
|
|
, marginRight (px 40)
|
|
|
|
, padding (px 25)
|
|
|
|
, VendorPrefixed.value "position" "sticky"
|
|
|
|
, top (px 150)
|
|
|
|
, flexShrink zero
|
|
|
|
]
|
|
|
|
[]
|
2018-06-22 12:41:38 +03:00
|
|
|
[ Headings.h4
|
2018-02-13 00:32:38 +03:00
|
|
|
[ Html.text "Categories" ]
|
2019-05-03 19:39:59 +03:00
|
|
|
, (allLink
|
|
|
|
:: List.map
|
|
|
|
navLink
|
|
|
|
[ Messaging
|
|
|
|
, Animations
|
|
|
|
, Buttons
|
|
|
|
, Colors
|
|
|
|
, Pages
|
|
|
|
, Icons
|
|
|
|
, Inputs
|
|
|
|
, Modals
|
|
|
|
, Tables
|
|
|
|
, Text
|
|
|
|
, Widgets
|
2018-10-23 19:55:30 +03:00
|
|
|
]
|
2019-05-03 19:39:59 +03:00
|
|
|
)
|
|
|
|
|> List.map toNavLi
|
|
|
|
|> Html.styled Html.ul
|
|
|
|
[ margin4 zero zero (px 40) zero
|
|
|
|
, padding zero
|
2018-02-13 00:32:38 +03:00
|
|
|
]
|
2019-05-03 19:39:59 +03:00
|
|
|
[]
|
2018-02-13 00:32:38 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2018-10-23 19:55:30 +03:00
|
|
|
sectionStyles : Css.Style
|
|
|
|
sectionStyles =
|
|
|
|
Css.batch [ margin2 (px 40) zero ]
|
|
|
|
|
|
|
|
|
2018-03-01 01:18:52 +03:00
|
|
|
layoutFixer : List Snippet
|
2018-02-13 00:32:38 +03:00
|
|
|
layoutFixer =
|
|
|
|
-- TODO: remove when universal header seizes power
|
2018-11-13 02:38:19 +03:00
|
|
|
[ Css.Global.selector "#header-menu"
|
2018-02-13 00:32:38 +03:00
|
|
|
[ Css.property "float" "none"
|
|
|
|
]
|
2018-11-13 02:38:19 +03:00
|
|
|
, Css.Global.selector "#page-container"
|
2018-02-13 00:32:38 +03:00
|
|
|
[ maxWidth (px 1400)
|
|
|
|
]
|
2018-11-13 02:38:19 +03:00
|
|
|
, Css.Global.selector ".anonymous .log-in-button"
|
2018-02-13 00:32:38 +03:00
|
|
|
[ Css.property "float" "none"
|
|
|
|
, right zero
|
|
|
|
, top zero
|
|
|
|
]
|
2018-11-13 02:38:19 +03:00
|
|
|
, Css.Global.selector ".l-inline-blocks"
|
2018-02-13 00:32:38 +03:00
|
|
|
[ textAlign right
|
|
|
|
]
|
2018-11-13 02:38:19 +03:00
|
|
|
, Css.Global.everything
|
2018-11-13 21:19:01 +03:00
|
|
|
[ fontFamily inherit
|
|
|
|
]
|
|
|
|
, Css.Global.body
|
2018-02-13 00:32:38 +03:00
|
|
|
[ Fonts.baseFont
|
|
|
|
]
|
|
|
|
]
|