add support for border margins
MODIFY
lib/primer/classify.rb
lib/primer/classify.rb
@@ -77,7 +77,7 @@ module Primer
]
}
}.freeze
- BORDER_KEYS = [:border, :border_color].freeze
+ BORDER_KEYS = [:border, :border_color, :border_top, :border_bottom, :border_left, :border_right].freeze
TYPOGRAPHY_KEYS = [:font_size].freeze
VALID_KEYS = (
CONCAT_KEYS +
@@ -170,6 +170,8 @@ module Primer
end
dasherized_val = val.to_s.dasherize
+ dasherized_key = key.to_s.dasherize
+
breakpoint = BREAKPOINTS[index]
if BOOLEAN_MAPPINGS.has_key?(key)
@@ -195,7 +197,11 @@ module Primer
elsif key == WORD_BREAK_KEY
memo[:classes] << "wb-#{dasherized_val}"
elsif BORDER_KEYS.include?(key)
+ if (key == :border || key == :border_color)
memo[:classes] << "border-#{dasherized_val}"
+ else
+ memo[:classes] << "#{dasherized_key}-#{val}"
+ end
elsif key == DIRECTION_KEY
memo[:classes] << "flex#{breakpoint}-#{dasherized_val}"
elsif key == JUSTIFY_CONTENT_KEY

MODIFY
test/primer/classify_test.rb
test/primer/classify_test.rb
@@ -172,10 +172,13 @@ class PrimerClassifyTest < Minitest::Test
assert_generated_class("border-bottom", { border: :bottom })
assert_generated_class("border-right", { border: :right })
assert_generated_class("border-y", { border: :y })
- assert_generated_class("border-top-0", { border: :top_0 })
- assert_generated_class("border-bottom-0", { border: :bottom_0 })
- assert_generated_class("border-left-0", { border: :left_0 })
- assert_generated_class("border-right-0", { border: :right_0 })
+ end
+
+ def test_border_margins
+ assert_generated_class("border-top-0", { border_top: 0 })
+ assert_generated_class("border-bottom-0", { border_bottom: 0 })
+ assert_generated_class("border-left-0", { border_left: 0 })
+ assert_generated_class("border-right-0", { border_right: 0 })
end
def test_border_color

add support for border margins