Class: Views::Docs::DropdownMenu

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_ui/dropdown_menu/dropdown_menu_docs.rb

Instance Method Summary collapse

Methods inherited from Base

#Alert, #AlertDescription, #AlertTitle, #Heading, #InlineCode, #InlineLink, #Text, #component_files, #docs_accordion_path, #docs_alert_dialog_path, #docs_alert_path, #docs_aspect_ratio_path, #docs_avatar_path, #docs_badge_path, #docs_installation_path, #docs_separator_path, #docs_sheet_path

Instance Method Details

#view_templateObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/ruby_ui/dropdown_menu/dropdown_menu_docs.rb', line 4

def view_template
  component = "DropdownMenu"
  div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
    render Docs::Header.new(title: "Dropdown Menu", description: "Displays a menu to the user — such as a set of actions or functions — triggered by a button.")

    Heading(level: 2) { "Usage" }

    render Docs::VisualCodeExample.new(title: "Example", context: self) do
      <<~RUBY
        DropdownMenu do
          DropdownMenuTrigger(class: 'w-full') do
            Button(variant: :outline) { "Open" }
          end
          DropdownMenuContent do
            DropdownMenuLabel { "My Account" }
            DropdownMenuSeparator
            DropdownMenuItem(href: '#') { "Profile" }
            DropdownMenuItem(href: '#') { "Billing" }
            DropdownMenuItem(href: '#') { "Team" }
            DropdownMenuItem(href: '#') { "Subscription" }
          end
        end
      RUBY
    end

    render Docs::VisualCodeExample.new(title: "Placement", description: "If the DropdownMenu conflicts with edge, it will auto-adjust it's placement", context: self) do
      <<~RUBY
        div(class: 'grid grid-cols-1 sm:grid-cols-3 gap-4') do
          # -- TOP --
          DropdownMenu(options: { placement: 'top' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'top' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          DropdownMenu(options: { placement: 'top-start' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'top-start' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          DropdownMenu(options: { placement: 'top-end' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'top-end' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          # -- BOTTOM --
          DropdownMenu(options: { placement: 'bottom' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'bottom' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          DropdownMenu(options: { placement: 'bottom-start' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'bottom-start' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          DropdownMenu(options: { placement: 'bottom-end' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'bottom-end' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          # -- LEFT --
          DropdownMenu(options: { placement: 'left' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'left' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          DropdownMenu(options: { placement: 'left-start' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'left-start' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          DropdownMenu(options: { placement: 'left-end' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'left-end' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          # -- RIGHT --
          DropdownMenu(options: { placement: 'right' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'right' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          DropdownMenu(options: { placement: 'right-start' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'right-start' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end

          DropdownMenu(options: { placement: 'right-end' }) do
            DropdownMenuTrigger(class: 'w-full') do
              Button(variant: :outline, class: 'w-full justify-center') { 'right-end' }
            end
            DropdownMenuContent do
              DropdownMenuLabel { "My Account" }
              DropdownMenuSeparator
              DropdownMenuItem(href: '#') { "Profile" }
              DropdownMenuItem(href: '#') { "Billing" }
              DropdownMenuItem(href: '#') { "Team" }
              DropdownMenuItem(href: '#') { "Subscription" }
            end
          end
        end
      RUBY
    end

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

    render Docs::ComponentsTable.new(component_files(component))
  end
end