You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -20,7 +32,7 @@ The Yew Custom Reusable Input Component is a powerful tool designed to make your
20
32
21
33
1. 🎫 Event Handling: The component exposes the `oninput` event handler, making it super easy to implement dynamic behavior based on your interactions.
22
34
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.
24
36
25
37
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.
26
38
@@ -33,7 +45,7 @@ You can quickly integrate the Yew Custom Reusable Input Component into your Yew
33
45
2. Then, install the input component package using your preferred package manager:
34
46
35
47
```bash
36
-
$ cargo add input-yew
48
+
$ cargo add input_yew
37
49
```
38
50
39
51
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
45
57
1. Import the component into your Yew application:
46
58
47
59
```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.
49
61
useyew::prelude::*;
62
+
useregex::Regex;
50
63
useinput_yew::CustomInput;
51
64
```
52
65
@@ -68,19 +81,15 @@ Using this custom reusable input component is a breeze! Simply follow these step
68
81
html! {
69
82
<formaction="#"aria-label="Sign In Form"onsubmit={onsubmit}>
70
83
<CustomInput
71
-
input_type={Some("text".to_string())}
72
-
label={"".to_string()}
84
+
input_type={"text".to_string()}
73
85
input_handle={input_email_handle}
74
86
name={"email".to_string()}
75
87
input_ref={input_email_ref}
76
88
input_placeholder={"Email".to_string()}
77
89
icon_class={"fas fa-user".to_string()}
78
90
icon={"fas fa-user".to_string()}
79
91
error_message={"Enter a valid email address".to_string()}
| 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. | "Invalidinput", "Fieldisrequired". |
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("initialvalue".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. | "fafa-eye" in case of using **FontAwesome**. |
125
+
| eye_disabled | Option<String> | The icon when the password is not visible. | "fafa-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. | "Enteryourusername", "Typeyouremail". |
128
+
| aria_label | Option<String> | The aria-label attribute for screen readers, providing a label for accessibility. | "Usernameinput", "Emailinput". |
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
+
96
133
## 📙 Examples
97
134
98
135
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
110
147
111
148
## 📝 Epilogue
112
149
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! 🎉
0 commit comments