Skip to content

Commit 9c22d53

Browse files
committed
aria-disabled for Dialog
1 parent e4264da commit 9c22d53

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

lib/ruby_ui/dialog/dialog_content.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def view_template
2020
template(data: {ruby_ui__dialog_target: "content"}) do
2121
div(data_controller: "ruby-ui--dialog") do
2222
backdrop
23+
2324
div(**attrs) do
2425
yield
2526
close_button
@@ -34,7 +35,11 @@ def default_attrs
3435
{
3536
data_state: "open",
3637
class: [
37-
"fixed flex flex-col pointer-events-auto left-[50%] top-[50%] z-50 w-full max-h-screen overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",
38+
"fixed flex flex-col pointer-events-auto left-[50%] top-[50%] z-50 w-full max-h-screen overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200",
39+
"md:w-full",
40+
"sm:rounded-lg",
41+
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",
42+
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]",
3843
SIZES[@size]
3944
]
4045
}
@@ -43,7 +48,14 @@ def default_attrs
4348
def close_button
4449
button(
4550
type: "button",
46-
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",
51+
class: [
52+
"absolute end-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity",
53+
"hover:opacity-100",
54+
"disabled:pointer-events-none disabled:opacity-50",
55+
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
56+
"data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
57+
"aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed"
58+
],
4759
data_action: "click->ruby-ui--dialog#dismiss"
4860
) do
4961
svg(
@@ -55,8 +67,7 @@ def close_button
5567
class: "h-4 w-4"
5668
) do |s|
5769
s.path(
58-
d:
59-
"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",
70+
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",
6071
fill: "currentColor",
6172
fill_rule: "evenodd",
6273
clip_rule: "evenodd"
@@ -70,8 +81,7 @@ def backdrop
7081
div(
7182
data_state: "open",
7283
data_action: "click->ruby-ui--dialog#dismiss esc->ruby-ui--dialog#dismiss",
73-
class:
74-
"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"
84+
class: "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"
7585
)
7686
end
7787
end

0 commit comments

Comments
 (0)