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/grid.rb,
app/lib/primer/classify/cache.rb,
app/lib/primer/classify/utilities.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, Grid, Utilities
Constant Summary collapse
- UTILITIES =
Load the utilities.yml file. Disabling because we want to load symbols, strings, and integers from the .yml file rubocop:disable Security/YAMLLoad
YAML.load( File.read( File.join(File.dirname(__FILE__), "./classify/utilities.yml") ) ).freeze
- DISPLAY_KEY =
rubocop:enable Security/YAMLLoad
:display- CONCAT_KEYS =
Keys where we can simply translate { key: value } into “.key-value”
i[position v 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[font_family font_style font_weight text_align text_transform].freeze
- WIDTH_KEY =
:width- HEIGHT_KEY =
:height- BOX_SHADOW_KEY =
:box_shadow- VISIBILITY_KEY =
:visibility- ANIMATION_KEY =
:animation- CONTAINER_KEY =
:container- BREAKPOINTS =
["", "-sm", "-md", "-lg", "-xl"].freeze
- RESPONSIVE_KEYS =
([DISPLAY_KEY, Primer::Classify::Grid::COL_KEY] + 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 =
( UTILITIES.keys + CONCAT_KEYS + BOOLEAN_MAPPINGS.keys + BORDER_MARGIN_KEYS + TYPOGRAPHY_KEYS + TEXT_KEYS + Primer::Classify::Flex::KEYS + Primer::Classify::Grid::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, CONTAINER_KEY ] ).freeze
Class Method Summary collapse
Class Method Details
.call(classes: "", style: nil, **args) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'app/lib/primer/classify.rb', line 118 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 |