Sha256: 77fce069d28da1ef3e78767783a31871110997f123b12540a308b237d5b059d1

Contents?: true

Size: 1.59 KB

Versions: 6

Compression:

Stored size: 1.59 KB

Contents

require_relative 'mixins/common'
require_relative 'mixins/attaches'

module Voom
  module Presenters
    module DSL
      module Components
        class ExpansionPanel < EventBase
          include Mixins::Common

          attr_accessor :open

          def initialize(**attribs_, &block)
            super(type: :expansion_panel, **attribs_, &block)
            self.text(attribs.delete(:text)) if attribs.key?(:text)
            self.secondary_text(attribs.delete(:secondary_text)) if attribs.key?(:secondary_text)
            @open = attribs.delete(:open) { false }
            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 secondary_text(*text, **attribs, &block)
            return @secondary_text if locked?
            @secondary_text = Components::Typography.new(parent: self, type: :text, text: text, context: context, **attribs, &block)
          end

          def content(**attribs, &block)
            return @content if locked?
            @content = Content.new(parent: self, context: context, **attribs, &block)
          end

          class Content < EventBase
            include Mixins::Common
            include Mixins::Attaches

            attr_accessor :components

            def initialize(**attribs_, &block)
              super(type: :content, **attribs_, &block)
              @components = []
              expand!
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voom-presenters-0.1.13 lib/voom/presenters/dsl/components/expansion_panel.rb
voom-presenters-0.1.12 lib/voom/presenters/dsl/components/expansion_panel.rb
voom-presenters-0.1.11 lib/voom/presenters/dsl/components/expansion_panel.rb
voom-presenters-0.1.10 lib/voom/presenters/dsl/components/expansion_panel.rb
voom-presenters-0.1.9 lib/voom/presenters/dsl/components/expansion_panel.rb
voom-presenters-0.1.8 lib/voom/presenters/dsl/components/expansion_panel.rb