generated from mitchell/rust_template
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
use leptos::View;
|
|
|
|
use crate::{ControlBuilder, ControlData, FormBuilder, FormData, FormStyleProvider};
|
|
|
|
pub struct TextAreaData {
|
|
pub(crate) name: String,
|
|
pub(crate) placeholder: Option<String>,
|
|
}
|
|
|
|
impl TextAreaData {
|
|
fn new(name: String) -> Self {
|
|
TextAreaData {
|
|
name,
|
|
placeholder: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<FS: FormStyleProvider> ControlData<FS> for TextAreaData {
|
|
fn build_control(self, fs: &FS, attributes: Vec<FS::StylingAttributes>) -> View {
|
|
fs.text_area(self, attributes)
|
|
}
|
|
}
|
|
|
|
impl<FD: FormData, FS: FormStyleProvider> FormBuilder<FD, FS> {
|
|
pub fn text_area(self, name: impl ToString) -> ControlBuilder<FD, FS, TextAreaData> {
|
|
ControlBuilder {
|
|
fb: self,
|
|
parse_fn: None,
|
|
style_attributes: Vec::new(),
|
|
data: TextAreaData::new(name.to_string()),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<FD: FormData, FS: FormStyleProvider> ControlBuilder<FD, FS, TextAreaData> {
|
|
pub fn placeholder(mut self, placeholder: impl ToString) -> Self {
|
|
self.data.placeholder = Some(placeholder.to_string());
|
|
self
|
|
}
|
|
}
|