clay-0.16.0: CSS preprocessor as embedded Haskell.
Safe HaskellNone
LanguageHaskell2010

Clay.Grid

Description

Partial implementation of | grid area CSS API.

Synopsis

Grid

grid-gap and grid-template CSS properties.

Example

For the below CSS code:

.grid1 {
  display: grid;
  width: max-content;
}

.grid3 {
  display: grid;
  width: max-content;
}

@media (min-width: 40.0rem) {
  .grid3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-gap: 1rem;
    width: max-content;
  }
}

The corresponding clay code is:

 ".grid1" ? do
   display grid
   width maxContent
 ".grid3" ? do
   display grid
   width maxContent
 query M.screen [M.minWidth (rem 40)] $ ".grid3" ? do
   display grid
   gridTemplateColumns [fr 1, fr 1, fr 1]
   gridGap $ rem 1
   width maxContent

gridGap :: Size a -> Css Source #

Property sets the gaps (gutters) between rows and columns.

gridTemplateColumns :: [Size a] -> Css Source #

Property defines the line names and track sizing functions of the grid columns.

Size and location

CSS documentation

The below functions are based on MDN Web Docs CSS documentation.

Naming note

Expand

In this documentation, as the functions are polymorphic we sometimes refer to the CSS types as used in the mdm web docs_ rather than the Haskell types. For example, grid-line is used instead of GridLine as a the argument might be provided as a GridLine but also as an Integer, String, etc.

Pragma

If you want to avoid specifying the types of the arguments, enable the ExtendedDefaultRules GHC language pragma as well as the -Wno-type-defaults GHC option to avoid compilation warnings.

