pub(crate) mod quill;
pub mod leaflet;
#[cfg(not(feature = "dev-css"))]
pub const FERRO_BASE_CSS: &str = include_str!("../../assets/ferro-base.css");
pub fn ferro_base_css() -> std::borrow::Cow<'static, str> {
#[cfg(not(feature = "dev-css"))]
{
std::borrow::Cow::Borrowed(FERRO_BASE_CSS)
}
#[cfg(feature = "dev-css")]
{
let css = std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/assets/ferro-base.css"
))
.expect("ferro-base.css must be readable in dev-css mode");
std::borrow::Cow::Owned(css)
}
}
pub const GEIST_SANS_WOFF2: &[u8] = include_bytes!("../../assets/fonts/Geist-Variable.woff2");
pub const GEIST_MONO_WOFF2: &[u8] = include_bytes!("../../assets/fonts/GeistMono-Variable.woff2");
pub const GEIST_OFL_TXT: &[u8] = include_bytes!("../../assets/fonts/OFL.txt");
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[allow(clippy::const_is_empty)]
fn ferro_base_css_non_empty() {
let css = ferro_base_css();
assert!(!css.is_empty(), "embedded CSS must not be empty");
assert!(
css.contains("flex"),
"expected `flex` utility in generated CSS"
);
}
#[test]
#[allow(clippy::const_is_empty)]
fn geist_sans_woff2_non_empty() {
assert!(
!GEIST_SANS_WOFF2.is_empty(),
"Geist Sans woff2 must not be empty"
);
}
#[test]
#[allow(clippy::const_is_empty)]
fn geist_mono_woff2_non_empty() {
assert!(
!GEIST_MONO_WOFF2.is_empty(),
"Geist Mono woff2 must not be empty"
);
}
#[test]
fn geist_sans_woff2_magic_bytes() {
assert_eq!(
&GEIST_SANS_WOFF2[..4],
&[0x77, 0x4F, 0x46, 0x32],
"Geist Sans woff2 must start with wOF2 magic bytes"
);
}
#[test]
fn geist_mono_woff2_magic_bytes() {
assert_eq!(
&GEIST_MONO_WOFF2[..4],
&[0x77, 0x4F, 0x46, 0x32],
"Geist Mono woff2 must start with wOF2 magic bytes"
);
}
#[test]
fn ferro_base_css_contains_motion_duration_fallback() {
let css = ferro_base_css();
assert!(
css.contains("var(--motion-duration-fast,"),
"expected motion-duration-fast fallback in generated CSS; run scripts/gen-ferro-base-css.sh"
);
for class in [".duration-fast{", ".duration-base{", ".duration-slow{"] {
assert!(
css.contains(class),
"expected `{class}` utility rule in generated CSS; run scripts/gen-ferro-base-css.sh"
);
}
assert!(
css.contains("prefers-reduced-motion"),
"expected prefers-reduced-motion block in generated CSS"
);
assert!(
css.contains("--motion-duration-fast:.01ms!important"),
"expected !important on the reduced-motion collapse; run scripts/gen-ferro-base-css.sh"
);
}
#[test]
fn ferro_base_css_ring_falls_back_to_primary() {
let css = ferro_base_css();
assert!(
css.contains("var(--color-ring,var(--color-primary))"),
"expected --color-ring fallback to --color-primary in generated CSS; run scripts/gen-ferro-base-css.sh"
);
}
#[test]
#[cfg(not(feature = "dev-css"))]
fn ferro_base_css_release_returns_borrowed() {
use std::borrow::Cow;
let css = ferro_base_css();
assert!(
matches!(css, Cow::Borrowed(_)),
"without dev-css feature, ferro_base_css() must return Cow::Borrowed (zero allocation)"
);
assert_eq!(
css.as_ref(),
FERRO_BASE_CSS,
"Cow::Borrowed content must equal the embedded FERRO_BASE_CSS constant"
);
}
#[test]
#[cfg(feature = "dev-css")]
fn ferro_base_css_dev_returns_owned_matching_disk() {
use std::borrow::Cow;
let css = ferro_base_css();
assert!(
matches!(css, Cow::Owned(_)),
"with dev-css feature, ferro_base_css() must return Cow::Owned (disk read)"
);
let disk_content = std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/assets/ferro-base.css"
))
.expect("assets/ferro-base.css must exist and be readable for the dev-css test");
assert_eq!(
css.as_ref(),
disk_content.as_str(),
"Cow::Owned content must equal the on-disk ferro-base.css (disk read proves hot-reload path is wired)"
);
}
}