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, non-responsive preview,
16/// and aggregate facades.
17pub const COMPONENT_LIBRARY: &str = "atlas-ui";
18
19/// Returns registry-safe named library paths for `slint-build`.
20///
21/// Pass the result to
22/// [`slint_build::CompilerConfiguration::with_library_paths`] from `build.rs`.
23/// Consumer markup can then import `@atlas-ui/stable.slint`,
24/// `@atlas-ui/preview-nonresponsive.slint`, `@atlas-ui/preview.slint`, or
25/// `@atlas-ui/components.slint`.
26#[must_use]
27pub fn slint_library_paths() -> HashMap<String, PathBuf> {
28    HashMap::from([
29        (COMPONENT_LIBRARY.to_owned(), components::ui_path()),
30        ("atlas-ui-core".to_owned(), core::ui_path()),
31        ("atlas-ui-icons".to_owned(), icons::ui_path()),
32        ("atlas-ui-tokens".to_owned(), tokens::ui_path()),
33    ])
34}
35
36/// Returns the stable Slint facade for tools that require a concrete path.
37#[must_use]
38pub fn stable_slint_path() -> PathBuf {
39    components::ui_path().join("stable.slint")
40}
41
42/// Returns the preview Slint facade for tools that require a concrete path.
43#[must_use]
44pub fn preview_slint_path() -> PathBuf {
45    components::ui_path().join("preview.slint")
46}
47
48/// Returns the non-responsive preview Slint facade for tools that require a
49/// concrete path. This facade excludes responsive preview contracts.
50#[must_use]
51pub fn preview_nonresponsive_slint_path() -> PathBuf {
52    components::ui_path().join("preview-nonresponsive.slint")
53}
54
55#[cfg(test)]
56mod tests {
57    use super::{
58        preview_nonresponsive_slint_path, preview_slint_path, slint_library_paths,
59        stable_slint_path,
60    };
61
62    #[test]
63    fn exported_slint_paths_exist() {
64        assert!(stable_slint_path().is_file());
65        assert!(preview_slint_path().is_file());
66        assert!(preview_nonresponsive_slint_path().is_file());
67        assert!(slint_library_paths().values().all(|path| path.is_dir()));
68    }
69}