Here is where you an create your stylesheet.
One of the first concepts of style-elements is that layout, position, and width/height all live in your view through the Element module.
Your stylesheet handles everything else!
Check out the other Style modules for other properties.
Check out Basic.elm in the examples folder to see an example of a full stylesheet.
style-elements does away with CSS selectors entirely. Every style gets one identifier, which is ultimately rendered as a class.
Here's a basic example of a style that sets a few colors.
import Style exposing (..)
import Style.Color as Color
import Color exposing (..)
type Styles
= Button
stylesheet =
Style.stylesheet
[ style Button
[ Color.background blue
, Color.text white
]
]
-- Which can be used in your view as:
el Button [ ] (text "A button!")Styles can have variations. Here's what it looks like to have a button style with a variation for Disabled
import Style exposing (..)
import Style.Color as Color
import Color exposing (..)
type Styles = Button
stylesheet =
Style.stylesheet
[ style Button
[ Color.background blue
, variation Disabled
[ Color.background lightGrey
]
]
]
-- which can be rendered in your view as
el Button [ vary Disabled True ] (text "A Disabled button!")You can give a hint about what the padding should be for this element, but the layout can override it.
Check out the Style.Shadow module for more about shadows.
Check out the Style.Filter module for more about filters.
Apply a stack of filters. The actual filters are in Style.Filter.
import Style.Filter as Filter
import Style exposing (..)
style MyFitleredStyle
[ filters
[ Filter.blur 0.5
, Filter.invert 0.5
]
]Set the transform origin.
Units are always as pixels
Units always rendered as radians.
Use degrees or turns from the standard library if you want to use a different set of units.
Rotate around a vector.
Angle units always rendered as radians.
Use degrees or turns from the standard library if you want to use a different set of units.
Psuedo classes can be nested.
Example:
style Button
[ Color.background blue
, hover
[ Color.background red
]
]Stylesheet options
Remove style hash guards from style classes.