Sha256: bde98c5958009d903a21cec43a0ea6b06af2a3d9424a033fd8886a0e6163d893

Contents?: true

Size: 1.53 KB

Versions: 15

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbVerticalNav
    class Item < Playbook::PbKit::Base
      PROPS = %i[configured_active
                 configured_classname
                 configured_data
                 configured_id
                 configured_link
                 configured_text
                 block].freeze

      def initialize(active: default_configuration,
                     classname: default_configuration,
                     data: default_configuration,
                     id: default_configuration,
                     link: default_configuration,
                     text: default_configuration,
                     &block)
        self.configured_active = active
        self.configured_classname = classname
        self.configured_data = data
        self.configured_id = id
        self.configured_link = link
        self.configured_text = text
        self.block = block_given? ? block : nil
      end

      def active
        is_true? configured_active
      end

      def active_class
        "_active" if active == true
      end

      def text
        default_value(configured_text, "")
      end

      def link
        default_value(configured_link, "#")
      end

      def yield(context:)
        !block.nil? ? context.capture(&block) : ""
      end

      def to_partial_path
        "pb_vertical_nav/item"
      end

    private

      DEFAULT = Object.new
      private_constant :DEFAULT
      def default_configuration
        DEFAULT
      end
      attr_accessor(*PROPS)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
playbook_ui-2.9.6 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.9.5 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.9.4 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.9.3 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.9.2 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.9.1 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.9.0 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.8.9 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.8.8 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.8.7 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.8.6 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.8.5 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.8.4 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.8.3 app/pb_kits/playbook/pb_vertical_nav/item.rb
playbook_ui-2.8.1 app/pb_kits/playbook/pb_vertical_nav/item.rb