//! # Neon Design System — Slint UI library for Rust
//!
//! Reusable Slint components + theme tokens for Rust desktop apps.
//! 35+ components, dark/light theme switch, neon accents, glass
//! surfaces.
//!
//! ## What this crate ships
//!
//! * **Slint components** — `.slint` files under `ui/` that consumer
//!   apps import via Slint's `library_paths` mechanism (see
//!   [`SLINT_LIBRARY_PATH`]).
//! * **Rust helpers** — theme switching, hex color parsing, the
//!   [`neon_ui_setup!`](crate::neon_ui_setup) macro.
//!
//! ## Consumer setup (3 steps)
//!
//! ### 1. Add the dependency in **both** `[dependencies]` and `[build-dependencies]`
//!
//! ```toml
//! [dependencies]
//! slint = "1.9"
//! slint-ui-system = { git = "https://github.com/wilmercampagna/slint-ui-system" }
//!
//! [build-dependencies]
//! slint-build = "1.9"
//! slint-ui-system = { git = "https://github.com/wilmercampagna/slint-ui-system" }
//! ```
//!
//! The build script reads [`SLINT_LIBRARY_PATH`] to wire up Slint's
//! library resolver; the runtime side gets the Rust helpers.
//!
//! ### 2. Wire up `build.rs`
//!
//! ```ignore
//! use slint_build::CompilerConfiguration;
//!
//! fn main() {
//!     let neon = format!("{}/index.slint",
//!                        slint_ui_system::SLINT_LIBRARY_PATH);
//!     let cfg = CompilerConfiguration::new()
//!         .with_library_paths(
//!             [("neon".to_string(), neon.into())]
//!                 .into_iter().collect(),
//!         );
//!     slint_build::compile_with_config("ui/app.slint", cfg).unwrap();
//! }
//! ```
//!
//! ### 3. Import in your `.slint` file
//!
//! ```slint
//! import { Theme, NeonButton, NeonCard } from "@neon";
//!
//! export component AppWindow inherits Window {
//!     background: Theme.bg-base;
//!     NeonButton {
//!         text: "Hello Neon";
//!         clicked => { /* … */ }
//!     }
//! }
//! ```
//!
//! ## Theme switch from Rust
//!
//! ```ignore
//! use slint::ComponentHandle;
//! use slint_ui_system::theme;
//! slint::include_modules!();
//!
//! fn main() -> Result<(), slint::PlatformError> {
//!     let win = AppWindow::new()?;
//!     theme::set_dark_mode(&win, false);   // light
//!     win.run()
//! }
//! ```
//!
//! ## License
//!
//! MIT or Apache-2.0 at the consumer's option.

#![doc(html_root_url = "https://docs.rs/slint-ui-system/0.5.0")]
#![warn(missing_docs)]

pub mod bridge;
pub mod color;
pub mod theme;

/// Absolute path to the directory containing this crate's `.slint`
/// library files. Used by consumer build scripts to set up Slint's
/// `library_paths` resolver so they can write
/// `import { … } from "@neon";` in their `.slint` sources.
///
/// This is `<crate_root>/ui` captured at this crate's compile
/// time — Cargo's path resolution (whether the crate lives as a
/// path dep, in `~/.cargo/registry`, or as a git checkout) is
/// handled transparently by `env!`.
///
/// # Example
///
/// In your build script:
///
/// ```ignore
/// fn main() {
///     let neon = format!("{}/index.slint",
///                        slint_ui_system::SLINT_LIBRARY_PATH);
///     let cfg = slint_build::CompilerConfiguration::new()
///         .with_library_paths(
///             [("neon".to_string(), neon.into())]
///                 .into_iter().collect(),
///         );
///     slint_build::compile_with_config("ui/app.slint", cfg).unwrap();
/// }
/// ```
pub const SLINT_LIBRARY_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/ui");

#[cfg(test)]
mod tests {
    #[test]
    fn slint_library_path_points_at_ui_dir() {
        let p = std::path::Path::new(super::SLINT_LIBRARY_PATH);
        assert!(p.is_dir(), "SLINT_LIBRARY_PATH must resolve to a real dir");
        assert!(
            p.join("index.slint").is_file(),
            "SLINT_LIBRARY_PATH must contain index.slint"
        );
        assert!(
            p.join("theme.slint").is_file(),
            "SLINT_LIBRARY_PATH must contain theme.slint"
        );
    }

    #[test]
    fn crate_metadata_pinned() {
        assert_eq!(env!("CARGO_PKG_NAME"), "slint-ui-system");
        // Bumped from 0.4 → 0.5 — NeonImageSidebar addition.
        assert!(env!("CARGO_PKG_VERSION").starts_with("0.5"));
    }
}
