module Coco module App module Elements class Button < Coco::Button SIZES = [:sm, :md, :lg, nil] SIZE_ALIASES = { default: [:sm, {xl: :md}] } THEMES = [ "primary", "text-primary", "secondary", "text-secondary", "positive", "text-positive", "negative", "text-negative", "warning", "text-warning", "info", "text-info", "toolbar", "text-toolbar", "neutral-dark", "neutral-light", "blank", nil ] DEFAULT_THEME = "primary" renders_one :dropdown, types: { content: ->(&block) { block.call }, confirmation: ->(**kwargs) do set_option_value(:confirm, true) Coco::App::Elements::ConfirmPanel.new(**kwargs) end } before_render do if confirm? && !dropdown? with_confirmation do |confirm| confirm.with_text { "Are you sure?" } confirm.with_button { "Yes, continue" } end end end def with_dropdown(...) with_dropdown_content(...) end def with_confirmation(...) with_dropdown_confirmation(...) end end end end end