Sha256: 2d4b582aba50e646ce8f232ed73d0523ce543233351dc189927b8dbb64f0ebe0

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbCard
    class Card < Playbook::PbKit::Base
      PROPS = %i[configured_aria
                 configured_classname
                 configured_data
                 configured_id
                 configured_shadow
                 block].freeze

      def initialize(aria: default_configuration,
                     classname: default_configuration,
                     data: default_configuration,
                     id: default_configuration,
                     shadow: default_configuration,
                     &block)
        self.configured_aria = aria
        self.configured_classname = classname
        self.configured_data = data
        self.configured_id = id
        self.configured_shadow = shadow
        self.block = block_given? ? block : nil
      end

      def shadow
        shadow_options = %w[shallow default deep deeper deepest]
        one_of_value(configured_shadow, shadow_options, "")
      end

      def shadow_class
        adjusted_value(shadow, "shadow_#{shadow}", nil)
      end

      def yield(context:)
        context.capture(&block)
      end

      def kit_class
        card_options = [
          "pb_card",
          shadow_class,
        ]
        card_options.reject(&:nil?).join(" ")
      end

      def to_partial_path
        "pb_card/card"
      end

    private

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
playbook_ui-2.8.4 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-2.8.3 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-2.8.1 app/pb_kits/playbook/pb_card/card.rb