// Input component - Pure Windjammer implementation
use super::traits::Renderable
pub struct Input {
value: string,
placeholder: string,
input_type: string,
}
impl Input {
pub fn new() -> Input {
Input {
value: "".to_string(),
placeholder: "".to_string(),
input_type: "text".to_string(),
}
}
pub fn value(self, value: string) -> Input {
self.value = value
self
}
pub fn placeholder(self, placeholder: string) -> Input {
self.placeholder = placeholder
self
}
pub fn input_type(self, input_type: string) -> Input {
self.input_type = input_type
self
}
}
impl Renderable for Input {
fn render(self) -> string {
format!("<input class='wj-input' type='{}' value='{}' placeholder='{}'/>",
self.input_type, self.value, self.placeholder)
}
}
fn main() {
let input = Input::new()
.value("Hello".to_string())
.placeholder("Enter text...".to_string())
println!("{}", input.render())
}