Skip to main content

workers_rsx/
lib.rs

1pub mod fragment;
2pub mod fragments;
3pub mod html;
4pub mod html_escaping;
5mod numbers;
6mod render;
7pub mod simple_element;
8pub mod state;
9mod text_element;
10mod dispatch;
11
12pub use dispatch::{dispatch, handle, Reducer};
13pub use self::render::Render;
14
15// Re-export for use by derive macros
16#[doc(hidden)]
17pub use serde_json;
18pub use fragment::Fragment;
19pub use fragments::diff_html;
20pub use simple_element::SimpleElement;
21pub use state::decode_state;
22pub use text_element::Raw;
23pub use text_element::RawOwned;
24pub use workers_rsx_impl::{component, css, html, page, rsx, view};
25pub use workers_rsx_impl::ActionJson;
26
27/// Tailwind CSS v4 preflight (base reset styles), minified.
28/// See: https://tailwindcss.com/docs/preflight
29pub static PREFLIGHT_CSS: &str = include_str!("preflight.css");
30
31/// Generate Tailwind CSS from a list of class names using `tailwind-rs-core`.
32/// Returns an empty string if no classes produce valid CSS.
33pub fn generate_tailwind_css(class_names: &[&str]) -> String {
34    let mut generator = tailwind_rs_core::CssGenerator::new();
35    for name in class_names {
36        let _ = generator.add_class(name);
37    }
38    let utility_css = generator.generate_css();
39    if utility_css.is_empty() {
40        return String::new();
41    }
42    format!("{}{}", PREFLIGHT_CSS, utility_css)
43}
44
45/// Create a raw (unencoded) HTML string
46#[macro_export]
47macro_rules! raw {
48    ($s:expr) => {
49        ::workers_rsx::Raw::from($s)
50    };
51}