Sha256: 47d600b8cd9a7a8804cfadc551ac5f7cc257e68cf43172c34cfe1ff51cf3025a

Contents?: true

Size: 1.29 KB

Versions: 117

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbFlex
    class FlexItem < Playbook::KitBase
      prop :fixed_size, default: nil
      prop :grow, type: Playbook::Props::Boolean,
                  default: false
      prop :shrink, type: Playbook::Props::Boolean,
                    default: false
      prop :flex, type: Playbook::Props::Enum,
                  values: %w[0 1 2 3 4 5 6 7 8 9 10 11 12 none],
                  default: "none"
      prop :overflow, type: Playbook::Props::Enum,
                      values: %w[auto hidden inherit initial scroll visible] + [nil],
                      default: nil

      def classname
        generate_classname("pb_flex_item_kit", fixed_size_class, grow_class, shrink_class, flex_class) + overflow_class
      end

      def style_value
        "flex-basis: #{fixed_size};" if fixed_size.present?
      end

    private

      def fixed_size_class
        fixed_size.present? ? "fixed_size" : nil
      end

      def grow_class
        grow ? "grow" : nil
      end

      def overflow_class
        overflow ? " overflow_#{overflow}" : ""
      end

      def shrink_class
        shrink ? "shrink" : nil
      end

      def flex_class
        if flex == "none"
          nil
        else
          "flex_#{flex}"
        end
      end
    end
  end
end

Version data entries

117 entries across 117 versions & 1 rubygems

Version Path
playbook_ui-10.14.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.13.1 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.13.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.13.0.pre.node.update app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.12.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.11.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.10.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.9.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.8.1.pre.alpha.flexdeps app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.9.0.pre.alpha1 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.8.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.7.1 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.7.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.6.2.pre.alpha.dep app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.6.1.pre.alpha1 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.6.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.5.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.4.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.3.0 app/pb_kits/playbook/pb_flex/flex_item.rb
playbook_ui-10.2.1.alpha.sisensefix app/pb_kits/playbook/pb_flex/flex_item.rb