Skip to content

Commit be3b442

Browse files
committed
Use the default visual code example for the dialog
1 parent c3b0a89 commit be3b442

File tree

6 files changed

+96
-230
lines changed

6 files changed

+96
-230
lines changed

app/controllers/docs/sidebar_controller.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,4 @@ def inset_example
1414

1515
render Views::Docs::Sidebar::InsetExample.new(sidebar_state:)
1616
end
17-
18-
def dialog_example
19-
sidebar_state = cookies.fetch(:sidebar_state, "true") == "true"
20-
21-
render Views::Docs::Sidebar::DialogExample.new(sidebar_state:)
22-
end
2317
end

app/views/docs/sidebar.rb

Lines changed: 92 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,107 @@ def view_template
1717
Views::Docs::Sidebar::InsetExample::CODE
1818
end
1919

20-
render div do
21-
div do
22-
Components.Heading(level: 4) { "Dialog variant" }
23-
24-
Tabs(default_value: "preview") do
25-
TabsList do
26-
TabsTrigger(value: "preview") do
27-
span { "Preview" }
28-
end
29-
TabsTrigger(value: "code") do
30-
span { "Code" }
31-
end
32-
end
33-
34-
TabsContent(value: "preview") do
35-
Link(href: "/docs/sidebar/dialog", target: :_blank, variant: :primary) { "Open in another tab" }
20+
render Docs::VisualCodeExample.new(title: "Dialog variant", context: self) do
21+
<<~RUBY
22+
Dialog(data: {action: "ruby-ui--dialog:connect->ruby-ui--dialog#open"}) do
23+
DialogTrigger do
24+
Button { "Open Dialog" }
3625
end
37-
38-
TabsContent(value: "code") do
39-
div(class: "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 relative rounded-md border") do
40-
Codeblock(Views::Docs::Sidebar::DialogExample::CODE, syntax: :ruby, class: "-m-px")
26+
DialogContent(class: "grid overflow-hidden p-0 md:max-h-[500px] md:max-w-[700px] lg:max-w-[800px]") do
27+
SidebarWrapper(class: "items-start") do
28+
Sidebar(collapsible: :none, class: "hidden md:flex") do
29+
SidebarContent do
30+
SidebarGroup do
31+
SidebarGroupContent do
32+
SidebarMenu do
33+
SidebarMenuItem do
34+
SidebarMenuButton(as: :a, href: "#") do
35+
search_icon()
36+
span { "Search" }
37+
end
38+
end
39+
SidebarMenuItem do
40+
SidebarMenuButton(as: :a, href: "#", active: true) do
41+
home_icon()
42+
span { "Home" }
43+
end
44+
end
45+
SidebarMenuItem do
46+
SidebarMenuButton(as: :a, href: "#") do
47+
inbox_icon()
48+
span { "Inbox" }
49+
end
50+
end
51+
end
52+
end
53+
end
54+
end
55+
end
56+
main(class: "flex h-[480px] flex-1 flex-col overflow-hidden") do
57+
end
4158
end
4259
end
4360
end
44-
end
61+
RUBY
4562
end
4663

4764
render Components::ComponentSetup::Tabs.new(component_name: component)
4865

4966
render Docs::ComponentsTable.new(component_files(component))
5067
end
5168
end
69+
70+
def search_icon
71+
svg(
72+
xmlns: "http://www.w3.org/2000/svg",
73+
width: "24",
74+
height: "24",
75+
viewBox: "0 0 24 24",
76+
fill: "none",
77+
stroke: "currentColor",
78+
stroke_width: "2",
79+
stroke_linecap: "round",
80+
stroke_linejoin: "round",
81+
class: "lucide lucide-search"
82+
) do |s|
83+
s.circle(cx: "11", cy: "11", r: "8")
84+
s.path(d: "M21 21L16.7 16.7")
85+
end
86+
end
87+
88+
def home_icon
89+
svg(
90+
xmlns: "http://www.w3.org/2000/svg",
91+
width: "24",
92+
height: "24",
93+
viewBox: "0 0 24 24",
94+
fill: "none",
95+
stroke: "currentColor",
96+
stroke_width: "2",
97+
stroke_linecap: "round",
98+
stroke_linejoin: "round",
99+
class: "lucide lucide-house"
100+
) do |s|
101+
s.path(d: "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8")
102+
s.path(d: "M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z")
103+
end
104+
end
105+
106+
def inbox_icon
107+
svg(
108+
xmlns: "http://www.w3.org/2000/svg",
109+
width: "24",
110+
height: "24",
111+
viewBox: "0 0 24 24",
112+
fill: "none",
113+
stroke: "currentColor",
114+
stroke_width: "2",
115+
stroke_linecap: "round",
116+
stroke_linejoin: "round",
117+
class: "lucide lucide-inbox"
118+
) do |s|
119+
s.polyline(points: "22 12 16 12 14 15 10 15 8 12 2 12")
120+
s.path(d: "M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z")
121+
end
122+
end
52123
end

app/views/docs/sidebar/dialog_example.rb

Lines changed: 0 additions & 198 deletions
This file was deleted.

app/views/docs/sidebar/example.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def initialize(sidebar_state:)
6969
ellipsis_icon()
7070
span(class: "sr-only") { "More" }
7171
end
72-
DropdownMenuContent(class: "z-40") do
72+
DropdownMenuContent do
7373
DropdownMenuItem(href: '#') { "Profile" }
7474
DropdownMenuItem(href: '#') { "Billing" }
7575
DropdownMenuItem(href: '#') { "Team" }
@@ -99,7 +99,7 @@ def initialize(sidebar_state:)
9999
ellipsis_icon()
100100
span(class: "sr-only") { "More" }
101101
end
102-
DropdownMenuContent(class: "z-40") do
102+
DropdownMenuContent do
103103
DropdownMenuItem(href: '#') { "Profile" }
104104
DropdownMenuItem(href: '#') { "Billing" }
105105
DropdownMenuItem(href: '#') { "Team" }

app/views/docs/sidebar/inset_example.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def initialize(sidebar_state:)
6969
ellipsis_icon()
7070
span(class: "sr-only") { "More" }
7171
end
72-
DropdownMenuContent(class: "z-40") do
72+
DropdownMenuContent do
7373
DropdownMenuItem(href: '#') { "Profile" }
7474
DropdownMenuItem(href: '#') { "Billing" }
7575
DropdownMenuItem(href: '#') { "Team" }
@@ -99,7 +99,7 @@ def initialize(sidebar_state:)
9999
ellipsis_icon()
100100
span(class: "sr-only") { "More" }
101101
end
102-
DropdownMenuContent(class: "z-40") do
102+
DropdownMenuContent do
103103
DropdownMenuItem(href: '#') { "Profile" }
104104
DropdownMenuItem(href: '#') { "Billing" }
105105
DropdownMenuItem(href: '#') { "Team" }

config/routes.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
get "sidebar", to: "docs#sidebar", as: :docs_sidebar
5454
get "sidebar/example", to: "docs/sidebar#example", as: :docs_sidebar_example
5555
get "sidebar/inset", to: "docs/sidebar#inset_example", as: :docs_sidebar_inset
56-
get "sidebar/dialog", to: "docs/sidebar#dialog_example", as: :docs_sidebar_dialog
5756
get "skeleton", to: "docs#skeleton", as: :docs_skeleton
5857
get "switch", to: "docs#switch", as: :docs_switch
5958
get "table", to: "docs#table", as: :docs_table

0 commit comments

Comments
 (0)