Skip to content

Commit

Permalink
Add textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Jun 13, 2024
1 parent fc997e0 commit 1888a60
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/leptos/textarea/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "shadcn-ui-leptos-textarea"
description = "Leptos port of shadcn/ui textarea."
publish = false

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

[dependencies]
leptos.workspace = true
tailwind_fuse.workspace = true
13 changes: 13 additions & 0 deletions packages/leptos/textarea/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<p align="center">
<a href="../../../logo.svg" alt="Rust shadcn/ui logo">
<img src="../../../logo.svg" width="300" height="200">
</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

[Rust shadcn/ui](https://github.com/NixySoftware/shadcn-ui) is a Rust port of [shadcn/ui](https://ui.shadcn.com/).
20 changes: 20 additions & 0 deletions packages/leptos/textarea/src/default.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use leptos::*;
use tailwind_fuse::*;

#[derive(TwClass)]
#[tw(
class = "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
)]
pub struct TextareaClass {}

#[component]
pub fn Textarea(
#[prop(into, optional)] class: MaybeSignal<String>,
#[prop(attrs)] attributes: Vec<(&'static str, Attribute)>,
) -> impl IntoView {
let class = create_memo(move |_| TextareaClass {}.with_class(class.get()));

view! {
<textarea {..attributes} class=class />
}
}
8 changes: 8 additions & 0 deletions packages/leptos/textarea/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Leptos port of [shadcn/ui textarea](https://ui.shadcn.com/docs/components/textarea).
//!
//! Displays a form textarea or a component that looks like a textarea.
//!
//! See <https://ui.shadcn.com/docs/components/textarea> for the original documentation.
pub mod default;
pub mod new_york;
20 changes: 20 additions & 0 deletions packages/leptos/textarea/src/new_york.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use leptos::*;
use tailwind_fuse::*;

#[derive(TwClass)]
#[tw(
class = "flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
)]
pub struct TextareaClass {}

#[component]
pub fn Textarea(
#[prop(into, optional)] class: MaybeSignal<String>,
#[prop(attrs)] attributes: Vec<(&'static str, Attribute)>,
) -> impl IntoView {
let class = create_memo(move |_| TextareaClass {}.with_class(class.get()));

view! {
<textarea {..attributes} class=class />
}
}

0 comments on commit 1888a60

Please sign in to comment.