Sha256: 204c4c16b37b0dc1ba474d9159334ffe49a1976048b3245fcc25eb78eb3fa99d

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents

require_relative 'icon_base'
require_relative 'mixins/event'
require_relative 'mixins/tooltips'

module Voom
  module Presenters
    module DSL
      module Components
        class Chip < EventBase
          include Mixins::Tooltips
          attr_reader :icons, :color
          
          def initialize(**attribs_, &block)
            super(type: :chip,
                  context: context,
                  **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)
            expand!
          end

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

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

          class Icon < Components::IconBase

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
voom-presenters-0.1.9 lib/voom/presenters/dsl/components/chip.rb
voom-presenters-0.1.8 lib/voom/presenters/dsl/components/chip.rb
voom-presenters-0.1.7 lib/voom/presenters/dsl/components/chip.rb
voom-presenters-0.1.6 lib/voom/presenters/dsl/components/chip.rb
voom-presenters-0.1.5 lib/voom/presenters/dsl/components/chip.rb
voom-presenters-0.1.4 lib/voom/presenters/dsl/components/chip.rb
voom-presenters-0.1.3 lib/voom/presenters/dsl/components/chip.rb
voom-presenters-0.1.2 lib/voom/presenters/dsl/components/chip.rb
voom-presenters-0.1.1 lib/voom/presenters/dsl/components/chip.rb
voom-presenters-0.1.0 lib/voom/presenters/dsl/components/chip.rb