2025-04-30 18:14:22 -04:00
|
|
|
class MenuComponentPreview < ViewComponent::Preview
|
|
|
|
def icon
|
2025-07-18 08:30:00 -04:00
|
|
|
render DS::Menu.new(variant: "icon") do |menu|
|
2025-04-30 18:14:22 -04:00
|
|
|
menu_contents(menu)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def button
|
2025-07-18 08:30:00 -04:00
|
|
|
render DS::Menu.new(variant: "button") do |menu|
|
2025-04-30 18:14:22 -04:00
|
|
|
menu.with_button(text: "Open menu", variant: "secondary")
|
|
|
|
menu_contents(menu)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def avatar
|
2025-07-18 08:30:00 -04:00
|
|
|
render DS::Menu.new(variant: "avatar") do |menu|
|
2025-04-30 18:14:22 -04:00
|
|
|
menu_contents(menu)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def menu_contents(menu)
|
|
|
|
menu.with_header do
|
|
|
|
content_tag(:div, class: "p-3") do
|
|
|
|
content_tag(:h3, "Menu header", class: "font-medium text-gray-900")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
menu.with_item(variant: "link", text: "Link", href: "#", icon: "plus")
|
|
|
|
menu.with_item(variant: "button", text: "Action", href: "#", method: :post, icon: "circle")
|
|
|
|
menu.with_item(variant: "button", text: "Action destructive", href: "#", method: :delete, icon: "circle")
|
|
|
|
|
|
|
|
menu.with_item(variant: "divider")
|
|
|
|
|
|
|
|
menu.with_custom_content do
|
|
|
|
content_tag(:div, class: "p-4") do
|
|
|
|
safe_join([
|
|
|
|
content_tag(:h3, "Custom content header", class: "font-medium text-gray-900"),
|
|
|
|
content_tag(:p, "Some custom content", class: "text-sm text-gray-500")
|
|
|
|
])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|