{-# LANGUAGE ExtendedDefaultRules #-}
{-# OPTIONS_GHC -Wno-type-defaults #-}

Examples

Expand

With the above enabled, you can write:

> gridRowStart 2
> gridRowStart "somegridarea"

If you do not enable those, then you must write:

> gridRowStart (2 :: Integer)
> gridRowStart ("somegridarea" :: String)

Note

Expand

If you decide to enable the above, it is advisable to have your Clay CSS code in its own module, so the behaviour of the rest of your code is not affected.

Examples

Examples are provided through the documentation for the various functions. Further examples can be found in the source code of the test suite in the GridSpec.hs module.

Data types and type classes

data GridLine Source #

A grid-line value.

A grid-line value specifies a size and location in a grid.

Note

Expand

To know more about grid-line value, see for example the documentation of the grid-row-start CSS property.

Instances

Instances details
Show GridLine Source # 
Instance details

Defined in Clay.Grid

Auto GridLine Source #

Keyword indicating that the property contributes nothing to the grid item's placement.

Instance details

Defined in Clay.Grid

Methods

auto :: GridLine Source #

Inherit GridLine Source #

Keyword inherit applied to a GridLine.

Instance details

Defined in Clay.Grid

Initial GridLine Source #

Keyword initial applied to a GridLine.

Instance details

Defined in Clay.Grid

Unset GridLine Source #

Keyword unset applied to a GridLine.

Instance details

Defined in Clay.Grid

ToGridLine GridLine Source # 
Instance details

Defined in Clay.Grid

ToGridLines2 GridLine Source #

One grid-line value.

Instance details

Defined in Clay.Grid

ToGridLines4 GridLine Source #

One grid-line value.

Instance details

Defined in Clay.Grid

Val GridLine Source #

Convertion of GridLine to Value.

Instance details

Defined in Clay.Grid

Methods

value :: GridLine -> Value Source #

Eq GridLine Source # 
Instance details

Defined in Clay.Grid

class ToGridLine a Source #

Minimal complete definition

toGridLine

Instances

Instances details
ToGridLine CustomIdentGrid Source #

custom-ident value.

Instance details

Defined in Clay.Grid

ToGridLine GridLine Source # 
Instance details

Defined in Clay.Grid

ToGridLine String Source #

custom-ident value.

Instance details

Defined in Clay.Grid

ToGridLine Integer Source # 
Instance details

Defined in Clay.Grid

ToGridLine (CustomIdentGrid, Integer) Source #

Both custom-ident and Integer values, provided as a pair.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

ToGridLine (String, Integer) Source #

Both custom-ident and Integer values, provided as a pair.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

data GridLines2 Source #

One or two grid-line values.

Instances

Instances details
ToGridLines2 GridLines2 Source #

One or two grid-line values.

Instance details

Defined in Clay.Grid

Val GridLines2 Source # 
Instance details

Defined in Clay.Grid

class ToGridLines2 a Source #

Minimal complete definition

toGridLines2

Instances

Instances details
ToGridLines2 CustomIdentGrid Source #

One custom-ident value.

Instance details

Defined in Clay.Grid

ToGridLines2 GridLine Source #

One grid-line value.

Instance details

Defined in Clay.Grid

ToGridLines2 GridLines2 Source #

One or two grid-line values.

Instance details

Defined in Clay.Grid

ToGridLines2 OneGridLine Source #

One grid-line value.

Instance details

Defined in Clay.Grid

ToGridLines2 TwoGridLines Source #

Two grid-line values.

Instance details

Defined in Clay.Grid

ToGridLines2 String Source #

One custom-ident value.

Instance details

Defined in Clay.Grid

ToGridLines2 Integer Source #

One Integer value.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

ToGridLines2 (CustomIdentGrid, Integer) Source #

One time both a custom-ident and Integer values, provided as a pair.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

ToGridLines2 (String, Integer) Source #

One time both a custom-ident and Integer values, provided as a pair.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

data GridLines4 Source #

One, two, three or four grid-line values.

Instances

Instances details
ToGridLines4 GridLines4 Source #

One, two, three or four grid-line values.

Instance details

Defined in Clay.Grid

Val GridLines4 Source # 
Instance details

Defined in Clay.Grid

class ToGridLines4 a Source #

Minimal complete definition

toGridLines4

Instances

Instances details
ToGridLines4 CustomIdentGrid Source #

One custom-ident value.

Instance details

Defined in Clay.Grid

ToGridLines4 FourGridLines Source #

Four grid-line values.

Instance details

Defined in Clay.Grid

ToGridLines4 GridLine Source #

One grid-line value.

Instance details

Defined in Clay.Grid

ToGridLines4 GridLines4 Source #

One, two, three or four grid-line values.

Instance details

Defined in Clay.Grid

ToGridLines4 OneGridLine Source #

One grid-line value.

Instance details

Defined in Clay.Grid

ToGridLines4 ThreeGridLines Source #

Three grid-line values.

Instance details

Defined in Clay.Grid

ToGridLines4 TwoGridLines Source #

Two grid-line values.

Instance details

Defined in Clay.Grid

ToGridLines4 String Source #

One custom-ident value.

Instance details

Defined in Clay.Grid

ToGridLines4 Integer Source #

One Integer value.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

ToGridLines4 (CustomIdentGrid, Integer) Source #

One time both a custom-ident and Integer values, provided as a pair.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

ToGridLines4 (String, Integer) Source #

One time both a custom-ident and Integer values, provided as a pair.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

data OneGridLine Source #

One GridLine value.

Instances

Instances details
ToGridLines2 OneGridLine Source #

One grid-line value.

Instance details

Defined in Clay.Grid

ToGridLines4 OneGridLine Source #

One grid-line value.

Instance details

Defined in Clay.Grid

Val OneGridLine Source # 
Instance details

Defined in Clay.Grid

data TwoGridLines Source #

Two GridLine values.

Instances

Instances details
ToGridLines2 TwoGridLines Source #

Two grid-line values.

Instance details

Defined in Clay.Grid

ToGridLines4 TwoGridLines Source #

Two grid-line values.

Instance details

Defined in Clay.Grid

Val TwoGridLines Source # 
Instance details

Defined in Clay.Grid

data ThreeGridLines Source #

Three GridLine values.

Instances

Instances details
ToGridLines4 ThreeGridLines Source #

Three grid-line values.

Instance details

Defined in Clay.Grid

Val ThreeGridLines Source # 
Instance details

Defined in Clay.Grid

data FourGridLines Source #

Four GridLine values.

Instances

Instances details
ToGridLines4 FourGridLines Source #

Four grid-line values.

Instance details

Defined in Clay.Grid

Val FourGridLines Source # 
Instance details

Defined in Clay.Grid

data CustomIdentGrid Source #

CSS custom-ident.

The data constructor is not exported. Use the partialMkCustomIdentGrid smart constructor to create a CustomIdentGrid.

Note

Expand

In CSS, some values for custom-ident are invalid depending on the CSS property the custom-ident is used with. Consequently, the custom-ident is only for CSS grid.

Instances

Instances details
Read CustomIdentGrid Source # 
Instance details

Defined in Clay.Grid

Show CustomIdentGrid Source # 
Instance details

Defined in Clay.Grid

ToGridLine CustomIdentGrid Source #

custom-ident value.

Instance details

Defined in Clay.Grid

ToGridLines2 CustomIdentGrid Source #

One custom-ident value.

Instance details

Defined in Clay.Grid

ToGridLines4 CustomIdentGrid Source #

One custom-ident value.

Instance details

Defined in Clay.Grid

Eq CustomIdentGrid Source # 
Instance details

Defined in Clay.Grid

Ord CustomIdentGrid Source # 
Instance details

Defined in Clay.Grid

ToGridLine (CustomIdentGrid, Integer) Source #

Both custom-ident and Integer values, provided as a pair.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

ToGridLines2 (CustomIdentGrid, Integer) Source #

One time both a custom-ident and Integer values, provided as a pair.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

ToGridLines4 (CustomIdentGrid, Integer) Source #

One time both a custom-ident and Integer values, provided as a pair.

NOTE: Integer value of 0 is invalid.

Instance details

Defined in Clay.Grid

customIdentToText :: CustomIdentGrid -> Text Source #

Convert a CustomIdentGrid to Text.

Note

Expand

The function is defined on its own as the newtype constructor of CustomIdentGridis not exported.

partialMkCustomIdentGrid :: Text -> CustomIdentGrid Source #

Create a CustomIdentGrid.

WARNING: this function is partial. An error will be raised if:

  • "span" is provided as a value (this is a reserved keyword in this context)
  • a number is provided as first character
  • If a hyphen (-) is provided as first character:

    • * a number is provided as second character
    • * a hyphen (-) is provided as second character.

Note

Expand

The above is a partial implementation of the CSS custom-ident naming rules. If you stick to the following charset [a-zA-z0-9-_] the checks will be effective and your CSS custom-ident will be a valid one. On the other hand, the following will not be checked:

  • character escaping (for example ?) or unicode
  • characters provided as hexadecimal number (for example 0x03BB)
  • characters outside of the above charset.

More information regarding this topic can be found on mdm web docs_

class ToSpan a Source #

Minimal complete definition

span_

Instances

Instances details
ToSpan String Source #

One line from the provided name is counted.

Instance details

Defined in Clay.Grid

ToSpan Integer Source #

Contributes the nth grid line to the grid item's placement.

NOTE: negative Integer or 0 values are invalid.

Instance details

Defined in Clay.Grid

ToSpan (String, Integer) Source #

Nth lines from the provided name are counted.

NOTE: negative Integer or 0 values are invalid.

Instance details

Defined in Clay.Grid

Style properties

The below functions are partial. They will raise an error if provided with a grid-line value which is:

gridArea :: ToGridLines4 a => a -> Css Source #

Property shorthand specifies a grid item's size and location within a grid.

One to four grid-line values can be specified. Grid-line values must be separated by a (//) operator.

WARNING: this function is partial. See above Clay.Grid.

Examples

Expand

The below examples assume that the ExtendedDefaultRules GHC language pragma is enabled. See above Clay.Grid.

gridArea (auto :: GridLine)
gridArea "somegridarea"
gridArea $ ("somegridarea", 4) // ("someothergridarea", 2)
gridArea $ 1 // 3 // 4

gridColumn :: ToGridLines2 a => a -> Css Source #

Property shorthand specifies a grid item's size and location within a grid column.

WARNING: this function is partial. See above Clay.Grid.

Examples

Expand

The below examples assume that the ExtendedDefaultRules GHC language pragma is enabled. See above Clay.Grid.

gridColumn (auto :: GridLine)
gridColumn $ span_ 3
gridColumn $ span_ ("somegridarea", 5)
gridColumn $ span_ 3 // 6

gridColumnStart :: ToGridLine a => a -> Css Source #

Property specifies a grid item's start position within the grid column.

WARNING: this function is partial. See above Clay.Grid.

Examples

Expand

The below examples assume that the ExtendedDefaultRules GHC language pragma is enabled. See above Clay.Grid.

gridColumnStart (inherit :: GridLine)
gridColumnStart 2
gridColumnStart ("somegridarea", 4)
gridColumnStart $ span_ ("somegridarea", 5)

gridColumnEnd :: ToGridLine a => a -> Css Source #

Property specifies a grid item's end position within the grid column.

WARNING: this function is partial. See above Clay.Grid.

Examples

Expand

The below examples assume that the ExtendedDefaultRules GHC language pragma is enabled. See above Clay.Grid.

gridColumnEnd (initial :: GridLine)
gridColumnEnd 2
gridColumnEnd "somegridarea"
gridColumnEnd $ span_ "somegridarea"

gridRow :: ToGridLines2 a => a -> Css Source #

Property shorthand specifies a grid item's size and location within a grid row.

One or two grid-line values can be specified. grid-line values must be separated by a (//) operator.

WARNING: this function is partial. See above Clay.Grid.

Examples

Expand

The below examples assume that the ExtendedDefaultRules GHC language pragma is enabled. See above Clay.Grid.

gridRow (unset :: GridLine)
gridRow $ span_ 3
gridRow $ span_ 3 // 6
gridRow $ span_ ("somegridarea", 5) // span_ 2

gridRowStart :: ToGridLine a => a -> Css Source #

Property specifies a grid item's start position within the grid row.

WARNING: this function is partial. See above Clay.Grid.

Examples

Expand

The below examples assume that the ExtendedDefaultRules GHC language pragma is enabled. See above Clay.Grid.

gridRowStart (initial :: GridLine)
gridRowStart (-2)
gridRowStart $ span_ "somegridarea"
gridRowStart "somegridarea"

gridRowEnd :: ToGridLine a => a -> Css Source #

Property specifies a grid item's end position within the grid row.

WARNING: this function is partial. See above Clay.Grid.

Examples

Expand

The below examples assume that the ExtendedDefaultRules GHC language pragma is enabled. See above Clay.Grid.

gridRowEnd (auto :: GridLine)
gridRowEnd (-2)
gridRowEnd ("somegridarea", 4)
gridRowEnd $ span_ 3

Keywords

(//) :: (Slash a r, ToGridLine b) => a -> b -> r Source #

/ CSS operator. Separates grid-line values.

span_ :: ToSpan a => a -> GridLine Source #

span CSS keyword, contributes to the grid item's placement.