#style #css #web #wasm

macro dwind-macros

Macros used by the dwind crate for applying dominator classes to components using a custom language

4 releases

new 0.2.2 Feb 16, 2025
0.2.1 Jan 22, 2025
0.2.0 Jan 18, 2025
0.1.0 Dec 2, 2024

#2470 in Procedural macros

Download history 154/week @ 2024-12-01 29/week @ 2024-12-08 49/week @ 2024-12-15 1/week @ 2024-12-22 43/week @ 2025-01-05 120/week @ 2025-01-12 235/week @ 2025-01-19 105/week @ 2025-01-26 478/week @ 2025-02-02 559/week @ 2025-02-09

1,421 downloads per month
Used in 2 crates

MIT license

36KB
788 lines

dwind-macros

This crate provides the core macros used by the DWIND style system.

For examples of usage, check out the example application here: https://jedimemo.github.io/dwind/examples/

Usage

dwclass! and dwclass_signal!

The main macros used from applications are dwclass and dwclass_signal. These can be used on DomBuilder<N> to use dwind classes on your dom elements.

fn hello() {
    html!("div", {
        .dwclass!("hover:font-extrabold")
        .dwclass_signal!("text-l", always(true))
    })
}

dwgenerate_map!

This macro lets you pre-declare classes to use in your dwind application. Typically used in style packages, such as dwind itself

#[macro_export]
macro_rules! width_generator {
    ($width:tt) => {
        const_format::formatcp!("width: {};", $width)
    };
}

// Invokes the width_generator!(a, b) macro for all elements in the provided array of tuples
dwgenerate_map!(
    "w",
    "width-",
    [
        // these tuples are turned into arguments to the invokes generator macro
        ("p-5", "5%"),
    ]
);

Dependencies

~13MB
~234K SLoC