Skip to content

Commit 22fafcc

Browse files
committed
ADD TEXTAREA
1 parent fdc7dca commit 22fafcc

File tree

7 files changed

+93
-3
lines changed

7 files changed

+93
-3
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
GIT
22
remote: https://github.com/rbui-labs/rbui.git
3-
revision: 19a1b5df2db0e000a21b9b2c5a573179c07506be
3+
revision: abb3ec1e5971413d4930ce4a56f688b7acb66a5e
44
specs:
5-
rbui (0.2.0)
5+
rbui (1.0.0.pre.alpha.3)
66
phlex (~> 1.10)
77
rouge (~> 4.2.0)
88
tailwind_merge (>= 0.12)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Here is the list of components that are being built. For reference, see here htt
4343
⚪️ Switch
4444
⚪️ Table
4545
✅ Tabs
46-
⚪️ Textarea
46+
Textarea
4747
⚪️ Toast
4848
⚪️ Toggle
4949
✅ Tooltip

app/controllers/docs_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ def tabs
158158
render Docs::TabsView.new
159159
end
160160

161+
def textarea
162+
render Docs::TextareaView.new
163+
end
164+
161165
def theme_toggle
162166
render Docs::ThemeToggleView.new
163167
end

app/views/components/shared/menu.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def components
9292
{name: "Shortcut Key", path: helpers.docs_shortcut_key_path},
9393
{name: "Table", path: helpers.docs_table_path},
9494
{name: "Tabs", path: helpers.docs_tabs_path},
95+
{name: "Textarea", path: helpers.docs_textarea_path},
9596
{name: "Theme Toggle", path: helpers.docs_theme_toggle_path},
9697
{name: "Tooltip", path: helpers.docs_tooltip_path},
9798
{name: "Typography", path: helpers.docs_typography_path}

app/views/docs/textarea_view.rb

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# frozen_string_literal: true
2+
3+
class Docs::TextareaView < ApplicationView
4+
def view_template
5+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
6+
render Docs::Header.new(title: "Textarea", description: "Displays a form textarea field or a component that looks like an textarea field.")
7+
8+
TypographyH2 { "Usage" }
9+
10+
render Docs::VisualCodeExample.new(title: "Textarea", context: self) do
11+
<<~RUBY
12+
div(class: "grid w-full max-w-sm items-center gap-1.5") do
13+
Textarea(placeholder: "Textarea")
14+
end
15+
RUBY
16+
end
17+
18+
render Docs::VisualCodeExample.new(title: "Disabled", context: self) do
19+
<<~RUBY
20+
div(class: "grid w-full max-w-sm items-center gap-1.5") do
21+
Textarea(disabled: true, placeholder: "Disabled")
22+
end
23+
RUBY
24+
end
25+
26+
render Docs::VisualCodeExample.new(title: "With FormField", context: self) do
27+
<<~RUBY
28+
div(class: "grid w-full max-w-sm items-center gap-1.5") do
29+
FormField do
30+
FormFieldLabel(for: "textarea") { "Textarea" }
31+
FormFieldHint { "This is a textarea" }
32+
Textarea(placeholder: "Textarea", id: "textarea")
33+
FormFieldError()
34+
end
35+
end
36+
RUBY
37+
end
38+
39+
render Docs::ComponentsTable.new(components)
40+
end
41+
end
42+
43+
private
44+
45+
def components
46+
[
47+
Docs::ComponentStruct.new(name: "InputController", source: "https://github.com/PhlexUI/phlex_ui_stimulus/blob/main/controllers/input_controller.js", built_using: :stimulus),
48+
Docs::ComponentStruct.new(name: "Textarea", source: "https://github.com/PhlexUI/phlex_ui/blob/main/lib/phlex_ui/input.rb", built_using: :phlex)
49+
]
50+
end
51+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
get "shortcut_key", to: "docs#shortcut_key", as: :docs_shortcut_key
4848
get "table", to: "docs#table", as: :docs_table
4949
get "tabs", to: "docs#tabs", as: :docs_tabs
50+
get "textarea", to: "docs#textarea", as: :docs_textarea
5051
get "theme_toggle", to: "docs#theme_toggle", as: :docs_theme_toggle
5152
get "tooltip", to: "docs#tooltip", as: :docs_tooltip
5253
get "typography", to: "docs#typography", as: :docs_typography
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
3+
module RBUI
4+
class TextareaPreview < Lookbook::Preview
5+
# Email Textarea
6+
# ---------------
7+
def email
8+
render(TestView.new) do
9+
Textarea(type: "email", placeholder: "Email", class: "max-w-sm")
10+
end
11+
end
12+
13+
# Disabled Textarea
14+
def disabled
15+
render(TestView.new) do
16+
Textarea(disabled: true, type: "email", placeholder: "Email", class: "max-w-sm")
17+
end
18+
end
19+
20+
# with error
21+
def with_error
22+
render(TestView.new) do
23+
Textarea(
24+
type: "email",
25+
placeholder: "Email",
26+
id: "email1",
27+
value: "joel@mail",
28+
error: "Invalid email address"
29+
)
30+
end
31+
end
32+
end
33+
end

0 commit comments

Comments
 (0)