Skip to content
110 changes: 87 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@
[workspace]
# Temporarily disabled to upgrade individual packages to Leptos 0.7.
# members = [
# "book-examples/*/*",
# "packages/colors",
# "packages/icons/*",
# "packages/primitives/*/*",
# "packages/themes/*",
# "scripts",
# "stories/*",
# ]
# Temporarily disabled subcrates to be upgraded individually to Leptos 0.7.
# Once a crate is ready, uncomment it here.
members = [
"book-examples/*/*",
"packages/colors",
"packages/icons/*",
"packages/primitives/leptos/accessible-icon",
"packages/primitives/leptos/arrow",
"packages/primitives/leptos/aspect-ratio",
"packages/primitives/leptos/direction",
"packages/primitives/leptos/id",
"packages/primitives/leptos/label",
"packages/primitives/leptos/use-controllable-state",
"packages/primitives/leptos/use-escape-keydown",
"packages/primitives/leptos/use-previous",
"packages/primitives/leptos/use-size",
"packages/primitives/leptos/visually-hidden",
"packages/icons/dioxus",
"packages/icons/yew",

# -- Leptos Primitives (commented until they're upgraded) --
# "packages/primitives/leptos/accessible-icon",
# "packages/primitives/leptos/arrow",
# "packages/primitives/leptos/aspect-ratio",
# "packages/primitives/leptos/avatar",
# "packages/primitives/leptos/checkbox",
"packages/primitives/leptos/context",
# "packages/primitives/leptos/collection",
# "packages/primitives/leptos/compose-refs",
# "packages/primitives/leptos/direction",
# "packages/primitives/leptos/dismissable-layer",
# "packages/primitives/leptos/dropdown-menu",
# "packages/primitives/leptos/focus-guards",
# "packages/primitives/leptos/focus-scope",
# "packages/primitives/leptos/id",
# "packages/primitives/leptos/label",
# "packages/primitives/leptos/menu",
# "packages/primitives/leptos/popover",
# "packages/primitives/leptos/popper",
# "packages/primitives/leptos/portal",
# "packages/primitives/leptos/presence",
"packages/primitives/leptos/primitive",
"packages/primitives/leptos/progress",
# "packages/primitives/leptos/roving-focus",
# "packages/primitives/leptos/select",
# "packages/primitives/leptos/separator",
# "packages/primitives/leptos/slot",
# "packages/primitives/leptos/switch",
# "packages/primitives/leptos/tabs",
# "packages/primitives/leptos/toggle",
# "packages/primitives/leptos/use-controllable-state",
# "packages/primitives/leptos/use-escape-keydown",
# "packages/primitives/leptos/use-previous",
# "packages/primitives/leptos/use-size",
# "packages/primitives/leptos/visually-hidden",

# -- Yew Primitives --
"packages/primitives/yew/*",

# -- Themes, Scripts, and Stories --
"packages/themes/yew",
"scripts",
"stories/*",
]

resolver = "2"

[workspace.package]
Expand All @@ -39,14 +62,17 @@ repository = "https://github.com/RustForWeb/radix"
version = "0.0.2"

[workspace.dependencies]
console_log = "1.0.0"
console_error_panic_hook = "0.1.7"
console_log = "1.0.0"
dioxus = "0.6.1"
leptos = "0.7.2"
leptos_dom = "0.7.2"
leptos_router = "0.7.2"
leptos-node-ref = "0.0.3"
leptos-maybe-callback = "0.0.3"
leptos-style = "0.0.3"
leptos-typed-fallback-show = "0.0.3"
leptos-use = "0.15.2"
log = "0.4.22"
send_wrapper = "0.6.0"
serde = "1.0.198"
Expand All @@ -58,6 +84,44 @@ yew-router = "0.18.0"
yew-struct-component = "0.1.4"
yew-style = "0.1.4"

