Sha256: 662d61d2451447bd928ae5438c165c10e75e836545f4be8f41207d18baf09749

Contents?: true

Size: 1.12 KB

Versions: 18

Compression:

Stored size: 1.12 KB

Contents

module Coco
  class ButtonGroup < Coco::Component
    include Concerns::ActsAsButtonGroup
    include Concerns::AcceptsOptions

    accepts_option :size, default: :default, private: true
    accepts_option :theme, default: :primary, private: true
    accepts_option :reversed, from: [true, false], default: false
    accepts_option :segmented, from: [true, false], default: false
    accepts_option :floating, from: [true, false], default: false
    accepts_option :collapsible, from: [true, false, nil]

    before_initialize do |kwargs|
      if kwargs[:floating] == true
        kwargs[:segmented] = true
        kwargs[:theme] = :toolbar_floating
      end
      kwargs
    end

    def button_kwargs(kwargs, type = nil)
      args = {
        theme: get_option_value(:theme),
        size: get_option_value(:size),
        **kwargs
      }

      if component_args.key?(:resize)
        args[:resize] = component_args[:resize]
      end

      if get_option_value(:collapsible) == false
        args[:collapsible] = false
      elsif get_option_value(:collapsible) == true
        args[:static] = false
      end

      args
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
coveragebook_components-0.19.8 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.19.7 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.19.6 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.19.5 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.19.4 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.19.3 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.19.2 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.19.1 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.19.0 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.18.8 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.18.7 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.18.0 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.17.7 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.17.6 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.17.5 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.17.4 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.17.3 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.17.2 app/components/coco/buttons/button_group/button_group.rb