Class: Primer::Classify
- Inherits:
-
Object
- Object
- Primer::Classify
- Defined in:
- app/lib/primer/classify.rb,
app/lib/primer/classify/flex.rb,
app/lib/primer/classify/cache.rb,
app/lib/primer/classify/spacing.rb,
app/lib/primer/classify/functional_colors.rb,
app/lib/primer/classify/functional_text_colors.rb,
app/lib/primer/classify/functional_border_colors.rb,
app/lib/primer/classify/functional_background_colors.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Cache, Flex, FunctionalBackgroundColors, FunctionalBorderColors, FunctionalColors, FunctionalTextColors, Spacing
Constant Summary collapse
- DISPLAY_KEY =
:display- SPACING_KEYS =
Primer::Classify::Spacing::KEYS
- CONCAT_KEYS =
Keys where we can simply translate { key: value } into “.key-value”
SPACING_KEYS + i[hide position v float col text box_shadow].freeze
- INVALID_CLASS_NAME_PREFIXES =
(["bg-", "color-", "text-", "d-", "v-align-", "wb-", "box-shadow-"] + CONCAT_KEYS.map { |k| "#{k}-" }).freeze
- COLOR_KEY =
:color- BG_KEY =
:bg- VERTICAL_ALIGN_KEY =
:vertical_align- WORD_BREAK_KEY =
:word_break- TEXT_KEYS =
i[text_align font_weight].freeze
- WIDTH_KEY =
:width- HEIGHT_KEY =
:height- BOX_SHADOW_KEY =
:box_shadow- VISIBILITY_KEY =
:visibility- ANIMATION_KEY =
:animation- BREAKPOINTS =
["", "-sm", "-md", "-lg", "-xl"].freeze
- RESPONSIVE_KEYS =
([DISPLAY_KEY, :col, :float] + SPACING_KEYS + Primer::Classify::Flex::RESPONSIVE_KEYS).freeze
- BOOLEAN_MAPPINGS =
{ underline: { mappings: [ { value: true, css_class: "text-underline" }, { value: false, css_class: "no-underline" } ] }, top: { mappings: [ { value: false, css_class: "top-0" } ] }, bottom: { mappings: [ { value: false, css_class: "bottom-0" } ] }, left: { mappings: [ { value: false, css_class: "left-0" } ] }, right: { mappings: [ { value: false, css_class: "right-0" } ] } }.freeze
- BORDER_KEY =
:border- BORDER_COLOR_KEY =
:border_color- BORDER_MARGIN_KEYS =
i[border_top border_bottom border_left border_right].freeze
- BORDER_RADIUS_KEY =
:border_radius- TYPOGRAPHY_KEYS =
[:font_size].freeze
- VALID_KEYS =
( CONCAT_KEYS + BOOLEAN_MAPPINGS.keys + BORDER_MARGIN_KEYS + TYPOGRAPHY_KEYS + TEXT_KEYS + Primer::Classify::Flex::KEYS + [ BORDER_KEY, BORDER_COLOR_KEY, BORDER_RADIUS_KEY, COLOR_KEY, BG_KEY, DISPLAY_KEY, VERTICAL_ALIGN_KEY, WORD_BREAK_KEY, WIDTH_KEY, HEIGHT_KEY, BOX_SHADOW_KEY, VISIBILITY_KEY, ANIMATION_KEY ] ).freeze
Class Method Summary collapse
Class Method Details
.call(classes: "", style: nil, **args) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'app/lib/primer/classify.rb', line 105 def call(classes: "", style: nil, **args) extracted_results = extract_hash(args) extracted_results[:class] = [ validated_class_names(classes), extracted_results.delete(:classes) ].compact.join(" ").strip.presence extracted_results[:style] = [ extracted_results.delete(:styles), style ].compact.join("").presence extracted_results end |