# Subcrate packages (paths remain the same; you can comment out any subcrate not yet upgraded).
# We centralize shared dependencies in [workspace.dependencies] for a single source of truth,
# reducing duplication, preventing version drift, and keeping the Cargo.lock consistent.
#radix-leptos-arrow.path = "./packages/primitives/leptos/arrow"
#radix-leptos-aspect-ratio.path = "./packages/primitives/leptos/aspect-ratio"
#radix-leptos-accessible-icon.path = "./packages/primitives/leptos/accessible-icon"
#radix-leptos-avatar.path = "./packages/primitives/leptos/avatar"
#radix-leptos-checkbox.path = "./packages/primitives/leptos/checkbox"
radix-leptos-context.path = "./packages/primitives/leptos/context"
#radix-leptos-collection.path = "./packages/primitives/leptos/collection"
#radix-leptos-compose-refs.path = "./packages/primitives/leptos/compose-refs"
#radix-leptos-direction.path = "./packages/primitives/leptos/direction"
#radix-leptos-dismissable-layer.path = "./packages/primitives/leptos/dismissable-layer"
#radix-leptos-dropdown-menu.path = "./packages/primitives/leptos/dropdown-menu"
#radix-leptos-focus-guards.path = "./packages/primitives/leptos/focus-guards"
#radix-leptos-focus-scope.path = "./packages/primitives/leptos/focus-scope"
#radix-leptos-id.path = "./packages/primitives/leptos/id"
#radix-leptos-label.path = "./packages/primitives/leptos/label"
#radix-leptos-menu.path = "./packages/primitives/leptos/menu"
#radix-leptos-popper.path = "./packages/primitives/leptos/popper"
#radix-leptos-portal.path = "./packages/primitives/leptos/portal"
#radix-leptos-presence.path = "./packages/primitives/leptos/presence"
radix-leptos-primitive.path = "./packages/primitives/leptos/primitive"
radix-leptos-progress.path = "./packages/primitives/leptos/progress"
#radix-leptos-roving-focus.path = "./packages/primitives/leptos/roving-focus"
#radix-leptos-select.path = "./packages/primitives/leptos/select"
#radix-leptos-separator.path = "./packages/primitives/leptos/separator"
#radix-leptos-slot.path = "./packages/primitives/leptos/slot"
#radix-leptos-switch.path = "./packages/primitives/leptos/switch"
#radix-leptos-tabs.path = "./packages/primitives/leptos/tabs"
#radix-leptos-toggle.path = "./packages/primitives/leptos/toggle"
#radix-leptos-use-controllable-state.path = "./packages/primitives/leptos/use-controllable-state"
#radix-leptos-use-escape-keydown.path = "./packages/primitives/leptos/use-escape-keydown"
#radix-leptos-use-previous.path = "./packages/primitives/leptos/use-previous"
#radix-leptos-use-size.path = "./packages/primitives/leptos/use-size"
#radix-leptos-visually-hidden.path = "./packages/primitives/leptos/visually-hidden"

[patch.crates-io]
yew = { git = "https://github.com/RustForWeb/yew.git", branch = "feature/use-composed-ref" }
yew-router = { git = "https://github.com/RustForWeb/yew.git", branch = "feature/use-composed-ref" }
leptos-node-ref = { git = "https://github.com/geoffreygarrett/leptos-utils", branch = "feature/any-node-ref" }
32 changes: 16 additions & 16 deletions book/src/primitives/components/progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ files = ["src/progress.rs"]

## Features

- Provides context for assistive technology to read the progress of a task.
- Provides context for assistive technology to read the progress of a task.

## Installation

Expand All @@ -29,9 +29,9 @@ Install the component from your command line.
cargo add radix-leptos-progress
```

- [View on crates.io](https://crates.io/crates/radix-leptos-progress)
- [View on docs.rs](https://docs.rs/radix-leptos-progress/latest/radix_leptos_progress/)
- [View source](https://github.com/RustForWeb/radix/tree/main/packages/primitives/leptos/progress)
- [View on crates.io](https://crates.io/crates/radix-leptos-progress)
- [View on docs.rs](https://docs.rs/radix-leptos-progress/latest/radix_leptos_progress/)
- [View source](https://github.com/RustForWeb/radix/tree/main/packages/primitives/leptos/progress)

{{#endtab }}
{{#endtabs }}
Expand All @@ -45,14 +45,14 @@ Import all parts and piece them together.

```rust,ignore
use leptos::*;
use radix_leptos_progress::*;
use radix_leptos_progress::primitive as Progress;

