class Primer::Classify::Flex

Handler for PrimerCSS flex classes.

Constants

ALIGN_ITEMS_KEY
ALIGN_ITEMS_VALUES
ALIGN_SELF_KEY
ALIGN_SELF_VALUES
DIRECTION_KEY
DIRECTION_VALUES
FLEX_KEY
FLEX_VALUES
GROW_KEY
GROW_VALUES
JUSTIFY_CONTENT_KEY
JUSTIFY_CONTENT_VALUES
KEYS
RESPONSIVE_KEYS
SHRINK_KEY
SHRINK_VALUES
WRAP_KEY
WRAP_MAPPINGS

Public Class Methods

classes(key, value, breakpoint) click to toggle source
# File lib/primer/classify/flex.rb, line 41
def classes(key, value, breakpoint)
  send(key, value, breakpoint)
end

Private Class Methods

align_items(value, breakpoint) click to toggle source
# File lib/primer/classify/flex.rb, line 96
def align_items(value, breakpoint)
  val = fetch_or_fallback(ALIGN_ITEMS_VALUES, value)

  formatted_value = val.to_s.gsub("flex_", "")
  "flex#{breakpoint}-items-#{formatted_value}"
end
align_self(value, _breakpoint) click to toggle source
# File lib/primer/classify/flex.rb, line 71
def align_self(value, _breakpoint)
  generate(
    value: value,
    allowed_values: ALIGN_SELF_VALUES,
    prefix: "flex-self"
  )
end
direction(value, breakpoint) click to toggle source
# File lib/primer/classify/flex.rb, line 83
def direction(value, breakpoint)
  val = fetch_or_fallback(DIRECTION_VALUES, value)

  "flex#{breakpoint}-#{val.to_s.dasherize}"
end
flex(value, _breakpoint) click to toggle source
# File lib/primer/classify/flex.rb, line 47
def flex(value, _breakpoint)
  generate(
    value: value,
    allowed_values: FLEX_VALUES,
    prefix: "flex"
  )
end
flex_grow(value, _breakpoint) click to toggle source
# File lib/primer/classify/flex.rb, line 63
def flex_grow(value, _breakpoint)
  generate(
    value: value,
    allowed_values: GROW_VALUES,
    prefix: "flex-grow"
  )
end
flex_shrink(value, _breakpoint) click to toggle source
# File lib/primer/classify/flex.rb, line 55
def flex_shrink(value, _breakpoint)
  generate(
    value: value,
    allowed_values: SHRINK_VALUES,
    prefix: "flex-shrink"
  )
end
flex_wrap(value, _breakpoint) click to toggle source
# File lib/primer/classify/flex.rb, line 79
def flex_wrap(value, _breakpoint)
  WRAP_MAPPINGS[fetch_or_fallback(WRAP_MAPPINGS.keys, value)]
end
generate(value:, allowed_values:, prefix:) click to toggle source
# File lib/primer/classify/flex.rb, line 103
def generate(value:, allowed_values:, prefix:)
  val = fetch_or_fallback(allowed_values, value)

  "#{prefix}-#{val}"
end
justify_content(value, breakpoint) click to toggle source
# File lib/primer/classify/flex.rb, line 89
def justify_content(value, breakpoint)
  val = fetch_or_fallback(JUSTIFY_CONTENT_VALUES, value)

  formatted_value = val.to_s.gsub(/(flex_|space_)/, "")
  "flex#{breakpoint}-justify-#{formatted_value}"
end