-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
93 additions
and
3 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
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
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
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
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,51 @@ | ||
# frozen_string_literal: true | ||
|
||
class Docs::TextareaView < ApplicationView | ||
def view_template | ||
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do | ||
render Docs::Header.new(title: "Textarea", description: "Displays a form textarea field or a component that looks like an textarea field.") | ||
|
||
TypographyH2 { "Usage" } | ||
|
||
render Docs::VisualCodeExample.new(title: "Textarea", context: self) do | ||
<<~RUBY | ||
div(class: "grid w-full max-w-sm items-center gap-1.5") do | ||
Textarea(placeholder: "Textarea") | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::VisualCodeExample.new(title: "Disabled", context: self) do | ||
<<~RUBY | ||
div(class: "grid w-full max-w-sm items-center gap-1.5") do | ||
Textarea(disabled: true, placeholder: "Disabled") | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::VisualCodeExample.new(title: "With FormField", context: self) do | ||
<<~RUBY | ||
div(class: "grid w-full max-w-sm items-center gap-1.5") do | ||
FormField do | ||
FormFieldLabel(for: "textarea") { "Textarea" } | ||
FormFieldHint { "This is a textarea" } | ||
Textarea(placeholder: "Textarea", id: "textarea") | ||
FormFieldError() | ||
end | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::ComponentsTable.new(components) | ||
end | ||
end | ||
|
||
private | ||
|
||
def components | ||
[ | ||
Docs::ComponentStruct.new(name: "InputController", source: "https://github.com/PhlexUI/phlex_ui_stimulus/blob/main/controllers/input_controller.js", built_using: :stimulus), | ||
Docs::ComponentStruct.new(name: "Textarea", source: "https://github.com/PhlexUI/phlex_ui/blob/main/lib/phlex_ui/input.rb", built_using: :phlex) | ||
] | ||
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
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,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module RBUI | ||
class TextareaPreview < Lookbook::Preview | ||
# Email Textarea | ||
# --------------- | ||
def email | ||
render(TestView.new) do | ||
Textarea(type: "email", placeholder: "Email", class: "max-w-sm") | ||
end | ||
end | ||
|
||
# Disabled Textarea | ||
def disabled | ||
render(TestView.new) do | ||
Textarea(disabled: true, type: "email", placeholder: "Email", class: "max-w-sm") | ||
end | ||
end | ||
|
||
# with error | ||
def with_error | ||
render(TestView.new) do | ||
Textarea( | ||
type: "email", | ||
placeholder: "Email", | ||
id: "email1", | ||
value: "joel@mail", | ||
error: "Invalid email address" | ||
) | ||
end | ||
end | ||
end | ||
end |