Skip to content

Commit 16f29f0

Browse files
committed
aria-disabled for Sheet
1 parent e4264da commit 16f29f0

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

lib/ruby_ui/sheet/sheet_content.rb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def view_template(&block)
1919
template(data: {ruby_ui__sheet_target: "content"}) do
2020
div(data: {controller: "ruby-ui--sheet-content"}) do
2121
backdrop
22+
2223
div(**attrs) do
2324
block&.call
2425
close_button
@@ -33,7 +34,9 @@ def default_attrs
3334
{
3435
data_state: "open", # For animate in
3536
class: [
36-
"fixed pointer-events-auto z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
37+
"fixed pointer-events-auto z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out",
38+
"data-[state=open]:animate-in data-[state=open]:duration-500",
39+
"data-[state=closed]:animate-out data-[state=closed]:duration-300",
3740
@side_classes
3841
]
3942
}
@@ -42,8 +45,15 @@ def default_attrs
4245
def close_button
4346
button(
4447
type: "button",
45-
class: "absolute end-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
46-
data_action: "click->ruby-ui--sheet-content#close"
48+
data_action: "click->ruby-ui--sheet-content#close",
49+
class: [
50+
"absolute end-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity",
51+
"hover:opacity-100",
52+
"disabled:pointer-events-none",
53+
"data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
54+
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
55+
"aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed"
56+
]
4757
) do
4858
svg(
4959
width: "15",
@@ -54,13 +64,13 @@ def close_button
5464
class: "h-4 w-4"
5565
) do |s|
5666
s.path(
57-
d:
58-
"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
67+
d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
5968
fill: "currentColor",
6069
fill_rule: "evenodd",
6170
clip_rule: "evenodd"
6271
)
6372
end
73+
6474
span(class: "sr-only") { "Close" }
6575
end
6676
end
@@ -69,8 +79,11 @@ def backdrop
6979
div(
7080
data_state: "open",
7181
data_action: "click->ruby-ui--sheet-content#close",
72-
class:
73-
"fixed pointer-events-auto inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
82+
class: [
83+
"fixed pointer-events-auto inset-0 z-50 bg-background/80 backdrop-blur-sm",
84+
"data-[state=open]:animate-in data-[state=open]:fade-in-0",
85+
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0"
86+
]
7487
)
7588
end
7689
end

0 commit comments

Comments
 (0)