Class: Primer::Classify
- Inherits:
-
Object
- Object
- Primer::Classify
- Defined in:
- app/lib/primer/classify.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, FunctionalBackgroundColors, FunctionalBorderColors, FunctionalColors, FunctionalTextColors, Spacing
Constant Summary collapse
- DIRECTION_KEY =
:direction- JUSTIFY_CONTENT_KEY =
:justify_content- ALIGN_ITEMS_KEY =
:align_items- DISPLAY_KEY =
:display- SPACING_KEYS =
Primer::Classify::Spacing::KEYS
- RESPONSIVE_KEYS =
([DISPLAY_KEY, DIRECTION_KEY, JUSTIFY_CONTENT_KEY, ALIGN_ITEMS_KEY, :col, :float] + SPACING_KEYS).freeze
- BREAKPOINTS =
["", "-sm", "-md", "-lg", "-xl"].freeze
- 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-", "text-", "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
- FLEX_KEY =
:flex- FLEX_GROW_KEY =
:flex_grow- FLEX_SHRINK_KEY =
:flex_shrink- ALIGN_SELF_KEY =
:align_self- WIDTH_KEY =
:width- HEIGHT_KEY =
:height- BOX_SHADOW_KEY =
:box_shadow- VISIBILITY_KEY =
:visibility- ANIMATION_KEY =
:animation- 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 + [ BORDER_KEY, BORDER_COLOR_KEY, BORDER_RADIUS_KEY, COLOR_KEY, BG_KEY, DISPLAY_KEY, VERTICAL_ALIGN_KEY, WORD_BREAK_KEY, DIRECTION_KEY, JUSTIFY_CONTENT_KEY, ALIGN_ITEMS_KEY, FLEX_KEY, FLEX_GROW_KEY, FLEX_SHRINK_KEY, ALIGN_SELF_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
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'app/lib/primer/classify.rb', line 117 def call(classes: "", style: nil, **args) extracted_results = extract_hash(args) extracted_results[:class] = [ validated_class_names(classes), extracted_results.delete(:classes) ].compact.join(" ").presence extracted_results[:style] = [ extracted_results.delete(:styles), style ].compact.join("").presence extracted_results end |