#style #css #layout #ui #gui-framework #node-tree

macro alchemy-macros

A crate containing macros used in Alchemy, the Rust cross-platform GUI framework

1 unstable release

0.1.0 Jun 6, 2019

#65 in #node-tree


Used in alchemy

MPL-2.0+

220KB
4.5K SLoC

Alchemy-Macros

This crate holds macros for two things, primarily:

  • rsx! {}, which transforms <View></<View> tags into their proper RSX calls. Much of this is forked from the awesome work done by Bodil Stokke in typed-html.
  • styles! {}, which transforms CSS style nodes into Vec<Styles>, which the rendering engine uses to theme and style nodes. This relies on the CSS Parser from Servo. Styles do not support cascading; this is a design decision, as inheritance is already a bit of a taboo in Rust, so to do it in styling code feels really odd and involves a mental shift the deeper you go. Opt to apply successive style keys, conditionally if need be, to achieve the same thing with a compositional approach.

Questions, Comments?

Open an issue, or hit me up on Twitter.


lib.rs:

Implements macros used in Alchemy.

  • rsx! {}, which turns RSX tags into RSX node trees.
  • styles! {}, which turns CSS stylesheet strings into Vec<Styles>.

In general, you should prefer using these to constructing the above values manually.

Much of the rsx! {} support is achieved by forking code riginally written by Bodil Stokke over in typed-html.

Dependencies

~3.5–4.5MB
~95K SLoC