Skip to content

Commit 28c1567

Browse files
Merge from main
2 parents 5d03cec + 82b2814 commit 28c1567

File tree

21 files changed

+330
-0
lines changed

21 files changed

+330
-0
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

book-examples/leptos/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ lucide-leptos = { version = "1.0.0", optional = true }
1818
log.workspace = true
1919
radix-leptos-icons = { workspace = true, optional = true }
2020
shadcn-ui-leptos-alert = { path = "../../packages/leptos/alert" , optional = true }
21+
shadcn-ui-leptos-badge = { path = "../../packages/leptos/badge", optional = true }
2122
shadcn-ui-leptos-breadcrumb = { path = "../../packages/leptos/breadcrumb", optional = true }
2223
shadcn-ui-leptos-button = { path = "../../packages/leptos/button", optional = true }
2324
shadcn-ui-leptos-card = { path = "../../packages/leptos/card", optional = true }
2425

2526
[features]
2627
default = [
2728
"alert",
29+
"badge",
2830
"breadcrumb",
2931
"button",
3032
"card",
@@ -34,6 +36,7 @@ alert = [
3436
"dep:radix-leptos-icons",
3537
"dep:shadcn-ui-leptos-alert",
3638
]
39+
badge = ["dep:shadcn-ui-leptos-badge"]
3740
breadcrumb = [
3841
"dep:lucide-leptos",
3942
"dep:radix-leptos-icons",

book-examples/leptos/src/default.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ mod components;
33
#[cfg(feature = "alert")]
44
mod alert;
55

6+
#[cfg(feature = "badge")]
7+
mod badge;
8+
69
#[cfg(feature = "breadcrumb")]
710
mod breadcrumb;
811

@@ -25,6 +28,10 @@ pub fn Default() -> impl MatchNestedRoutes + Clone {
2528
{
2629
component_view(self::alert::AlertRoutes, ())
2730
},
31+
#[cfg(feature = "badge")]
32+
{
33+
component_view(self::badge::BadgeRoutes, ())
34+
},
2835
#[cfg(feature = "breadcrumb")]
2936
{
3037
component_view(self::breadcrumb::BreadcrumbRoutes, ())
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#[allow(clippy::module_inception)]
2+
mod badge;
3+
mod badge_destructive;
4+
mod badge_outline;
5+
mod badge_secondary;
6+
7+
use leptos::prelude::*;
8+
use leptos_router::{
9+
components::{Outlet, ParentRoute, Route},
10+
path, MatchNestedRoutes,
11+
};
12+
13+
#[component(transparent)]
14+
pub fn BadgeRoutes() -> impl MatchNestedRoutes + Clone {
15+
view! {
16+
<ParentRoute path=path!("/badge") view=Outlet>
17+
<Route path=path!("/") view=badge::BadgeDemo />
18+
<Route path=path!("/destructive") view=badge_destructive::BadgeDestructive />
19+
<Route path=path!("/outline") view=badge_outline::BadgeOutline />
20+
<Route path=path!("/secondary") view=badge_secondary::BadgeSecondary />
21+
</ParentRoute>
22+
}
23+
.into_inner()
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use leptos::prelude::*;
2+
3+
use crate::default::components::ui::badge::Badge;
4+
5+
#[component]
6+
pub fn BadgeDemo() -> impl IntoView {
7+
view! {
8+
<Badge>{"Badge"}</Badge>
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use leptos::prelude::*;
2+
3+
use crate::default::components::ui::badge::{Badge, BadgeVariant};
4+
5+
#[component]
6+
pub fn BadgeDestructive() -> impl IntoView {
7+
view! {
8+
<Badge variant={BadgeVariant::Destructive}>{"Destructive"}</Badge>
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use leptos::prelude::*;
2+
3+
use crate::default::components::ui::badge::{Badge, BadgeVariant};
4+
5+
#[component]
6+
pub fn BadgeOutline() -> impl IntoView {
7+
view! {
8+
<Badge variant={BadgeVariant::Outline}>{"Outline"}</Badge>
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use leptos::prelude::*;
2+
3+
use crate::default::components::ui::badge::{Badge, BadgeVariant};
4+
5+
#[component]
6+
pub fn BadgeSecondary() -> impl IntoView {
7+
view! {
8+
<Badge variant={BadgeVariant::Secondary}>{"Secondary"}</Badge>
9+
}
10+
}

book-examples/leptos/src/default/components/ui.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#[cfg(feature = "alert")]
44
pub use shadcn_ui_leptos_alert::default as alert;
55

6+
#[cfg(feature = "badge")]
7+
pub use shadcn_ui_leptos_badge::default as badge;
8+
69
#[cfg(feature = "breadcrumb")]
710
pub use shadcn_ui_leptos_breadcrumb::default as breadcrumb;
811

book-examples/leptos/src/new_york.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ mod components;
33
#[cfg(feature = "alert")]
44
mod alert;
55

6+
#[cfg(feature = "badge")]
7+
mod badge;
8+
69
#[cfg(feature = "breadcrumb")]
710
mod breadcrumb;
811

@@ -25,6 +28,10 @@ pub fn NewYork() -> impl MatchNestedRoutes + Clone {
2528
{
2629
component_view(self::alert::AlertRoutes, ())
2730
},
31+
#[cfg(feature = "badge")]
32+
{
33+
component_view(self::badge::BadgeRoutes, ())
34+
},
2835
#[cfg(feature = "breadcrumb")]
2936
{
3037
component_view(self::breadcrumb::BreadcrumbRoutes, ())

0 commit comments

Comments
 (0)