Method: Playbook::PbNav::Item#margin_classes

Defined in:
app/pb_kits/playbook/pb_nav/item.rb

#margin_classesObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/pb_kits/playbook/pb_nav/item.rb', line 62

def margin_classes
  margin_attributes = {
    margin: "m",
    margin_x: "mx",
    margin_y: "my",
    margin_bottom: "mb",
    margin_top: "mt",
    margin_right: "mr",
    margin_left: "ml",
  }

  # rubocop:disable Style/RedundantAssignment
  margin_classes = margin_attributes.map do |attr, class_prefix|
    # rubocop:enable Style/RedundantAssignment
    value = object.public_send(attr)
    " #{class_prefix}_#{value}" if value
  end.compact.join

  margin_classes
end