Skip to content

Commit 68422c5

Browse files
authored
disabled + aria-disabled for Form and Input (#229)
* disabled + aria-disabled examples for Combobox * disabled + aria-disabled for Form and Input * OOPS
1 parent bdd19ec commit 68422c5

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

app/components/ruby_ui/form/form_field_label.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ def view_template(&)
99
private
1010

1111
def default_attrs
12-
{class: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"}
12+
{
13+
class: [
14+
"text-sm font-medium leading-none",
15+
"peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
16+
"peer-aria-disabled:cursor-not-allowed peer-aria-disabled:opacity-70 peer-aria-disabled:pointer-events-none"
17+
]
18+
}
1319
end
1420
end
1521
end

app/components/ruby_ui/input/input.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ def default_attrs
1919
ruby_ui__form_field_target: "input",
2020
action: "input->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid"
2121
},
22-
class: "flex h-9 w-full rounded-md border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 border-border focus-visible:ring-ring placeholder:text-muted-foreground"
22+
class: [
23+
"flex h-9 w-full rounded-md border bg-background px-3 py-1 text-sm shadow-sm transition-colors border-border",
24+
"placeholder:text-muted-foreground",
25+
"disabled:cursor-not-allowed disabled:opacity-50",
26+
"file:border-0 file:bg-transparent file:text-sm file:font-medium",
27+
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
28+
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none"
29+
]
2330
}
2431
end
2532
end

app/views/docs/form.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ def view_template
2222
RUBY
2323
end
2424

25+
render Docs::VisualCodeExample.new(title: "Disabled", context: self) do
26+
<<~RUBY
27+
FormField do
28+
FormFieldLabel { "Disabled" }
29+
Input(disabled: true, placeholder: "Joel Drapper", required: true, minlength: "3") { "Joel Drapper" }
30+
end
31+
RUBY
32+
end
33+
34+
render Docs::VisualCodeExample.new(title: "Aria Disabled", context: self) do
35+
<<~RUBY
36+
FormField do
37+
FormFieldLabel { "Aria Disabled" }
38+
Input(aria: {disabled: "true"}, placeholder: "Joel Drapper", required: true, minlength: "3") { "Joel Drapper" }
39+
end
40+
RUBY
41+
end
42+
2543
render Docs::VisualCodeExample.new(title: "Custom error message", context: self) do
2644
<<~RUBY
2745
Form(class: "w-2/3 space-y-6") do

app/views/docs/input.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ def view_template
3434
RUBY
3535
end
3636

37+
render Docs::VisualCodeExample.new(title: "Aria Disabled", context: self) do
38+
<<~RUBY
39+
div(class: 'grid w-full max-w-sm items-center gap-1.5') do
40+
Input(aria: {disabled: "true"}, type: "email", placeholder: "Email")
41+
end
42+
RUBY
43+
end
44+
3745
render Docs::VisualCodeExample.new(title: "With label", context: self) do
3846
<<~RUBY
3947
div(class: 'grid w-full max-w-sm items-center gap-1.5') do

0 commit comments

Comments
 (0)