Method: Playbook::Spacing#spacing_props

Defined in:
lib/playbook/spacing.rb

#spacing_propsObject

[View source]

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/playbook/spacing.rb', line 97

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

  css = ""
  selected_props.each do |prop|
    responsive = try(prop).is_a?(::Hash)
    spacing_value = send(prop)
    prefix = spacing_options[prop]

    if responsive
      default_value = spacing_value.delete(:default) || nil
      break_value = spacing_value.delete(:break) || break_method_values.first
      spacing_value.each do |key, value|
        css += "break_#{break_value}_#{key}\:#{prefix}_#{value} " if screen_size_values.include?(key.to_s) && spacing_values.include?(value.to_s)
      end

      css += "#{prefix}_#{default_value} " if spacing_values.include?(default_value)
    elsif spacing_values.include?(spacing_value)
      css += "#{prefix}_#{spacing_value} "
    end
  end

  css.strip unless css.blank?
end