Skip to content

v4.1.0

Choose a tag to compare

@ghivert ghivert released this 09 May 16:23
· 27 commits to main since this release
593a5df

What's Changed — Core

v4.1.0 marks a new release for Sketch, allowing to bundle global, static styling
directly on stylesheet! Instead of depending on an external CSS file, it's now
possible to style body, :root, :host or any node you want directly in your
stylesheet.

import sketch
import sketch/css
import sketch/css/length.{px}

pub fn main() {
  let assert Ok(stylesheet) = sketch.stylesheet(strategy: sketch.Ephemeral)
  stylesheet
  |> sketch.global(root_class())
  |> sketch.global(body_class())
  |> sketch.render
}

fn root_class() {
  css.global(":root", [
    css.property("--my-variable", "#FFFFFF"),
  ])
}

fn body_class() {
  css.global("body", [
    css.font_family("Déjà Vu Sans"),
    css.margin(px(0)),
  ])
}

Everytime a global class is pushed in a stylesheet, the previous global class
with the same name will be overidden, and the new style will take place. It's
possible to leverage persistent stylesheet with global classes to change your
default styles during the lifetime of your application.

Improvements

  • Add the support for global classes to push directly in stylesheets.
  • Change the class name generation algorithm from xxhash32 to murmur3a, thanks
    to @eaon! Generation algorithm is now purely written in Gleam, and does not
    rely anymore on opaque blob, meaning Sketch is now more security-friendly, and
    100% auditable!
  • Class names are now defined using hex instead of ints! This makes class names
    easier to recognize and easier to read in the DOM!
  • Add a dispose function, to delete stylesheets and avoid memory leaks.

What's Changed — Sketch Lustre

Sketch Lustre Experimental is now official, and become the official way to use
Sketch with Lustre! Say goodbye to wrapper type, and say hello to pure, native
Lustre Element!

Sketch Lustre now uses the new approach to hide the sketch.StyleSheet during
view creation, to generate directly lustre/element.Element.
sketch/lustre/element.Element is now gone, meaning Sketch Lustre becomes
easily interoperable with the rest of the Lustre ecosystem! Sketch Lustre marks
a new step for Sketch & Lustre, closing the gap between Lustre & Sketch!

Breaking Changes

  • sketch/lustre/element.Element is now gone, and every
    sketch/lustre/element/html function generate lustre/element.Element
    directly.
  • sketch/lustre.setup does not accept a sketch.StyleSheet anymore, but now
    generates the corresponding persistent stylesheet on its own. This ensures no
    user will choose the wrong stylesheet strategy.

Improvements

  • sketch/lustre now exposes teardown, that let you get rid of a
    sketch.StyleSheet. That ensures no memory leak will happen in applications.
  • To mimic Lustre, sketch_lustre exposes a new module
    sketch/lustre/element/keyed, that exposes the same functions as
    lustre/element/keyed, with an additional class when needed.

New Contributors

  • @eaon made their first contribution in #40

Full Changelog: v4.0.0...v4.1.0