Sha256: 6b434690cbfebe02cbb93a37778c89ee9c0dd34ff43c0dd08a1e8a7492e883b9

Contents?: true

Size: 1.88 KB

Versions: 18

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

module Primer
  class Classify
    # Text specific functional colors.
    # https://primer-css-git-mkt-color-modes-docs-primer.vercel.app/css/support/v16-migration#text
    class FunctionalTextColors < FunctionalColors
      FUNCTIONAL_OPTIONS = {
        primary: :text_primary,
        secondary: :text_secondary,
        tertiary: :text_tertiary,
        link: :text_link,
        success: :text_success,
        warning: :text_warning,
        danger: :text_danger,
        white: :text_white,
        inverse: :text_inverse
      }.freeze

      # colors mapping to `nil` will preserve the old classes.
      # e.g. `text: :orange` will generate `text-orange`.
      MAPPINGS = {
        gray_dark: FUNCTIONAL_OPTIONS[:primary],
        gray: FUNCTIONAL_OPTIONS[:secondary],
        gray_light: FUNCTIONAL_OPTIONS[:tertiary],
        blue: FUNCTIONAL_OPTIONS[:link],
        green: FUNCTIONAL_OPTIONS[:success],
        yellow: FUNCTIONAL_OPTIONS[:warning],
        red: FUNCTIONAL_OPTIONS[:danger],
        white: FUNCTIONAL_OPTIONS[:white]
      }.freeze

      OPTIONS = [
        :icon_primary,
        :icon_secondary,
        :icon_tertiary,
        :icon_info,
        :icon_success,
        :icon_warning,
        :icon_danger,
        *FUNCTIONAL_OPTIONS.values
      ].freeze
      OPTIONS_WITHOUT_MAPPINGS = [:black, :orange, :orange_light, :purple, :pink, :inherit].freeze
      DEPRECATED_OPTIONS = [*MAPPINGS.keys, *OPTIONS_WITHOUT_MAPPINGS].freeze

      class << self
        def color(val)
          functional_color(
            key: "color",
            value: val,
            mappings: MAPPINGS,
            non_functional_prefix: "text",
            functional_prefix: "color",
            number_prefix: "color",
            functional_options: OPTIONS,
            options_without_mappigs: OPTIONS_WITHOUT_MAPPINGS
          )
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
primer_view_components-0.0.45 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.44 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.43 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.42 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.41 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.40 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.39 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.38 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.37 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.36 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.35 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.34 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.33 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.32 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.31 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.30 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.29 app/lib/primer/classify/functional_text_colors.rb
primer_view_components-0.0.28 app/lib/primer/classify/functional_text_colors.rb