Sha256: fc531638301c98b3a90b6b4618ff1cc38f71d40f14f7b130ffb12e52246c7505
Contents?: true
Size: 1.5 KB
Versions: 16
Compression:
Stored size: 1.5 KB
Contents
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", "toolbar-floating", "text-toolbar", "neutral-dark", "neutral-light", "blank", nil ] DEFAULT_THEME = "primary" accepts_option :size, from: SIZES, default: :md accepts_option :theme, from: THEMES, default: DEFAULT_THEME 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
Version data entries
16 entries across 16 versions & 1 rubygems