-
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.
Merge pull request #102 from PhlexUI/cirdes/add-form-component
Adding form Component
- Loading branch information
Showing
25 changed files
with
846 additions
and
656 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
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,147 @@ | ||
# frozen_string_literal: true | ||
|
||
class Docs::FormView < ApplicationView | ||
@@code_example = nil | ||
|
||
def view_template | ||
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do | ||
render Docs::Header.new(title: "Form", description: "Building forms with built-in client-side validations.") | ||
|
||
TypographyH2 { "Usage" } | ||
|
||
render Docs::VisualCodeExample.new(title: "Example", context: self) do | ||
@@code_example = <<~RUBY | ||
Form(class: "w-2/3 space-y-6") do | ||
FormField do | ||
FormFieldLabel { "Default error" } | ||
Input(placeholder: "Joel Drapper", required: true, minlength: "3") { "Joel Drapper" } | ||
FormFieldHint() | ||
FormFieldError() | ||
end | ||
Button(type: "submit") { "Save" } | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::VisualCodeExample.new(title: "Custom error message", context: self) do | ||
<<~RUBY | ||
Form(class: "w-2/3 space-y-6") do | ||
FormField do | ||
FormFieldLabel { "Custom error message" } | ||
Input(placeholder: "[email protected]", required: true, data_value_missing: "Custom error message") | ||
FormFieldError() | ||
end | ||
Button(type: "submit") { "Save" } | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::VisualCodeExample.new(title: "Backend error", context: self) do | ||
<<~RUBY | ||
Form(class: "w-2/3 space-y-6") do | ||
FormField do | ||
FormFieldLabel { "Backend error" } | ||
Input(placeholder: "Joel Drapper", required: true) | ||
FormFieldError { "Error from backend" } | ||
end | ||
Button(type: "submit") { "Save" } | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::VisualCodeExample.new(title: "Checkbox", context: self) do | ||
<<~RUBY | ||
Form(class: "w-2/3 space-y-6") do | ||
FormField do | ||
Checkbox(required: true) | ||
label( | ||
class: | ||
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" | ||
) { " Accept terms and conditions " } | ||
FormFieldError() | ||
end | ||
Button(type: "submit") { "Save" } | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::VisualCodeExample.new(title: "Select", context: self) do | ||
<<~RUBY | ||
Form(class: "w-2/3 space-y-6") do | ||
FormField do | ||
FormFieldLabel { "Select" } | ||
Select do | ||
SelectInput(required: true) | ||
SelectTrigger do | ||
SelectValue(placeholder: "Select a fruit") | ||
end | ||
SelectContent() do | ||
SelectGroup do | ||
SelectLabel { "Fruits" } | ||
SelectItem(value: "apple") { "Apple" } | ||
SelectItem(value: "orange") { "Orange" } | ||
SelectItem(value: "banana") { "Banana" } | ||
SelectItem(value: "watermelon") { "Watermelon" } | ||
end | ||
end | ||
end | ||
FormFieldError() | ||
end | ||
Button(type: "submit") { "Save" } | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::VisualCodeExample.new(title: "Combobox", context: self) do | ||
<<~RUBY | ||
Form(class: "w-2/3 space-y-6") do | ||
FormField do | ||
FormFieldLabel { "Combobox" } | ||
Combobox do | ||
ComboboxInput(required: true) | ||
ComboboxTrigger do | ||
ComboboxValue(placeholder: "Select event...") | ||
end | ||
ComboboxContent do | ||
ComboboxSearchInput(placeholder: "Search event...") | ||
ComboboxList do | ||
ComboboxEmpty { "No results found." } | ||
ComboboxGroup(heading: "Suggestions") do | ||
ComboboxItem(value: "railsworld") do | ||
span { "Rails World" } | ||
end | ||
ComboboxItem(value: "tropicalrb") do | ||
span { "Tropical.rb" } | ||
end | ||
ComboboxItem(value: "friendly.rb") do | ||
span { "Friendly.rb" } | ||
end | ||
end | ||
ComboboxSeparator() | ||
ComboboxGroup(heading: "Others") do | ||
ComboboxItem(value: "railsconf") do | ||
span { "RailsConf" } | ||
end | ||
ComboboxItem(value: "euruko") do | ||
span { "Euruko" } | ||
end | ||
ComboboxItem(value: "rubykaigi") do | ||
span { "RubyKaigi" } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
FormFieldError() | ||
end | ||
Button(type: "submit") { "Save" } | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::ComponentsTable.new(components("Form", @@code_example), component_files("Form")) | ||
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
Oops, something went wrong.