2016-03-14 10:00:58 +00:00
|
|
|
module Demo.Grid where
|
|
|
|
|
2016-04-08 13:51:45 +00:00
|
|
|
|
|
|
|
import Html exposing (..)
|
|
|
|
import Array
|
|
|
|
|
2016-03-14 10:00:58 +00:00
|
|
|
import Material.Grid exposing (..)
|
2016-03-21 05:02:39 +00:00
|
|
|
import Material.Style exposing (Style, css)
|
2016-04-12 13:31:52 +00:00
|
|
|
import Material.Color as Color
|
2016-03-21 05:02:39 +00:00
|
|
|
|
2016-04-08 13:51:45 +00:00
|
|
|
import Demo.Page as Page
|
2016-03-30 19:19:06 +00:00
|
|
|
|
2016-03-14 10:00:58 +00:00
|
|
|
|
2016-03-21 05:02:39 +00:00
|
|
|
-- Cell styling
|
|
|
|
|
2016-04-08 21:05:57 +00:00
|
|
|
|
2016-03-21 05:02:39 +00:00
|
|
|
style : Int -> List Style
|
|
|
|
style h =
|
|
|
|
[ css "text-sizing" "border-box"
|
|
|
|
, css "background-color" "#BDBDBD"
|
|
|
|
, css "height" (toString h ++ "px")
|
|
|
|
, css "padding-left" "8px"
|
|
|
|
, css "padding-top" "4px"
|
|
|
|
, css "color" "white"
|
|
|
|
]
|
|
|
|
|
2016-04-08 21:05:57 +00:00
|
|
|
|
2016-03-21 05:02:39 +00:00
|
|
|
-- Cell variants
|
|
|
|
|
2016-04-08 21:05:57 +00:00
|
|
|
|
2016-03-21 05:02:39 +00:00
|
|
|
democell : Int -> List Style -> List Html -> Cell
|
|
|
|
democell k styling =
|
|
|
|
cell <| List.concat [style k, styling]
|
2016-04-08 21:05:57 +00:00
|
|
|
|
2016-03-21 05:02:39 +00:00
|
|
|
|
|
|
|
small : List Style -> List Html -> Cell
|
|
|
|
small = democell 50
|
|
|
|
|
2016-04-08 21:05:57 +00:00
|
|
|
|
2016-03-21 05:02:39 +00:00
|
|
|
std : List Style -> List Html -> Cell
|
|
|
|
std = democell 200
|
|
|
|
|
2016-04-08 21:05:57 +00:00
|
|
|
|
2016-03-21 05:02:39 +00:00
|
|
|
-- Grid
|
2016-03-14 10:00:58 +00:00
|
|
|
|
2016-04-08 21:05:57 +00:00
|
|
|
|
2016-04-08 13:51:45 +00:00
|
|
|
color : Int -> Style
|
|
|
|
color k =
|
2016-04-12 13:31:52 +00:00
|
|
|
Array.get ((k + 11) % Array.length Color.palette) Color.palette
|
2016-04-08 13:51:45 +00:00
|
|
|
|> Maybe.withDefault Color.Teal
|
|
|
|
|> flip Color.color Color.S500
|
|
|
|
|> Color.background
|
|
|
|
|
2016-04-08 21:05:57 +00:00
|
|
|
|
2016-04-08 13:51:45 +00:00
|
|
|
view : Html
|
2016-03-14 10:00:58 +00:00
|
|
|
view =
|
2016-04-08 21:05:57 +00:00
|
|
|
[ p []
|
|
|
|
[ text """Resize your browser-window and observe the effect on the Grid
|
|
|
|
below. Note in particular what happens to the top and bottom rows."""
|
|
|
|
]
|
|
|
|
, [1..12 ]
|
2016-04-12 13:31:52 +00:00
|
|
|
|> List.map (\i -> small [size All 1, color 4] [text "1"])
|
2016-03-19 22:47:21 +00:00
|
|
|
|> grid []
|
2016-03-14 10:00:58 +00:00
|
|
|
, [1 .. 3]
|
2016-04-12 13:31:52 +00:00
|
|
|
|> List.map (\i -> std [size All 4, color 5] [text <| "4"])
|
2016-03-19 22:47:21 +00:00
|
|
|
|> grid []
|
2016-04-12 13:31:52 +00:00
|
|
|
, [ std [size All 6, color 6] [text "6"]
|
|
|
|
, std [size All 4, color 6] [text "4"]
|
|
|
|
, std [size All 2, color 6] [text "2"]
|
2016-03-19 22:47:21 +00:00
|
|
|
] |> grid []
|
2016-04-12 13:31:52 +00:00
|
|
|
, [ std [size All 6, size Tablet 8, color 7] [text "6 (8 tablet)"]
|
|
|
|
, std [size All 4, size Tablet 6, color 8] [text "4 (6 tablet)"]
|
|
|
|
, std [size All 2, size Phone 4, color 9] [text "2 (4 phone)"]
|
2016-03-19 22:47:21 +00:00
|
|
|
] |> grid []
|
2016-03-14 10:00:58 +00:00
|
|
|
]
|
2016-04-08 13:51:45 +00:00
|
|
|
|> Page.body "Grid" srcUrl intro references
|
2016-03-19 22:47:21 +00:00
|
|
|
|
|
|
|
|
2016-03-30 19:19:06 +00:00
|
|
|
intro : Html
|
2016-04-08 13:51:45 +00:00
|
|
|
intro =
|
|
|
|
Page.fromMDL "http://www.getmdl.io/components/#layout-section/grid" """
|
2016-03-30 19:19:06 +00:00
|
|
|
> The Material Design Lite (MDL) grid component is a simplified method for laying
|
|
|
|
> out content for multiple screen sizes. It reduces the usual coding burden
|
|
|
|
> required to correctly display blocks of content in a variety of display
|
|
|
|
> conditions.
|
|
|
|
>
|
|
|
|
> The MDL grid is defined and enclosed by a container element. A grid has 12
|
|
|
|
> columns in the desktop screen size, 8 in the tablet size, and 4 in the phone
|
|
|
|
> size, each size having predefined margins and gutters. Cells are laid out
|
|
|
|
> sequentially in a row, in the order they are defined, with some exceptions:
|
|
|
|
>
|
|
|
|
> - If a cell doesn't fit in the row in one of the screen sizes, it flows
|
|
|
|
> into the following line.
|
|
|
|
> - If a cell has a specified column size equal to or larger than the number
|
|
|
|
> of columns for the current screen size, it takes up the entirety of its
|
|
|
|
> row.
|
2016-04-08 13:51:45 +00:00
|
|
|
"""
|
2016-03-30 19:19:06 +00:00
|
|
|
|
2016-04-08 13:51:45 +00:00
|
|
|
srcUrl : String
|
|
|
|
srcUrl =
|
|
|
|
"https://github.com/debois/elm-mdl/blob/master/examples/Demo/Grid.elm"
|
2016-03-30 19:19:06 +00:00
|
|
|
|
2016-04-08 13:51:45 +00:00
|
|
|
references : List (String, String)
|
|
|
|
references =
|
|
|
|
[ Page.package "http://package.elm-lang.org/packages/debois/elm-mdl/latest/Material-Grid"
|
|
|
|
, Page.mds "https://www.google.com/design/spec/layout/responsive-ui.html#responsive-ui-grid"
|
|
|
|
, Page.mdl "http://www.getmdl.io/components/#layout-section/grid"
|
|
|
|
]
|