Skip to content

Commit fc6e71f

Browse files
committed
[Bug Fix] close_button prop: render only when true; X at top-right inside
- Region.skeleton: render ToastClose only when close_button: true. - Region wrapper: data-close-button=true|false. - Item: group-data-[close-button=true]/toaster:pr-10 reserves space. - ToastClose: top-right inside (right-2 top-2), size-6 rounded-md, always visible, ghost-button style. SVG bumped to size-3.5. - Default close_button: false (no X shown). Set to true on Region to opt in.
1 parent ab75087 commit fc6e71f

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

gem/lib/ruby_ui/toast/toast_close.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ def view_template
66
button(**attrs) do
77
svg(
88
xmlns: "http://www.w3.org/2000/svg",
9-
width: "12",
10-
height: "12",
9+
width: "14",
10+
height: "14",
1111
viewbox: "0 0 24 24",
1212
fill: "none",
1313
stroke: "currentColor",
1414
stroke_width: "2",
1515
stroke_linecap: "round",
1616
stroke_linejoin: "round",
17-
class: "size-3"
17+
class: "size-3.5"
1818
) do |s|
1919
s.path(d: "M18 6 6 18")
2020
s.path(d: "m6 6 12 12")
@@ -33,7 +33,7 @@ def default_attrs
3333
slot: "close",
3434
action: "click->ruby-ui--toast#dismiss"
3535
},
36-
class: "absolute left-0 top-0 -translate-x-[35%] -translate-y-[35%] size-5 cursor-pointer rounded-full border border-border bg-popover text-foreground p-0 flex items-center justify-center opacity-0 z-10 transition-opacity hover:bg-muted focus:opacity-100 focus:outline-none focus:ring-1 focus:ring-ring group-hover/toast:opacity-100 group-data-[close-button=always]/toaster:opacity-100"
36+
class: "absolute right-2 top-2 size-6 cursor-pointer rounded-md text-foreground/60 p-0 flex items-center justify-center transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring"
3737
}
3838
end
3939
end

gem/lib/ruby_ui/toast/toast_item.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def item_classes
5858
flex w-[356px] max-w-full items-center gap-1.5
5959
rounded-lg border bg-popover text-popover-foreground
6060
border-border p-4 text-[13px] shadow-[0_4px_12px_rgba(0,0,0,0.1)]
61+
group-data-[close-button=true]/toaster:pr-10
6162
transition-[transform,opacity] duration-300 ease-out
6263
will-change-transform
6364
opacity-[var(--opacity,1)]

gem/lib/ruby_ui/toast/toast_region.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def skeleton(variant)
7070
render RubyUI::ToastTitle.new
7171
render RubyUI::ToastDescription.new
7272
end
73-
render RubyUI::ToastClose.new
73+
render RubyUI::ToastClose.new if @close_button
7474
end
7575
end
7676
end
@@ -82,7 +82,7 @@ def default_attrs
8282
aria_live: "polite",
8383
data: {
8484
controller: "ruby-ui--toaster",
85-
close_button: @close_button ? "always" : "hover",
85+
close_button: @close_button.to_s,
8686
position: @position.to_s.tr("_", "-"),
8787
ruby_ui__toaster_position_value: @position.to_s.tr("_", "-"),
8888
ruby_ui__toaster_expand_value: @expand.to_s,

0 commit comments

Comments
 (0)