diff --git a/package-lock.json b/package-lock.json index 8dbfeda..ce71949 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,10 @@ { - "name": "@nixysoftware/leptos-radix", + "name": "@nixysoftware/radix", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@nixysoftware/leptos-radix", + "name": "@nixysoftware/radix", "license": "MIT", "devDependencies": { "@types/node": "^20.11.28", diff --git a/packages/colors/src/lib.rs b/packages/colors/src/lib.rs index 925e00d..1efda7c 100644 --- a/packages/colors/src/lib.rs +++ b/packages/colors/src/lib.rs @@ -1,3 +1,11 @@ +//! Rust port of [Radix Colors](https://www.radix-ui.com/colors). +//! +//! A gorgeous, accessible color system. +//! +//! See for the original documentation. +//! +//! See [`@radix-ui/colors`](https://www.npmjs.com/package/@radix-ui/colors) for the original package. + mod black_a; mod dark; mod light; diff --git a/packages/primitives/core/number/src/lib.rs b/packages/primitives/core/number/src/lib.rs index 8b13789..1eab5f8 100644 --- a/packages/primitives/core/number/src/lib.rs +++ b/packages/primitives/core/number/src/lib.rs @@ -1 +1,5 @@ - +//! Rust port of [Radix Core Number](https://www.radix-ui.com/primitives). +//! +//! This is an internal utility, not intended for public usage. +//! +//! See [`@radix-ui/number`](https://www.npmjs.com/package/@radix-ui/number) for the original package. diff --git a/packages/primitives/core/primitive/src/lib.rs b/packages/primitives/core/primitive/src/lib.rs index 8b13789..4602f15 100644 --- a/packages/primitives/core/primitive/src/lib.rs +++ b/packages/primitives/core/primitive/src/lib.rs @@ -1 +1,5 @@ - +//! Rust port of [Radix Core Primitive](https://www.radix-ui.com/primitives). +//! +//! This is an internal utility, not intended for public usage. +//! +//! See [`@radix-ui/primitive`](https://www.npmjs.com/package/@radix-ui/primitive) for the original package. diff --git a/packages/primitives/core/rect/src/lib.rs b/packages/primitives/core/rect/src/lib.rs index 52ef540..9af936c 100644 --- a/packages/primitives/core/rect/src/lib.rs +++ b/packages/primitives/core/rect/src/lib.rs @@ -1,3 +1,9 @@ +//! Rust port of [Radix Core Rect](https://www.radix-ui.com/primitives). +//! +//! This is an internal utility, not intended for public usage. +//! +//! See [`@radix-ui/rect`](https://www.npmjs.com/package/@radix-ui/rect) for the original package. + mod observe_element_rect; pub use observe_element_rect::*; diff --git a/packages/primitives/leptos/arrow/src/lib.rs b/packages/primitives/leptos/arrow/src/lib.rs index ba52d8f..2e4188f 100644 --- a/packages/primitives/leptos/arrow/src/lib.rs +++ b/packages/primitives/leptos/arrow/src/lib.rs @@ -1,3 +1,9 @@ +//! Leptos port of [Radix Arrow](https://www.radix-ui.com/primitives). +//! +//! This is an internal utility, not intended for public usage. +//! +//! See [`@radix-ui/react-arrow`](https://www.npmjs.com/package/@radix-ui/react-arrow) for the original package. + mod arrow; pub use arrow::*; diff --git a/packages/primitives/leptos/direction/Cargo.toml b/packages/primitives/leptos/direction/Cargo.toml new file mode 100644 index 0000000..a721096 --- /dev/null +++ b/packages/primitives/leptos/direction/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "radix-leptos-direction" +description = "Leptos port of Radix Direction." + +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +version.workspace = true + +[dependencies] +leptos.workspace = true diff --git a/packages/primitives/leptos/direction/README.md b/packages/primitives/leptos/direction/README.md new file mode 100644 index 0000000..7fe9a7c --- /dev/null +++ b/packages/primitives/leptos/direction/README.md @@ -0,0 +1,13 @@ +

+ + + +

+ +

radix-leptos-direction

+ +Wraps your app to provide global reading direction. + +## Rust Radix + +[Rust Radix](https://github.com/NixySoftware/radix) is a Rust port of [Radix](https://www.radix-ui.com/primitives). diff --git a/packages/primitives/leptos/direction/src/direction.rs b/packages/primitives/leptos/direction/src/direction.rs new file mode 100644 index 0000000..d50835e --- /dev/null +++ b/packages/primitives/leptos/direction/src/direction.rs @@ -0,0 +1,29 @@ +use leptos::*; + +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum Direction { + Ltr, + Rtl, +} + +type DirectionContextValue = MaybeSignal; + +#[component] +pub fn DirectionProvider( + #[prop(into)] direction: DirectionContextValue, + children: Children, +) -> impl IntoView { + view! { + {children()} + } +} + +pub fn use_direction(local_dir: MaybeProp) -> Signal { + let global_dir = use_context::(); + + Signal::derive(move || { + local_dir() + .or(global_dir.map(|global_dir| global_dir())) + .unwrap_or(Direction::Ltr) + }) +} diff --git a/packages/primitives/leptos/direction/src/lib.rs b/packages/primitives/leptos/direction/src/lib.rs new file mode 100644 index 0000000..f2e8730 --- /dev/null +++ b/packages/primitives/leptos/direction/src/lib.rs @@ -0,0 +1,11 @@ +//! Leptos port of [Radix Direction](https://www.radix-ui.com/primitives/docs/utilities/direction-provider). +//! +//! Wraps your app to provide global reading direction. +//! +//! See for the original documentation. +//! +//! See [`@radix-ui/react-direction`](https://www.npmjs.com/package/@radix-ui/react-direction) for the original package. + +mod direction; + +pub use direction::*; diff --git a/packages/primitives/leptos/popper/src/lib.rs b/packages/primitives/leptos/popper/src/lib.rs index 913b3a9..10cf9fb 100644 --- a/packages/primitives/leptos/popper/src/lib.rs +++ b/packages/primitives/leptos/popper/src/lib.rs @@ -1,3 +1,9 @@ +//! Leptos port of [Radix Popper](https://www.radix-ui.com/primitives). +//! +//! This is an internal utility, not intended for public usage. +//! +//! See [`@radix-ui/react-popper`](https://www.npmjs.com/package/@radix-ui/react-popper) for the original package. + mod popper; pub use popper::*; diff --git a/packages/primitives/leptos/use-size/src/lib.rs b/packages/primitives/leptos/use-size/src/lib.rs index 230ad98..0d8e506 100644 --- a/packages/primitives/leptos/use-size/src/lib.rs +++ b/packages/primitives/leptos/use-size/src/lib.rs @@ -1,3 +1,9 @@ +//! Leptos port of [Radix Use Size](https://www.radix-ui.com/primitives). +//! +//! This is an internal utility, not intended for public usage. +//! +//! See [`@radix-ui/react-use-size`](https://www.npmjs.com/package/@radix-ui/react-use-size) for the original package. + mod use_size; pub use use_size::*;