forked from ontoportal/ontoportal_web_ui
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add email, password, url components to lookbook
- Loading branch information
1 parent
527f9a2
commit 205bb52
Showing
9 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class Input::EmailComponent < InputFieldComponent | ||
def initialize(label: '', name:, value: nil, placeholder: '', error_message: '', helper_text: '') | ||
super(label: label, name: name, value: value, placeholder: placeholder, error_message: error_message, helper_text: helper_text) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= render InputFieldComponent.new(label: @label, name: @name, value: @value, placeholder: @placeholder, error_message: @error_message, helper_text: @helper_text, type: "email") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class Input::PasswordComponent < InputFieldComponent | ||
def initialize(label: '', name:, value: nil, placeholder: '', error_message: '', helper_text: '') | ||
super(label: label, name: name, value: value, placeholder: placeholder, error_message: error_message, helper_text: helper_text) | ||
end | ||
end |
1 change: 1 addition & 0 deletions
1
app/components/input/password_component/password_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= render InputFieldComponent.new(label: @label, name: @name, value: @value, placeholder: @placeholder, error_message: @error_message, helper_text: @helper_text, type: "password") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class Input::UrlComponent < InputFieldComponent | ||
def initialize(label: '', name:, value: nil, placeholder: '', error_message: '', helper_text: '') | ||
super(label: label, name: name, value: value, placeholder: placeholder, error_message: error_message, helper_text: helper_text) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= render InputFieldComponent.new(label: @label, name: @name, value: @value, placeholder: @placeholder, error_message: @error_message, helper_text: @helper_text, type: "url") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class Input::EmailComponentPreview < ViewComponent::Preview | ||
def default | ||
# This is a url input field: | ||
# - To use it without a label: don't give a value to the param label or leave it empty. | ||
# - To put it in error state: define the param error_message with the error message you want to be displayed. | ||
# - To give it a helper text (a text displayed under the input field): define the param helper_text with the helper text you want to be displayed. | ||
# @param label text | ||
# @param error_message text | ||
# @param helper_text text | ||
|
||
def default(label: "Label", placeholder: "", error_message: "", helper_text: "") | ||
render Input::EmailComponent.new(label: label, name: "name", placeholder: placeholder, error_message: error_message, helper_text: helper_text) | ||
end | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
test/components/previews/input/password_component_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class Input::PasswordComponentPreview < ViewComponent::Preview | ||
def default | ||
# This is a url input field: | ||
# - To use it without a label: don't give a value to the param label or leave it empty. | ||
# - To put it in error state: define the param error_message with the error message you want to be displayed. | ||
# - To give it a helper text (a text displayed under the input field): define the param helper_text with the helper text you want to be displayed. | ||
# @param label text | ||
# @param error_message text | ||
# @param helper_text text | ||
|
||
def default(label: "Label", placeholder: "", error_message: "", helper_text: "") | ||
render Input::PasswordComponent.new(label: label, name: "name", placeholder: placeholder, error_message: error_message, helper_text: helper_text) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class Input::UrlComponentPreview < ViewComponent::Preview | ||
def default | ||
# This is a url input field: | ||
# - To use it without a label: don't give a value to the param label or leave it empty. | ||
# - To put it in error state: define the param error_message with the error message you want to be displayed. | ||
# - To give it a helper text (a text displayed under the input field): define the param helper_text with the helper text you want to be displayed. | ||
# @param label text | ||
# @param error_message text | ||
# @param helper_text text | ||
|
||
def default(label: "Label", placeholder: "", error_message: "", helper_text: "") | ||
render Input::UrlComponent.new(label: label, name: "name", placeholder: placeholder, error_message: error_message, helper_text: helper_text) | ||
end | ||
end | ||
end |