Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

input with error#1399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
levkk merged 1 commit intomasterfromlevkk-input-wiith-error
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletionspgml-dashboard/src/components/inputs/text/input/input.scss
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
div[data-controller="inputs-text-input"] {
--bs-danger: #{$peach-shade-100};

span.material-symbols-outlined {
margin-left: -40px;
color: #{$slate-shade-100};

&.is-invalid {
color: var(--bs-danger);
}
}

input.form-control {
Expand All@@ -12,4 +18,10 @@ div[data-controller="inputs-text-input"] {
label.form-label {
font-weight: #{$font-weight-normal};
}

p {
small {
color: var(--bs-danger);
}
}
}
7 changes: 7 additions & 0 deletionspgml-dashboard/src/components/inputs/text/input/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ pub struct Input {
autocomplete: bool,
value: String,
required: bool,
error: Option<String>,
}

impl Input {
Expand All@@ -38,6 +39,7 @@ impl Input {
autocomplete: false,
value: "".to_string(),
required: false,
error: None,
}
}

Expand DownExpand Up@@ -90,6 +92,11 @@ impl Input {
self.required = true;
self
}

pub fn error(mut self, error: Option<impl ToString>) -> Self {
self.error = error.map(|e| e.to_string());
self
}
}

component!(Input);
15 changes: 13 additions & 2 deletionspgml-dashboard/src/components/inputs/text/input/template.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
<% let (input_classes, icon_classes) = if error.is_some() {
("form-control is-invalid", "material-symbols-outlined is-invalid")
} else {
("form-control", "material-symbols-outlined")
};
%>
<div data-controller="inputs-text-input">
<% if let Some(label) = label { %>
<label class="form-label" for="<%= id %>"><%+ label %></label>
Expand All@@ -8,7 +14,7 @@
id="<%= id %>"
type="<%= type_ %>"
name="<%= name %>"
class="form-control"
class="<%= input_classes %>"
placeholder="<%= placeholder %>"
data-action="<%= input_actions %>"
autocomplete="<%= autocomplete %>"
Expand All@@ -20,10 +26,15 @@

<% if let Some(icon) = icon { %>
<span
class="material-symbols-outlined"
class="<%= icon_classes %>"
data-action="<%= icon_actions %>">
<%= icon %>
</span>
<% } %>
</div>
<% if let Some(error) = error { %>
<p class="mt-1 mb-0">
<small><%= error %></small>
</p>
<% } %>
</div>
10 changes: 10 additions & 0 deletionspgml-dashboard/src/components/pages/demo/template.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,6 +58,16 @@
.type_("text") %>
</div>

<div class="py-5">
<%+ Input::new()
.label("What is your name?".into())
.icon("person")
.placeholder("Enter your name")
.name("name")
.type_("text")
.error(Some("Your name is not valid.")) %>
</div>

<div class="py-5">
<%+ Search::new(SearchOptions {
name: "Model search".into(),
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp