Sha256: c256c51c0316ac368c68859f8e5fc72046b30cfd180d94486730b763c1b32166

Contents?: true

Size: 1.77 KB

Versions: 109

Compression:

Stored size: 1.77 KB

Contents

# frozen_string_literal: true

module Playbook
  module Spacing
    def self.included(base)
      base.prop :margin
      base.prop :margin_bottom
      base.prop :margin_left
      base.prop :margin_right
      base.prop :margin_top
      base.prop :margin_x
      base.prop :margin_y
      base.prop :max_width
      base.prop :padding
      base.prop :padding_bottom
      base.prop :padding_left
      base.prop :padding_right
      base.prop :padding_top
      base.prop :padding_x
      base.prop :padding_y
    end

    def spacing_options
      {
        margin: "m",
        margin_bottom: "mb",
        margin_left: "ml",
        margin_right: "mr",
        margin_top: "mt",
        margin_x: "mx",
        margin_y: "my",
        padding: "p",
        padding_bottom: "pb",
        padding_left: "pl",
        padding_right: "pr",
        padding_top: "pt",
        padding_x: "px",
        padding_y: "py",
      }
    end

    def spacing_values
      %w[none xxs xs sm md lg xl]
    end

    def spacing_props
      selected_props = spacing_options.keys.select { |sk| try(sk) }
      return nil unless selected_props.present?

      selected_props.map do |k|
        spacing_value = send(k)
        "#{spacing_options[k]}_#{spacing_value}" if spacing_values.include? spacing_value
      end.compact.join(" ")
    end

    def max_width_props
      selected_mw_props = max_width_options.keys.select { |sk| try(sk) }
      return nil unless selected_mw_props.present?

      selected_mw_props.map do |k|
        width_value = send(k)
        "max_width_#{width_value}" if max_width_values.include? width_value
      end.compact.join(" ")
    end

    def max_width_options
      {
        max_width: "mw",
      }
    end

    def max_width_values
      %w[xs sm md lg xl 0 none]
    end
  end
end

Version data entries

109 entries across 109 versions & 1 rubygems

Version Path
playbook_ui-12.17.1 lib/playbook/spacing.rb
playbook_ui-12.17.0.pre.alpha.lightboxcurrentPhotoIndex582 lib/playbook/spacing.rb
playbook_ui-12.17.0 lib/playbook/spacing.rb
playbook_ui-12.16.0.pre.alpha.tooltippositionprop566 lib/playbook/spacing.rb
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg558 lib/playbook/spacing.rb
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg547 lib/playbook/spacing.rb
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg532 lib/playbook/spacing.rb
playbook_ui-12.16.0.pre.alpha.lightboxcurrentphotoprop531 lib/playbook/spacing.rb
playbook_ui-12.16.0.pre.alpha.tiptaptestingpart1528 lib/playbook/spacing.rb
playbook_ui-12.16.0 lib/playbook/spacing.rb
playbook_ui-12.15.0 lib/playbook/spacing.rb
playbook_ui-12.14.0.pre.alpha.lightboxcurrentphotoprop460 lib/playbook/spacing.rb
playbook_ui-12.14.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown457 lib/playbook/spacing.rb
playbook_ui-12.14.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown456 lib/playbook/spacing.rb
playbook_ui-12.14.0 lib/playbook/spacing.rb
playbook_ui-12.13.0.pre.alpha.PLAY693tooltipwrongbg440 lib/playbook/spacing.rb
playbook_ui-12.13.0.pre.alpha.addingProductTokens439 lib/playbook/spacing.rb
playbook_ui-12.13.0.pre.alpha.PLAY705phonenumberkit438 lib/playbook/spacing.rb
playbook_ui-12.13.0 lib/playbook/spacing.rb
playbook_ui-12.12.0.pre.alpha.PLAY697sandpacklayoutstyles413 lib/playbook/spacing.rb