#[component]
fn Anatomy() -> impl IntoView {
view! {
<Progress>
<ProgressIndicator />
</Progress>
<Progress::Root>
<Progress::Indicator />
</Progress::Root>
}
}
```
Expand All @@ -70,19 +70,19 @@ Contains all of the progress parts.
{{#tab name="Leptos" }}

| Prop | Type | Default |
| ----------------- | -------------------------------------- | ------- |
|-------------------|----------------------------------------|---------|
| `as_child` | `MaybeProp<bool>` | `false` |
| `value` | `MaybeProp<f64>` | - |
| `value` | `MaybeProp<f64>` | |
| `max` | `MaybeProp<f64>` | `100.0` |
| `get_value_label` | `Option<Callback<(f64, f64), String>>` | - |
| `get_value_label` | `Option<Callback<(f64, f64), String>>` | |

{{#endtab }}
{{#endtabs }}

<div style="height: 1em;"></div>

| Data attribute | Values |
| -------------- | -------------------------------------------- |
|----------------|----------------------------------------------|
| `[data-state]` | `"complete" \| "indeterminate" \| "loading"` |
| `[data-value]` | The current value |
| `[data-max]` | The max value |
Expand All @@ -95,7 +95,7 @@ Used to show the progress visually. It also makes progress accessible to assisti
{{#tab name="Leptos" }}

| Prop | Type | Default |
| ---------- | ----------------- | ------- |
|------------|-------------------|---------|
| `as_child` | `MaybeProp<bool>` | `false` |

{{#endtab }}
Expand All @@ -104,15 +104,15 @@ Used to show the progress visually. It also makes progress accessible to assisti
<div style="height: 1em;"></div>

| Data attribute | Values |
| -------------- | -------------------------------------------- |
|----------------|----------------------------------------------|
| `[data-state]` | `"complete" \| "indeterminate" \| "loading"` |
| `[data-value]` | The current value |
| `[data-max]` | The max value |

## Accessibility

Adheres to the [`progressbar` role requirements](https://www.w3.org/WAI/ARIA/apg/patterns/meter/).
Adheres to the [`progressbar` role requirements](https://www.w3.org/WAI/ARIA/apg/patterns/meter).

## See Also

- [Radix documentation](https://www.radix-ui.com/primitives/docs/components/progress)
- [Radix documentation](https://www.radix-ui.com/primitives/docs/components/progress)
12 changes: 12 additions & 0 deletions packages/primitives/leptos/context/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "radix-leptos-context"
description = "Leptos port of Radix Context."

authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[dependencies]
leptos.workspace = true
21 changes: 21 additions & 0 deletions packages/primitives/leptos/context/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<p align="center">
<a href="../../../../logo.svg">
<img src="../../../../logo.svg" width="300" height="200" alt="Rust Radix Logo">
</a>
</p>

<h1 align="center">radix-leptos-context</h1>

This is an internal utility, not intended for public usage.

[Rust Radix](https://github.com/RustForWeb/radix) is a Rust port of [Radix](https://www.radix-ui.com/primitives).

## Documentation

See [the Rust Radix book](https://radix.rustforweb.org/) for documentation.

## Rust For Web

The Rust Radix project is part of the [Rust For Web](https://github.com/RustForWeb).

[Rust For Web](https://github.com/RustForWeb) creates and ports web UI libraries for Rust. All projects are free and open source.
84 changes: 84 additions & 0 deletions packages/primitives/leptos/context/src/create_context.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/// Macro to create a context provider and a hook to consume the context.
///
/// # Example
/// ```rust
/// use leptos::prelude::*;
/// use radix_leptos_context::create_context;
///
/// #[derive(Clone)]
/// struct CountContext(i32);
///
/// create_context!(
/// context_type: CountContext,
/// provider: CountProvider,
/// hook: use_count,
/// root: "Count"
/// );
///
/// #[component]
/// fn Counter() -> impl IntoView {
/// let count = use_count("Counter");
/// view! { <div>"Count: "{count.0}</div> }
/// }
///
/// #[component]
/// fn App() -> impl IntoView {
/// view! {
/// <CountProvider value=CountContext(42)>
/// <Counter/>
/// </CountProvider>
/// }
/// }
/// ```
///
/// # Panics
///
/// The hook will panic if used in a component that is not wrapped in its provider:
/// ```should_panic
/// use leptos::prelude::*;
/// use radix_leptos_context::create_context;
///
/// #[derive(Clone)]
/// struct CountContext(i32);
///
/// create_context!(
/// context_type: CountContext,
/// provider: CountProvider,
/// hook: use_count,
/// root: "Count"
/// );
///
/// #[component]
/// fn BadApp() -> impl IntoView {
/// let count = use_count("BadApp"); // Panics: "`BadApp` must be used within `Count`"
/// view! { <div>{count.0}</div> }
/// }
/// ```
#[macro_export]
macro_rules! create_context {
(
context_type: $context_ty:ty,
provider: $provider:ident,
hook: $hook:ident,
root: $root_component_name:expr
) => {
use leptos::prelude::*;

#[component]
#[allow(non_snake_case)]
pub fn $provider(
value: $context_ty,
children: TypedChildren<impl IntoView + 'static>,
) -> impl IntoView {
view! { <Provider value=value children=children/> }
}

pub fn $hook(component_name: &'static str) -> $context_ty {
use_context::<$context_ty>()
.expect(&format!("`{}` must be used within `{}`", component_name, $root_component_name))
.clone()
}
};
}
// TODO: Default context support

3 changes: 3 additions & 0 deletions packages/primitives/leptos/context/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod create_context;

// pub use create_context::*;
14 changes: 14 additions & 0 deletions packages/primitives/leptos/primitive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "radix-leptos-primitive"
description = "Leptos port of Radix Primitive."

authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[dependencies]
leptos.workspace = true
leptos-node-ref.workspace = true
leptos-typed-fallback-show.workspace = true
Loading