Sha256: 45af6c901711e622d20ea46b5b50064327ecfe0fac1f6a6a25c7c0cdd6e1be45

Contents?: true

Size: 1.06 KB

Versions: 14

Compression:

Stored size: 1.06 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 :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

14 entries across 14 versions & 1 rubygems

Version Path
coveragebook_components-0.17.1 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.17.0 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.16.0 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.15.0 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.14.0 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.13.1 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.13.0 app/components/coco/buttons/button_group/button_group.rb
coveragebook_components-0.12.2 app/components/coco/shared/button_group/button_group.rb
coveragebook_components-0.12.1 app/components/coco/shared/button_group/button_group.rb
coveragebook_components-0.12.0 app/components/coco/shared/button_group/button_group.rb
coveragebook_components-0.11.0 app/components/coco/shared/button_group/button_group.rb
coveragebook_components-0.10.1.beta.2 app/components/coco/shared/button_group/button_group.rb
coveragebook_components-0.10.1.beta.1 app/components/coco/shared/button_group/button_group.rb
coveragebook_components-0.10.1.beta.0 app/components/coco/shared/button_group/button_group.rb