|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +class Views::Docs::DropdownMenu < Views::Base |
| 4 | + def view_template |
| 5 | + component = "DropdownMenu" |
| 6 | + div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do |
| 7 | + 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.") |
| 8 | + |
| 9 | + Heading(level: 2) { "Usage" } |
| 10 | + |
| 11 | + render Docs::VisualCodeExample.new(title: "Example", context: self) do |
| 12 | + <<~RUBY |
| 13 | + DropdownMenu do |
| 14 | + DropdownMenuTrigger(class: 'w-full') do |
| 15 | + Button(variant: :outline) { "Open" } |
| 16 | + end |
| 17 | + DropdownMenuContent do |
| 18 | + DropdownMenuLabel { "My Account" } |
| 19 | + DropdownMenuSeparator |
| 20 | + DropdownMenuItem(href: '#') { "Profile" } |
| 21 | + DropdownMenuItem(href: '#') { "Billing" } |
| 22 | + DropdownMenuItem(href: '#') { "Team" } |
| 23 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 24 | + end |
| 25 | + end |
| 26 | + RUBY |
| 27 | + end |
| 28 | + |
| 29 | + render Docs::VisualCodeExample.new(title: "Placement", description: "If the DropdownMenu conflicts with edge, it will auto-adjust it's placement", context: self) do |
| 30 | + <<~RUBY |
| 31 | + div(class: 'grid grid-cols-1 sm:grid-cols-3 gap-4') do |
| 32 | + # -- TOP -- |
| 33 | + DropdownMenu(options: { placement: 'top' }) do |
| 34 | + DropdownMenuTrigger(class: 'w-full') do |
| 35 | + Button(variant: :outline, class: 'w-full justify-center') { 'top' } |
| 36 | + end |
| 37 | + DropdownMenuContent do |
| 38 | + DropdownMenuLabel { "My Account" } |
| 39 | + DropdownMenuSeparator |
| 40 | + DropdownMenuItem(href: '#') { "Profile" } |
| 41 | + DropdownMenuItem(href: '#') { "Billing" } |
| 42 | + DropdownMenuItem(href: '#') { "Team" } |
| 43 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 44 | + end |
| 45 | + end |
| 46 | +
|
| 47 | + DropdownMenu(options: { placement: 'top-start' }) do |
| 48 | + DropdownMenuTrigger(class: 'w-full') do |
| 49 | + Button(variant: :outline, class: 'w-full justify-center') { 'top-start' } |
| 50 | + end |
| 51 | + DropdownMenuContent do |
| 52 | + DropdownMenuLabel { "My Account" } |
| 53 | + DropdownMenuSeparator |
| 54 | + DropdownMenuItem(href: '#') { "Profile" } |
| 55 | + DropdownMenuItem(href: '#') { "Billing" } |
| 56 | + DropdownMenuItem(href: '#') { "Team" } |
| 57 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 58 | + end |
| 59 | + end |
| 60 | +
|
| 61 | + DropdownMenu(options: { placement: 'top-end' }) do |
| 62 | + DropdownMenuTrigger(class: 'w-full') do |
| 63 | + Button(variant: :outline, class: 'w-full justify-center') { 'top-end' } |
| 64 | + end |
| 65 | + DropdownMenuContent do |
| 66 | + DropdownMenuLabel { "My Account" } |
| 67 | + DropdownMenuSeparator |
| 68 | + DropdownMenuItem(href: '#') { "Profile" } |
| 69 | + DropdownMenuItem(href: '#') { "Billing" } |
| 70 | + DropdownMenuItem(href: '#') { "Team" } |
| 71 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 72 | + end |
| 73 | + end |
| 74 | +
|
| 75 | + # -- BOTTOM -- |
| 76 | + DropdownMenu(options: { placement: 'bottom' }) do |
| 77 | + DropdownMenuTrigger(class: 'w-full') do |
| 78 | + Button(variant: :outline, class: 'w-full justify-center') { 'bottom' } |
| 79 | + end |
| 80 | + DropdownMenuContent do |
| 81 | + DropdownMenuLabel { "My Account" } |
| 82 | + DropdownMenuSeparator |
| 83 | + DropdownMenuItem(href: '#') { "Profile" } |
| 84 | + DropdownMenuItem(href: '#') { "Billing" } |
| 85 | + DropdownMenuItem(href: '#') { "Team" } |
| 86 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 87 | + end |
| 88 | + end |
| 89 | +
|
| 90 | + DropdownMenu(options: { placement: 'bottom-start' }) do |
| 91 | + DropdownMenuTrigger(class: 'w-full') do |
| 92 | + Button(variant: :outline, class: 'w-full justify-center') { 'bottom-start' } |
| 93 | + end |
| 94 | + DropdownMenuContent do |
| 95 | + DropdownMenuLabel { "My Account" } |
| 96 | + DropdownMenuSeparator |
| 97 | + DropdownMenuItem(href: '#') { "Profile" } |
| 98 | + DropdownMenuItem(href: '#') { "Billing" } |
| 99 | + DropdownMenuItem(href: '#') { "Team" } |
| 100 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 101 | + end |
| 102 | + end |
| 103 | +
|
| 104 | + DropdownMenu(options: { placement: 'bottom-end' }) do |
| 105 | + DropdownMenuTrigger(class: 'w-full') do |
| 106 | + Button(variant: :outline, class: 'w-full justify-center') { 'bottom-end' } |
| 107 | + end |
| 108 | + DropdownMenuContent do |
| 109 | + DropdownMenuLabel { "My Account" } |
| 110 | + DropdownMenuSeparator |
| 111 | + DropdownMenuItem(href: '#') { "Profile" } |
| 112 | + DropdownMenuItem(href: '#') { "Billing" } |
| 113 | + DropdownMenuItem(href: '#') { "Team" } |
| 114 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 115 | + end |
| 116 | + end |
| 117 | +
|
| 118 | + # -- LEFT -- |
| 119 | + DropdownMenu(options: { placement: 'left' }) do |
| 120 | + DropdownMenuTrigger(class: 'w-full') do |
| 121 | + Button(variant: :outline, class: 'w-full justify-center') { 'left' } |
| 122 | + end |
| 123 | + DropdownMenuContent do |
| 124 | + DropdownMenuLabel { "My Account" } |
| 125 | + DropdownMenuSeparator |
| 126 | + DropdownMenuItem(href: '#') { "Profile" } |
| 127 | + DropdownMenuItem(href: '#') { "Billing" } |
| 128 | + DropdownMenuItem(href: '#') { "Team" } |
| 129 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 130 | + end |
| 131 | + end |
| 132 | +
|
| 133 | + DropdownMenu(options: { placement: 'left-start' }) do |
| 134 | + DropdownMenuTrigger(class: 'w-full') do |
| 135 | + Button(variant: :outline, class: 'w-full justify-center') { 'left-start' } |
| 136 | + end |
| 137 | + DropdownMenuContent do |
| 138 | + DropdownMenuLabel { "My Account" } |
| 139 | + DropdownMenuSeparator |
| 140 | + DropdownMenuItem(href: '#') { "Profile" } |
| 141 | + DropdownMenuItem(href: '#') { "Billing" } |
| 142 | + DropdownMenuItem(href: '#') { "Team" } |
| 143 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 144 | + end |
| 145 | + end |
| 146 | +
|
| 147 | + DropdownMenu(options: { placement: 'left-end' }) do |
| 148 | + DropdownMenuTrigger(class: 'w-full') do |
| 149 | + Button(variant: :outline, class: 'w-full justify-center') { 'left-end' } |
| 150 | + end |
| 151 | + DropdownMenuContent do |
| 152 | + DropdownMenuLabel { "My Account" } |
| 153 | + DropdownMenuSeparator |
| 154 | + DropdownMenuItem(href: '#') { "Profile" } |
| 155 | + DropdownMenuItem(href: '#') { "Billing" } |
| 156 | + DropdownMenuItem(href: '#') { "Team" } |
| 157 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 158 | + end |
| 159 | + end |
| 160 | +
|
| 161 | + # -- RIGHT -- |
| 162 | + DropdownMenu(options: { placement: 'right' }) do |
| 163 | + DropdownMenuTrigger(class: 'w-full') do |
| 164 | + Button(variant: :outline, class: 'w-full justify-center') { 'right' } |
| 165 | + end |
| 166 | + DropdownMenuContent do |
| 167 | + DropdownMenuLabel { "My Account" } |
| 168 | + DropdownMenuSeparator |
| 169 | + DropdownMenuItem(href: '#') { "Profile" } |
| 170 | + DropdownMenuItem(href: '#') { "Billing" } |
| 171 | + DropdownMenuItem(href: '#') { "Team" } |
| 172 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 173 | + end |
| 174 | + end |
| 175 | +
|
| 176 | + DropdownMenu(options: { placement: 'right-start' }) do |
| 177 | + DropdownMenuTrigger(class: 'w-full') do |
| 178 | + Button(variant: :outline, class: 'w-full justify-center') { 'right-start' } |
| 179 | + end |
| 180 | + DropdownMenuContent do |
| 181 | + DropdownMenuLabel { "My Account" } |
| 182 | + DropdownMenuSeparator |
| 183 | + DropdownMenuItem(href: '#') { "Profile" } |
| 184 | + DropdownMenuItem(href: '#') { "Billing" } |
| 185 | + DropdownMenuItem(href: '#') { "Team" } |
| 186 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 187 | + end |
| 188 | + end |
| 189 | +
|
| 190 | + DropdownMenu(options: { placement: 'right-end' }) do |
| 191 | + DropdownMenuTrigger(class: 'w-full') do |
| 192 | + Button(variant: :outline, class: 'w-full justify-center') { 'right-end' } |
| 193 | + end |
| 194 | + DropdownMenuContent do |
| 195 | + DropdownMenuLabel { "My Account" } |
| 196 | + DropdownMenuSeparator |
| 197 | + DropdownMenuItem(href: '#') { "Profile" } |
| 198 | + DropdownMenuItem(href: '#') { "Billing" } |
| 199 | + DropdownMenuItem(href: '#') { "Team" } |
| 200 | + DropdownMenuItem(href: '#') { "Subscription" } |
| 201 | + end |
| 202 | + end |
| 203 | + end |
| 204 | + RUBY |
| 205 | + end |
| 206 | + |
| 207 | + render Components::ComponentSetup::Tabs.new(component_name: component) |
| 208 | + |
| 209 | + render Docs::ComponentsTable.new(component_files(component)) |
| 210 | + end |
| 211 | + end |
| 212 | +end |
0 commit comments