Sha256: 5bcb01815306ff5f676ebfc8ca4e8571e7f19ee5d9a71c371b9ab3e1f611c472

Contents?: true

Size: 1.56 KB

Versions: 12

Compression:

Stored size: 1.56 KB

Contents

module Coprl
  module Presenters
    module DSL
      module Components
        class Chip < EventBase
          include Mixins::Tooltips
          attr_reader :icons, :color, :name, :value, :chipset_variant, :selected

          def initialize(**attribs_, &block)
            super(type: :chip,
                  **attribs_, &block)
            @icons = []
            self.text(attribs.delete(:text)) if attribs.key?(:text)
            self.icon(attribs.delete(:icon)) if attribs.key?(:icon)
            @color = attribs.delete(:color)
            @name = attribs.delete(:name)
            @value = attribs.delete(:value)
            @selected = attribs.delete(:selected){false}
            expand!
            @chipset_variant = self.parent(:chipset)&.variant.to_s
          end

          def text(*text, **attribs, &block)
            return @text if locked?
            @text = Components::Typography.new(parent: self, type: :text, text: text, **attribs, &block)
          end

          def icon(icon=nil, **attribs, &block)
            @icons << Icon.new(parent: self, icon: icon,
                               **attribs, &block)
          end

          def menu(**attributes, &block)
            return @menu if locked?
            @menu = Components::Menu.new(parent: self, **attributes, &block)
          end

          class Icon < Components::IconBase

            def initialize(**attribs_, &block)
              super(**attribs_, &block)
              @position = [:left] if position.empty?
              expand!
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
coprl-3.0.0.beta.12 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.11 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.10 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.9 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.8 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.7 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.6 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.5 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.4 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.3 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.2 lib/coprl/presenters/dsl/components/chip.rb
coprl-3.0.0.beta.1 lib/coprl/presenters/dsl/components/chip.rb