windjammer_ui/components/generated/
chatinput.rs1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5pub struct ChatInput {
6 placeholder: String,
7 value: String,
8 disabled: bool,
9 multiline: bool,
10 rows: i32,
11}
12
13impl ChatInput {
14 #[inline]
15 pub fn new() -> ChatInput {
16 ChatInput {
17 placeholder: String::from("Type a message...".to_string()),
18 value: String::from("".to_string()),
19 disabled: false,
20 multiline: true,
21 rows: 3,
22 }
23 }
24 #[inline]
25 pub fn placeholder(mut self, placeholder: String) -> ChatInput {
26 self.placeholder = placeholder;
27 self
28 }
29 #[inline]
30 pub fn value(mut self, value: String) -> ChatInput {
31 self.value = value;
32 self
33 }
34 #[inline]
35 pub fn disabled(mut self, disabled: bool) -> ChatInput {
36 self.disabled = disabled;
37 self
38 }
39 #[inline]
40 pub fn multiline(mut self, multiline: bool) -> ChatInput {
41 self.multiline = multiline;
42 self
43 }
44 #[inline]
45 pub fn rows(mut self, rows: i32) -> ChatInput {
46 self.rows = rows;
47 self
48 }
49}
50
51impl Renderable for ChatInput {
52 #[inline]
53 fn render(self) -> String {
54 let disabled_attr = {
55 if self.disabled {
56 " disabled"
57 } else {
58 ""
59 }
60 };
61 let input_html = {
62 if self.multiline {
63 format!("<textarea class='wj-chat-input-field' placeholder='{}' rows='{}'{}>{}</textarea>", self.placeholder, self.rows, disabled_attr, self.value)
64 } else {
65 format!("<input type='text' class='wj-chat-input-field' placeholder='{}' value='{}'{}/>", self.placeholder, self.value, disabled_attr)
66 }
67 };
68 format!(
69 "<div class='wj-chat-input'>
70 {}
71 <button class='wj-chat-send-button'{}>
72 <span>➤</span>
73 </button>
74 </div>",
75 input_html, disabled_attr
76 )
77 }
78}