Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gem/lib/ruby_ui/alert_dialog/alert_dialog_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def view_template(&block)
def background
div(
data_state: "open",
class: "fixed inset-0 z-50 bg-black/80 backdrop-blur-sm data-[state=open]:animate-in",
class: "fixed inset-0 z-50 bg-black/10 supports-backdrop-filter:backdrop-blur-xs data-[state=open]:animate-in",
style: "pointer-events:auto",
data_aria_hidden: "true",
aria_hidden: "true"
Expand Down
2 changes: 1 addition & 1 deletion gem/lib/ruby_ui/command/command_dialog_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def backdrop
data_state: "open",
data_action: "click->ruby-ui--command#dismiss esc->ruby-ui--command#dismiss",
data_ruby_ui__command_target: "backdrop",
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 data-[state=closed]:fill-mode-forwards"
class: "fixed pointer-events-auto inset-0 z-50 bg-black/10 supports-backdrop-filter:backdrop-blur-xs 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]:fill-mode-forwards"
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion gem/lib/ruby_ui/dialog/dialog_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def default_attrs
data_ruby_ui__dialog_target: "dialog",
data_action: "click->ruby-ui--dialog#backdropClick",
class: [
"fixed open: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 backdrop:bg-background/80 backdrop:backdrop-blur-sm open:animate-in open:fade-in-0 open:zoom-in-95 sm:rounded-lg md:w-full",
"fixed open: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 backdrop:bg-black/10 backdrop:supports-backdrop-filter:backdrop-blur-xs open:animate-in open:fade-in-0 open:zoom-in-95 sm:rounded-lg md:w-full",
SIZES[@size]
]
}
Expand Down
2 changes: 1 addition & 1 deletion gem/lib/ruby_ui/sheet/sheet_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def backdrop
data_action: "click->ruby-ui--sheet-content#close",
data_ruby_ui__sheet_content_target: "backdrop",
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 data-[state=closed]:fill-mode-forwards"
"fixed pointer-events-auto inset-0 z-50 bg-black/10 supports-backdrop-filter:backdrop-blur-xs 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]:fill-mode-forwards"
)
end
end
Expand Down
11 changes: 11 additions & 0 deletions gem/test/ruby_ui/alert_dialog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,15 @@ def test_render_with_all_items

assert_match(/Show dialog/, output)
end

# Every modal shares shadcn's overlay: black at 10% in both themes, blurred only where backdrop-filter is supported.
def test_content_uses_the_shared_modal_overlay
output = phlex do
RubyUI.AlertDialogContent { "Content" }
end

assert_includes output, "bg-black/10"
assert_includes output, "supports-backdrop-filter:backdrop-blur-xs"
refute_match(/bg-background\/80|bg-black\/80|backdrop-blur-sm/, output)
end
end
11 changes: 11 additions & 0 deletions gem/test/ruby_ui/command_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,15 @@ def test_content_and_backdrop_hold_the_last_frame_of_the_exit_animation

assert_equal 2, output.scan("data-[state=closed]:fill-mode-forwards").size
end

# Every modal shares shadcn's overlay: black at 10% in both themes, blurred only where backdrop-filter is supported.
def test_backdrop_uses_the_shared_modal_overlay
output = phlex do
RubyUI.CommandDialogContent { "command body" }
end

assert_includes output, "bg-black/10"
assert_includes output, "supports-backdrop-filter:backdrop-blur-xs"
refute_match(/bg-background\/80|bg-black\/80|backdrop-blur-sm/, output)
end
end
13 changes: 13 additions & 0 deletions gem/test/ruby_ui/dialog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,17 @@ def test_trigger_has_open_action

assert_match(/data-action="click->ruby-ui--dialog#open"/, output)
end

# Every modal shares shadcn's overlay: black at 10% in both themes, blurred only where backdrop-filter is supported.
def test_dialog_content_uses_the_shared_modal_overlay
output = phlex do
RubyUI.Dialog do
RubyUI.DialogContent { "Content" }
end
end

assert_includes output, "backdrop:bg-black/10"
assert_includes output, "backdrop:supports-backdrop-filter:backdrop-blur-xs"
refute_match(/bg-background\/80|bg-black\/80|backdrop-blur-sm/, output)
end
end
11 changes: 11 additions & 0 deletions gem/test/ruby_ui/sheet_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,15 @@ def test_content_and_backdrop_hold_the_last_frame_of_the_exit_animation

assert_equal 2, output.scan("data-[state=closed]:fill-mode-forwards").size
end

# Every modal shares shadcn's overlay: black at 10% in both themes, blurred only where backdrop-filter is supported.
def test_backdrop_uses_the_shared_modal_overlay
output = phlex do
RubyUI.SheetContent { "sheet body" }
end

assert_includes output, "bg-black/10"
assert_includes output, "supports-backdrop-filter:backdrop-blur-xs"
refute_match(/bg-background\/80|bg-black\/80|backdrop-blur-sm/, output)
end
end
Loading
Loading