Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/textarea #210

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions book-examples/leptos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ shadcn-ui-leptos-alert = { path = "../../packages/leptos/alert" , optional = tru
shadcn-ui-leptos-badge = { path = "../../packages/leptos/badge", optional = true }
shadcn-ui-leptos-button = { path = "../../packages/leptos/button", optional = true }
shadcn-ui-leptos-card = { path = "../../packages/leptos/card", optional = true }
shadcn-ui-leptos-textarea = { path = "../../packages/leptos/textarea", optional = true }

[features]
default = [
"alert",
"badge",
"button",
"card",
"textarea",
]
alert = [
"dep:lucide-leptos",
Expand All @@ -45,3 +47,7 @@ card = [
"dep:shadcn-ui-leptos-button",
"dep:shadcn-ui-leptos-card",
]
textarea = [
"dep:shadcn-ui-leptos-button",
"dep:shadcn-ui-leptos-textarea",
]
6 changes: 6 additions & 0 deletions book-examples/leptos/src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ mod badge;
mod button;
#[cfg(feature = "card")]
mod card;
#[cfg(feature = "textarea")]
mod textarea;

use leptos::prelude::*;
use leptos_router::{
Expand All @@ -34,6 +36,10 @@ pub fn Default() -> impl MatchNestedRoutes + Clone {
{
component_view(self::card::CardRoutes, ())
},
#[cfg(feature = "textarea")]
{
component_view(self::textarea::TextareaRoutes, ())
},
);

view! {
Expand Down
2 changes: 2 additions & 0 deletions book-examples/leptos/src/default/components/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ pub use shadcn_ui_leptos_badge::default as badge;
pub use shadcn_ui_leptos_button::default as button;
#[cfg(feature = "card")]
pub use shadcn_ui_leptos_card::default as card;
#[cfg(feature = "textarea")]
pub use shadcn_ui_leptos_textarea::default as textarea;
28 changes: 28 additions & 0 deletions book-examples/leptos/src/default/textarea.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#[allow(clippy::module_inception)]
mod textarea;
mod textarea_disabled;
mod textarea_form;
mod textarea_with_button;
mod textarea_with_label;
mod textarea_with_text;

use leptos::prelude::*;
use leptos_router::{
components::{Outlet, ParentRoute, Route},
path, MatchNestedRoutes,
};

#[component(transparent)]
pub fn TextareaRoutes() -> impl MatchNestedRoutes + Clone {
view! {
<ParentRoute path=path!("/textarea") view=Outlet>
<Route path=path!("/") view=textarea::TextareaDemo />
<Route path=path!("/disabled") view=textarea_disabled::TextareaDisabledDemo />
<Route path=path!("/form") view=textarea_form::TextareaFormDemo />
<Route path=path!("/with-button") view=textarea_with_button::TextareaWithButtonDemo />
<Route path=path!("/with-label") view=textarea_with_label::TextareaWithLabelDemo />
<Route path=path!("/with-text") view=textarea_with_text::TextareaWithTextDemo />
</ParentRoute>
}
.into_inner()
}
10 changes: 10 additions & 0 deletions book-examples/leptos/src/default/textarea/textarea.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use leptos::prelude::*;

use crate::default::components::ui::textarea::Textarea;

#[component]
pub fn TextareaDemo() -> impl IntoView {
view! {
<Textarea placeholder="Type your message here." />
}
}
10 changes: 10 additions & 0 deletions book-examples/leptos/src/default/textarea/textarea_disabled.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use leptos::prelude::*;

use crate::default::components::ui::textarea::Textarea;

#[component]
pub fn TextareaDisabledDemo() -> impl IntoView {
view! {
<Textarea placeholder="Type your message here." disabled=true />
}
}
10 changes: 10 additions & 0 deletions book-examples/leptos/src/default/textarea/textarea_form.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use leptos::prelude::*;

use crate::default::components::ui::textarea::Textarea;

#[component]
pub fn TextareaFormDemo() -> impl IntoView {
view! {
<Textarea placeholder= "Need implementation!"></Textarea>
}
}
18 changes: 18 additions & 0 deletions book-examples/leptos/src/default/textarea/textarea_with_button.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use leptos::prelude::*;

use crate::default::components::ui::{button::Button, textarea::Textarea};

#[component]
pub fn TextareaWithButtonDemo() -> impl IntoView {
let text = RwSignal::new("".to_string());
view! {
<div class="grid w-full gap-2">
<Textarea placeholder="Type your message here." value=text />
<Button
onclick= Callback::new(move |_|{
text.set("Updated".to_string());
})
>"Send message"</Button>
</div>
}
}
13 changes: 13 additions & 0 deletions book-examples/leptos/src/default/textarea/textarea_with_label.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use leptos::prelude::*;

use crate::default::components::ui::textarea::Textarea;

#[component]
pub fn TextareaWithLabelDemo() -> impl IntoView {
view! {
<div class="grid w-full gap-1.5">
<label r#for="message">"Your message"</label>
<Textarea placeholder="Type your message here." id="message" />
</div>
}
}
16 changes: 16 additions & 0 deletions book-examples/leptos/src/default/textarea/textarea_with_text.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use leptos::prelude::*;

use crate::default::components::ui::textarea::Textarea;

#[component]
pub fn TextareaWithTextDemo() -> impl IntoView {
view! {
<div class="grid w-full gap-1.5">
<label r#for="message-2">"Your Message"</label>
<Textarea placeholder="Type your message here." id="message-2" />
<p class="text-sm text-muted-foreground">
{"Your message will be copied to the support team."}
</p>
</div>
}
}
6 changes: 6 additions & 0 deletions book-examples/leptos/src/new_york.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ mod badge;
mod button;
#[cfg(feature = "card")]
mod card;
#[cfg(feature = "textarea")]
mod textarea;

use leptos::prelude::*;
use leptos_router::{
Expand All @@ -34,6 +36,10 @@ pub fn NewYork() -> impl MatchNestedRoutes + Clone {
{
component_view(self::card::CardRoutes, ())
},
#[cfg(feature = "textarea")]
{
component_view(self::textarea::TextareaRoutes, ())
},
);

view! {
Expand Down
2 changes: 2 additions & 0 deletions book-examples/leptos/src/new_york/components/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ pub use shadcn_ui_leptos_badge::new_york as badge;
pub use shadcn_ui_leptos_button::new_york as button;
#[cfg(feature = "card")]
pub use shadcn_ui_leptos_card::new_york as card;
#[cfg(feature = "textarea")]
pub use shadcn_ui_leptos_textarea::new_york as textarea;
28 changes: 28 additions & 0 deletions book-examples/leptos/src/new_york/textarea.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#[allow(clippy::module_inception)]
mod textarea;
mod textarea_disabled;
mod textarea_form;
mod textarea_with_button;
mod textarea_with_label;
mod textarea_with_text;

use leptos::prelude::*;
use leptos_router::{
components::{Outlet, ParentRoute, Route},
path, MatchNestedRoutes,
};

#[component(transparent)]
pub fn TextareaRoutes() -> impl MatchNestedRoutes + Clone {
view! {
<ParentRoute path=path!("/textarea") view=Outlet>
<Route path=path!("/") view=textarea::TextareaDemo />
<Route path=path!("/disabled") view=textarea_disabled::TextareaDisabledDemo />
<Route path=path!("/form") view=textarea_form::TextareaFormDemo />
<Route path=path!("/with-button") view=textarea_with_button::TextareaWithButtonDemo />
<Route path=path!("/with-label") view=textarea_with_label::TextareaWithLabelDemo />
<Route path=path!("/with-text") view=textarea_with_text::TextareaWithTextDemo />
</ParentRoute>
}
.into_inner()
}
10 changes: 10 additions & 0 deletions book-examples/leptos/src/new_york/textarea/textarea.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use leptos::prelude::*;

use crate::new_york::components::ui::textarea::Textarea;

#[component]
pub fn TextareaDemo() -> impl IntoView {
view! {
<Textarea placeholder="Type your message here." />
}
}
10 changes: 10 additions & 0 deletions book-examples/leptos/src/new_york/textarea/textarea_disabled.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use leptos::prelude::*;

use crate::new_york::components::ui::textarea::Textarea;

#[component]
pub fn TextareaDisabledDemo() -> impl IntoView {
view! {
<Textarea placeholder="Type your message here." disabled=true />
}
}
10 changes: 10 additions & 0 deletions book-examples/leptos/src/new_york/textarea/textarea_form.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use leptos::prelude::*;

use crate::new_york::components::ui::textarea::Textarea;

#[component]
pub fn TextareaFormDemo() -> impl IntoView {
view! {
<Textarea placeholder= "Need implementation!"></Textarea>
}
}
18 changes: 18 additions & 0 deletions book-examples/leptos/src/new_york/textarea/textarea_with_button.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use leptos::prelude::*;

use crate::new_york::components::ui::{button::Button, textarea::Textarea};

#[component]
pub fn TextareaWithButtonDemo() -> impl IntoView {
let text = RwSignal::new("".to_string());
view! {
<div class="grid w-full gap-2">
<Textarea placeholder="Type your message here." value=text />
<Button
onclick= Callback::new(move |_|{
text.set("Updated".to_string());
})
>"Send message"</Button>
</div>
}
}
13 changes: 13 additions & 0 deletions book-examples/leptos/src/new_york/textarea/textarea_with_label.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use leptos::prelude::*;

use crate::new_york::components::ui::textarea::Textarea;

#[component]
pub fn TextareaWithLabelDemo() -> impl IntoView {
view! {
<div class="grid w-full gap-1.5">
<label r#for="message">"Your message"</label>
<Textarea placeholder="Type your message here." id="message" />
</div>
}
}
16 changes: 16 additions & 0 deletions book-examples/leptos/src/new_york/textarea/textarea_with_text.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use leptos::prelude::*;

use crate::new_york::components::ui::textarea::Textarea;

#[component]
pub fn TextareaWithTextDemo() -> impl IntoView {
view! {
<div class="grid w-full gap-1.5">
<label r#for="message-2">"Your Message"</label>
<Textarea placeholder="Type your message here." id="message-2" />
<p class="text-sm text-muted-foreground">
{"Your message will be copied to the support team."}
</p>
</div>
}
}
19 changes: 19 additions & 0 deletions packages/leptos/textarea/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "shadcn-ui-leptos-textarea"
description = "Leptos port of shadcn/ui Textarea."
homepage = "https://shadcn-ui.rustforweb.org/components/textarea.html"
publish = false

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

[dependencies]
tailwind_fuse.workspace = true
leptos.workspace = true
leptos-style.workspace = true
leptos-node-ref.workspace = true
shadcn-ui-leptos-utils = { path = "../utils" }

21 changes: 21 additions & 0 deletions packages/leptos/textarea/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 shadcn/ui Logo">
</a>
</p>

<h1 align="center">shadcn-ui-leptos-textarea</h1>

Displays a form textarea or a component that looks like a textarea.

[Rust shadcn/ui](https://github.com/RustForWeb/shadcn-ui) is a Rust port of [shadcn/ui](https://ui.shadcn.com/).

## Documentation

See [the Rust shadcn/ui book](https://shadcn-ui.rustforweb.org/) for documentation.

## Rust For Web

The Rust shadcn/ui 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.
Loading
Loading