Skip to content

Commit d2935c5

Browse files
committed
[Documentation] Reorder Toast docs sections + Close+Action example
- About moved to top (right after Header). - Examples second; Mount moved to AFTER Examples. - New 'Close + Action' example after 'Close Button' (X visible plus Undo button). - Components table moved above API Reference (file table first, then the props/options reference).
1 parent 4a69ae2 commit d2935c5

2 files changed

Lines changed: 24 additions & 22 deletions

File tree

docs/app/javascript/controllers/toast_demo_controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const PRESETS = {
99
with_action: { variant: "default", title: "Event has been created", action: { label: "Undo" } },
1010
text_only: { variant: "default", title: "Event has been created" },
1111
close_button: { variant: "default", title: "Event has been created", description: "Close it manually with the X.", closeButton: true },
12+
close_action: { variant: "default", title: "Event has been created", description: "Friday at 3:00 PM", closeButton: true, action: { label: "Undo" } },
1213
}
1314

1415
export default class extends Controller {

docs/app/views/docs/toast.rb

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class Views::Docs::Toast < Views::Base
1212
{key: "with_action", label: "With Action", title: "Event has been created", action_label: "Undo"},
1313
{key: "promise", label: "Promise", title: nil},
1414
{key: "text_only", label: "Text Only", title: "Event has been created"},
15-
{key: "close_button", label: "Close Button", title: "Event has been created"}
15+
{key: "close_button", label: "Close Button", title: "Event has been created"},
16+
{key: "close_action", label: "Close + Action", title: "Event has been created"}
1617
].freeze
1718

1819
POSITIONS = %w[top-left top-center top-right bottom-left bottom-center bottom-right].freeze
@@ -26,6 +27,26 @@ def view_template
2627
description: "An opinionated toast component."
2728
)
2829

30+
Heading(level: 2) { "About" }
31+
p(class: "text-muted-foreground text-sm leading-relaxed") do
32+
plain "Trigger toasts from the server with Turbo Streams or from JavaScript via "
33+
code(class: "rounded bg-muted px-1.5 py-0.5 text-xs") { "window.RubyUI.toast.*" }
34+
plain ". Heavily inspired by the original "
35+
a(
36+
href: "https://github.com/emilkowalski/sonner",
37+
target: "_blank",
38+
rel: "noopener",
39+
class: "underline underline-offset-2 hover:text-foreground"
40+
) { "sonner" }
41+
plain "."
42+
end
43+
44+
Heading(level: 2) { "Examples" }
45+
Heading(level: 3) { "Types" }
46+
div(class: "grid gap-4 sm:grid-cols-2", data: {controller: "toast-demo"}) do
47+
EXAMPLES.each { |ex| example_box(ex) }
48+
end
49+
2950
Heading(level: 2) { "Mount" }
3051
div(class: "rounded-md border bg-muted/30 p-4") do
3152
Codeblock(<<~RUBY, syntax: :ruby)
@@ -37,12 +58,6 @@ def view_template
3758
RUBY
3859
end
3960

40-
Heading(level: 2) { "Examples" }
41-
Heading(level: 3) { "Types" }
42-
div(class: "grid gap-4 sm:grid-cols-2", data: {controller: "toast-demo"}) do
43-
EXAMPLES.each { |ex| example_box(ex) }
44-
end
45-
4661
Heading(level: 3) { "Position" }
4762
p(class: "text-muted-foreground text-sm") { "Use the position prop to change where toasts mount." }
4863
div(class: "rounded-md border p-8 flex flex-wrap items-center justify-center gap-2", data: {controller: "toast-demo"}) do
@@ -101,19 +116,7 @@ def view_template
101116

102117
render Components::ComponentSetup::Tabs.new(component_name: component)
103118

104-
Heading(level: 2) { "About" }
105-
p(class: "text-muted-foreground text-sm leading-relaxed") do
106-
plain "Trigger toasts from the server with Turbo Streams or from JavaScript via "
107-
code(class: "rounded bg-muted px-1.5 py-0.5 text-xs") { "window.RubyUI.toast.*" }
108-
plain ". Heavily inspired by the original "
109-
a(
110-
href: "https://github.com/emilkowalski/sonner",
111-
target: "_blank",
112-
rel: "noopener",
113-
class: "underline underline-offset-2 hover:text-foreground"
114-
) { "sonner" }
115-
plain "."
116-
end
119+
render Docs::ComponentsTable.new(component_files(component))
117120

118121
Heading(level: 2) { "API Reference" }
119122

@@ -132,8 +135,6 @@ def view_template
132135
plain " CustomEvent detail."
133136
end
134137
props_table(JS_OPTIONS)
135-
136-
render Docs::ComponentsTable.new(component_files(component))
137138
end
138139
end
139140

0 commit comments

Comments
 (0)