Sha256: b9ad17573cc3b5d9b4e414d07dd167e6a797205271a6937a8775a66b91d57041

Contents?: true

Size: 789 Bytes

Versions: 17

Compression:

Stored size: 789 Bytes

Contents

module Coco
  class Toolbar < Coco::Component
    renders_many :sections,
      ->(*args, align: nil, **kwargs, &block) do
        alignment = if align.nil?
          @sections[:start].nil? ? :start : :end
        else
          align
        end.to_sym

        unless @sections[alignment].nil?
          raise "Toolbar already has a `#{alignment}` section defined"
        end

        component = Coco::ButtonGroup.new(**kwargs, theme: :toolbar, collapsible: true)
        @sections[alignment] = view_context.render(component, &block)
      end

    def initialize(**kwargs)
      @sections = {
        start: nil,
        end: nil
      }
      super(**kwargs)
    end

    def start_section
      @sections[:start]
    end

    def end_section
      @sections[:end]
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
coveragebook_components-0.19.0 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.18.8 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.18.7 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.18.0 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.17.7 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.17.6 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.17.5 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.17.4 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.17.3 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.17.2 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.17.1 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.17.0 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.16.0 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.15.0 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.14.0 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.13.1 app/components/coco/buttons/toolbar/toolbar.rb
coveragebook_components-0.13.0 app/components/coco/buttons/toolbar/toolbar.rb