sketch

Types

Strategy for the StyleSheet. Two strategies are available as of now: ephemeral and persistent. In the first case, the stylesheet is throwable, and it is not expected to be persisted across renders. A class name is always generated according to its content. Two classes with the exact same properties will always have the exact same name.
The second case is designed to be persisted across renders, and uses an actor to save its content on the BEAM.

pub type Strategy {
  Ephemeral
  Persistent
}

Constructors

  • Ephemeral
  • Persistent

Manages the styles. Can be instanciated with stylesheet.

pub opaque type StyleSheet

Functions

pub fn at_rule(
  rule: AtRule,
  stylesheet: StyleSheet,
) -> StyleSheet

Pushes an @rule in the StyleSheet, to get it bundled in the outputted CSS. It returns the StyleSheet with the rule added.

pub fn class_name(
  class: Class,
  stylesheet: StyleSheet,
) -> #(StyleSheet, String)

Converts a Class to its class name, to use it anywhere in your application. It always returns the StyleSheet, because the class can have been pushed in the StyleSheet itself.

pub fn render(cache: StyleSheet) -> String

Render the content in the stylesheet in proper CSS stylesheet.

pub fn stylesheet(
  strategy strategy: Strategy,
) -> Result(StyleSheet, SketchError)

Create a cache, managing the styles. You can instanciate as much cache as you want, if you need to manage different stylesheets. Instanciating an Ephemeral always succeed.

Search Document