Sha256: 6c33dce5d77a50822bc8b74b2dbfddf9553584d6ad11132cf0d5945ded40c408

Contents?: true

Size: 1.58 KB

Versions: 12

Compression:

Stored size: 1.58 KB

Contents

module Coprl
  module Presenters
    module DSL
      module Components
        class UnorderedList < Base

          attr_reader :list_items, :list_style

          def initialize(**attribs_, &block)
            super(type: :unordered_list, **attribs_, &block)
            @list_style = attribs.delete(:list_style){ :disc }
            @list_items = []
            expand!
          end

          def list_item(text=nil, **attribs_, &block)
            @list_items << ListItem.new(parent: self, text: text, **attribs_, &block)
          end

          class ListItem < Base

            def initialize(**attribs_, &block)
              super(type: :list_item, **attribs_, &block)
              self.text(attribs.delete(:text)) if attribs.key?(:text)
              self.icon(attribs.delete(:icon)) if attribs.key?(:icon)
              self.unordered_list(attribs.delete(:unordered_list)) if attribs.key?(:unordered_list)
              expand!
            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)
              return @icon if locked?
              @icon = Components::Icon.new(parent: self, icon: icon, **attribs, &block)
            end

            def unordered_list(**attribs, &block)
              return @unordered_list if locked?
              @unordered_list = UnorderedList.new(parent: self, **attribs, &block)
            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/unordered_list.rb
coprl-3.0.0.beta.11 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.10 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.9 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.8 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.7 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.6 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.5 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.4 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.3 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.2 lib/coprl/presenters/dsl/components/unordered_list.rb
coprl-3.0.0.beta.1 lib/coprl/presenters/dsl/components/unordered_list.rb