Skip to content

Commit 161b003

Browse files
committed
add support for tel input & update readme file
1 parent d8d78cb commit 161b003

File tree

6 files changed

+2125
-51
lines changed

6 files changed

+2125
-51
lines changed

README.md

+49-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
# 💡 Input Yew
22

3-
![text-demo](./assets/text-demo.gif)
4-
![pass-demo](./assets/pass-demo.gif)
5-
![textarea-demo](./assets/textarea-demo.gif)
3+
[![Crates.io](https://img.shields.io/crates/v/input_yew)](https://crates.io/crates/input_yew)
4+
[![Crates.io Downloads](https://img.shields.io/crates/d/input_yew)](https://crates.io/crates/input_yew)
5+
![Crates.io License](https://img.shields.io/crates/l/input_yew)
6+
![Rust](https://img.shields.io/badge/rust-stable-orange)
7+
8+
![logo](./assets/logo.png)
9+
10+
## 🎬 Demo
11+
12+
| Input Type | Demo |
13+
| --- | --- |
14+
| Text Input | ![text-demo](./assets/text-demo.gif) |
15+
| Textarea Input | ![pass-demo](./assets/pass-demo.gif) |
16+
| Text Input | ![textarea-demo](./assets/textarea-demo.gif) |
17+
| Telephone Input | ![tel-demo](./assets/tel-demo.gif) |
618

719
## 📜 Prologue
820

@@ -20,7 +32,7 @@ The Yew Custom Reusable Input Component is a powerful tool designed to make your
2032

2133
1. 🎫 Event Handling: The component exposes the `oninput` event handler, making it super easy to implement dynamic behavior based on your interactions.
2234

23-
1. ♿ Accessibility: This compoenent was designed with accessibility in mind, ensuring that it's user-friendly and perceivable by all, regardless of ability.
35+
1. ♿ Accessibility: This component was designed with accessibility in mind, ensuring that it's user-friendly and perceivable by all, regardless of ability.
2436

2537
1. ❌ Error Handling: When users provide invalid input, the component gracefully displays clear error messages, guiding them towards valid data entry and enhancing the overall user experience.
2638

@@ -33,7 +45,7 @@ You can quickly integrate the Yew Custom Reusable Input Component into your Yew
3345
2. Then, install the input component package using your preferred package manager:
3446

3547
```bash
36-
$ cargo add input-yew
48+
$ cargo add input_yew
3749
```
3850

3951
3. Finally, import the component into your Yew application and start using it to power up your forms and user interactions.
@@ -45,8 +57,9 @@ Using this custom reusable input component is a breeze! Simply follow these step
4557
1. Import the component into your Yew application:
4658

4759
```rust
48-
// Add these lines at the beginning of your file
60+
// Add these lines at the beginning of your file, make sure you have `regex` installed for input validation.
4961
use yew::prelude::*;
62+
use regex::Regex;
5063
use input_yew::CustomInput;
5164
```
5265

@@ -68,19 +81,15 @@ Using this custom reusable input component is a breeze! Simply follow these step
6881
html! {
6982
<form action="#" aria-label="Sign In Form" onsubmit={onsubmit}>
7083
<CustomInput
71-
input_type={Some("text".to_string())}
72-
label={"".to_string()}
84+
input_type={"text".to_string()}
7385
input_handle={input_email_handle}
7486
name={"email".to_string()}
7587
input_ref={input_email_ref}
7688
input_placeholder={"Email".to_string()}
7789
icon_class={"fas fa-user".to_string()}
7890
icon={"fas fa-user".to_string()}
7991
error_message={"Enter a valid email address".to_string()}
80-
form_input_class={"".to_string()}
8192
form_input_field_class={"form-one-field".to_string()}
82-
form_input_label_class={"".to_string()}
83-
form_input_input_class={"".to_string()}
8493
form_input_error_class={"error-txt".to_string()}
8594
required={true}
8695
input_valid_handle={email_valid_handle}
@@ -93,6 +102,34 @@ Using this custom reusable input component is a breeze! Simply follow these step
93102

94103
1. Customize the input component's appearance and behavior according to your project requirements.
95104

105+
## 🔧 Props
106+
107+
| Name | Type | Description | Example |
108+
| --- | --- | --- | --- |
109+
| input_type | Option<String> | The type of the input. | "text", "password", "tel, "textarea", "date". |
110+
| label | Option<String> | The label to be displayed for the input field. | "Username", "Email". |
111+
| name | Option<String> | The name of the input field, used for form submission and accessibility. | "username", "email". |
112+
| required | Option<bool> | Indicates whether the input is required or not. | true, false. |
113+
| input_ref | NodeRef | A reference to the DOM node of the input element. | `use_node_ref()`, |
114+
| error_message | Option<String> | The error message to display when there is a validation error. | "Invalid input", "Field is required". |
115+
| form_input_class | Option<String> | The CSS class to be applied to all inner elements. | "form-input-container", "input-group". |
116+
| form_input_field_class | Option<String> | The CSS class to be applied to the inner input element and icon. | "form-input-field", "input-icon". |
117+
| form_input_label_class | Option<String> | The CSS class to be applied to the label for the input element. | "form-input-label". |
118+
| form_input_input_class | Option<String> | The CSS class to be applied to the input element. | "custom-input". |
119+
| form_input_error_class | Option<String> | The CSS class to be applied to the error div element. | "input-error-message". |
120+
| icon_class | Option<String> | The CSS class to be applied to the start icon element. | "input-icon". |
121+
| input_handle | UseStateHandle<String> | The state handle for managing the value of the input. | use_state("initial value".into()).handle(), |
122+
| input_valid_handle | UseStateHandle<bool> | The state handle for managing the validity state of the input. | use_state(true).handle(), |
123+
| validate_function | Callback<String, bool> | A callback function to validate the input value. It takes a `String` as input and returns a `bool`. | Callback::from(|value: String| value.len() >= 8), |
124+
| eye_active | Option<String> | The icon when the password is visible. | "fa fa-eye" in case of using **FontAwesome**. |
125+
| eye_disabled | Option<String> | The icon when the password is not visible. | "fa fa-eye-slash" in case of using **FontAwesome**. |
126+
| input_id | Option<String> | The ID attribute of the input element. | "input-username", "input-email". |
127+
| input_placeholder | Option<String> | The placeholder text to be displayed in the input element. | "Enter your username", "Type your email". |
128+
| aria_label | Option<String> | The aria-label attribute for screen readers, providing a label for accessibility. | "Username input", "Email input". |
129+
| aria_required | Option<String> | The aria-required attribute for screen readers, indicating whether the input is required. | "true", "false". |
130+
| aria_invalid | Option<String> | The aria-invalid attribute for screen readers, indicating whether the input value is invalid. | "true", "false". |
131+
| aria_describedby | Option<String> | The aria-describedby attribute for screen readers, describing the input element's error message. | "error-message-username", "error-message-email". |
132+
96133
## 📙 Examples
97134
98135
Lots of repositories we built use it to create even more sophisticated forms like Contact Us forms, multi-step forms, and login forms. If you're curious about how to use it, you can check out the following repositories for more information:
@@ -110,4 +147,4 @@ The Yew Custom Reusable Input Component is licensed under the `Apache-2.0` Licen
110147
111148
## 📝 Epilogue
112149
113-
Congratulations! You're now equipped with a fantastic Yew Custom Reusable Input Component that will supercharge your web applications with its flexibility, user-friendliness, and robustness. Happy coding, and may your projects thrive with this powerful tool! 🎉
150+
Congratulations! You're now equipped with a fantastic Yew Custom Reusable Input Component that will supercharge your web applications with its flexibility, user-friendliness, and robustness. Happy coding, and may your projects thrive with this powerful tool! 🎉

assets/logo.png

374 KB
Loading

assets/tel-demo.gif

563 KB
Loading

0 commit comments

Comments
 (0)