Sha256: f8dc67f95b83e7984cd0776105c609072f5d027356750de245c805fd1f1d447e

Contents?: true

Size: 1.72 KB

Versions: 18

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbCard
    class Card < Playbook::KitBase
      prop :selected, type: Playbook::Props::Boolean, default: false
      prop :shadow, type: Playbook::Props::Enum,
                    values: %w[none deep deeper deepest],
                    default: "none"
      prop :highlight, type: Playbook::Props::Hash,
                       default: {}
      prop :border_none, type: Playbook::Props::Boolean,
                         default: false
      prop :border_radius, type: Playbook::Props::Enum,
                           values: %w[xs sm md lg xl none rounded],
                           default: "md"

      def classname
        generate_classname("pb_card_kit",
                           selected_class,
                           shadow_class,
                           highlight_position_class,
                           highlight_color_class,
                           border_class,
                           border_radius_class)
      end

      def body_padding
        if padding.present?
          ""
        else
          "p_md"
        end
      end

    private

      def selected_class
        selected ? "selected" : "deselected"
      end

      def shadow_class
        shadow != "none" ? "shadow_#{shadow}" : nil
      end

      def highlight_position_class
        highlight[:position].present? ? "highlight_#{highlight[:position]}" : nil
      end

      def highlight_color_class
        highlight[:color].present? ? "highlight_#{highlight[:color]}" : nil
      end

      def border_class
        border_none == true ? "border_none" : nil
      end

      def border_radius_class
        border_radius != "md" ? "border_radius_#{border_radius}" : nil
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
playbook_ui-8.1.3 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.1.2 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.0.3 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.2.0.pre.alpha2 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.1.1 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.0.2 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.2.0.pre.alpha1 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.1.0 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.0.1 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.0.0 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.0.0.pre.alpha5 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.0.0.pre.alpha4 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-8.0.0.pre.alpha1 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-7.16.0.pre.alpha5 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-7.16.0.pre.alpha4 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-7.16.0.pre.alpha3 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-7.16.0.pre.alpha2 app/pb_kits/playbook/pb_card/card.rb
playbook_ui-7.16.0.pre.alpha1 app/pb_kits/playbook/pb_card/card.rb