lib/playbook/spacing.rb in playbook_ui-14.1.0.pre.alpha.fixaction3547 vs lib/playbook/spacing.rb in playbook_ui-14.1.0.pre.alpha.pbntr373enablekitsforradio3593
- old
+ new
@@ -9,10 +9,11 @@
base.prop :margin_right
base.prop :margin_top
base.prop :margin_x
base.prop :margin_y
base.prop :max_width
+ base.prop :min_width
base.prop :padding
base.prop :padding_bottom
base.prop :padding_left
base.prop :padding_right
base.prop :padding_top
@@ -24,14 +25,24 @@
{
max_width: "mw",
}
end
+ def min_width_options
+ {
+ min_width: "minw",
+ }
+ end
+
def max_width_values
- %w[xs sm md lg xl xxl 0 none]
+ %w[0% xs sm md lg xl xxl 0 none 100%]
end
+ def min_width_values
+ %w[0% xs sm md lg xl xxl 0 none 100%]
+ end
+
def spacing_options
{
margin: "m",
margin_bottom: "mb",
margin_left: "ml",
@@ -85,16 +96,34 @@
end
css.strip unless css.blank?
end
+ def filter_classname(value)
+ if value.include?("%")
+ value.gsub("%", "_percent")
+ else
+ value
+ end
+ end
+
+ def min_width_props
+ selected_minw_props = min_width_options.keys.select { |sk| try(sk) }
+ return nil unless selected_minw_props.present?
+
+ selected_minw_props.map do |k|
+ width_value = send(k)
+ "min_width_#{filter_classname(width_value)}" if min_width_values.include? width_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
+ "max_width_#{filter_classname(width_value)}" if max_width_values.include? width_value
end.compact.join(" ")
end
end
end