Skip to main content

atlas_ui/
lib.rs

1//! Main Rust entry point for the Atlas UI design system.
2//!
3//! Use this crate as a build dependency to configure Slint's named Atlas
4//! libraries without relying on a monorepo directory layout.
5
6use std::{collections::HashMap, path::PathBuf};
7
8pub use atlas_ui_components as components;
9pub use atlas_ui_core as core;
10#[cfg(feature = "documents")]
11pub use atlas_ui_documents as documents;
12pub use atlas_ui_icons as icons;
13pub use atlas_ui_tokens as tokens;
14
15/// Named Slint library containing the stable, preview, and aggregate facades.
16pub const COMPONENT_LIBRARY: &str = "atlas-ui";
17
18/// Returns registry-safe named library paths for `slint-build`.
19///
20/// Pass the result to
21/// [`slint_build::CompilerConfiguration::with_library_paths`] from `build.rs`.
22/// Consumer markup can then import `@atlas-ui/stable.slint`,
23/// `@atlas-ui/preview.slint`, or `@atlas-ui/components.slint`.
24#[must_use]
25pub fn slint_library_paths() -> HashMap<String, PathBuf> {
26    HashMap::from([
27        (COMPONENT_LIBRARY.to_owned(), components::ui_path()),
28        ("atlas-ui-core".to_owned(), core::ui_path()),
29        ("atlas-ui-icons".to_owned(), icons::ui_path()),
30        ("atlas-ui-tokens".to_owned(), tokens::ui_path()),
31    ])
32}
33
34/// Returns the stable Slint facade for tools that require a concrete path.
35#[must_use]
36pub fn stable_slint_path() -> PathBuf {
37    components::ui_path().join("stable.slint")
38}
39
40/// Returns the preview Slint facade for tools that require a concrete path.
41#[must_use]
42pub fn preview_slint_path() -> PathBuf {
43    components::ui_path().join("preview.slint")
44}
45
46#[cfg(test)]
47mod tests {
48    use super::{preview_slint_path, slint_library_paths, stable_slint_path};
49
50    #[test]
51    fn exported_slint_paths_exist() {
52        assert!(stable_slint_path().is_file());
53        assert!(preview_slint_path().is_file());
54        assert!(slint_library_paths().values().all(|path| path.is_dir()));
55    }
56}