primer_view_components 0.0.57 → 0.0.58

Sign up to get free protection for your applications and to get access to all the features.
@@ -125,7 +125,12 @@ module RuboCop
125
125
  orange_6: nil,
126
126
  orange_7: nil,
127
127
  orange_8: nil,
128
- orange_9: nil
128
+ orange_9: nil,
129
+ purple_light: nil,
130
+ purple: nil,
131
+ yellow_dark: nil,
132
+ orange: nil,
133
+ pink: nil
129
134
  },
130
135
  border_color: {
131
136
  gray: "border_color: :primary",
@@ -11,6 +11,8 @@ namespace :utilities do
11
11
  # rubocop:disable Lint/ConstantDefinitionInBlock
12
12
  SUPPORTED_KEYS = %i[
13
13
  anim
14
+ color-bg
15
+ color-border
14
16
  color-icon
15
17
  color-text
16
18
  d
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.57
4
+ version: 0.0.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-13 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -505,9 +505,6 @@ files:
505
505
  - lib/primer/classify.rb
506
506
  - lib/primer/classify/cache.rb
507
507
  - lib/primer/classify/flex.rb
508
- - lib/primer/classify/functional_background_colors.rb
509
- - lib/primer/classify/functional_border_colors.rb
510
- - lib/primer/classify/functional_colors.rb
511
508
  - lib/primer/classify/grid.rb
512
509
  - lib/primer/classify/utilities.rb
513
510
  - lib/primer/classify/utilities.yml
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "functional_colors"
4
-
5
- module Primer
6
- class Classify
7
- # Background specific functional colors
8
- # https://primer-css-git-mkt-color-modes-docs-primer.vercel.app/css/support/v16-migration#background
9
- class FunctionalBackgroundColors < FunctionalColors
10
- FUNCTIONAL_OPTIONS = {
11
- primary: :primary,
12
- secondary: :secondary,
13
- tertiary: :tertiary,
14
- canvas: :canvas,
15
- canvas_inset: :canvas_inset,
16
- canvas_inverse: :canvas_inverse,
17
- info: :info,
18
- info_inverse: :info_inverse,
19
- success: :success,
20
- success_inverse: :success_inverse,
21
- warning: :warning,
22
- warning_inverse: :warning_inverse,
23
- danger: :danger,
24
- danger_inverse: :danger_inverse,
25
- overlay: :overlay
26
- }.freeze
27
-
28
- MAPPINGS = {
29
- white: FUNCTIONAL_OPTIONS[:primary],
30
- gray_light: FUNCTIONAL_OPTIONS[:secondary],
31
- gray: FUNCTIONAL_OPTIONS[:tertiary],
32
- gray_dark: FUNCTIONAL_OPTIONS[:canvas_inverse],
33
- blue_light: FUNCTIONAL_OPTIONS[:info],
34
- blue: FUNCTIONAL_OPTIONS[:info_inverse],
35
- green_light: FUNCTIONAL_OPTIONS[:success],
36
- green: FUNCTIONAL_OPTIONS[:success_inverse],
37
- yellow_light: FUNCTIONAL_OPTIONS[:warning],
38
- yellow: FUNCTIONAL_OPTIONS[:warning_inverse],
39
- red_light: FUNCTIONAL_OPTIONS[:danger],
40
- red: FUNCTIONAL_OPTIONS[:danger_inverse]
41
- }.freeze
42
-
43
- OPTIONS = FUNCTIONAL_OPTIONS.values.freeze
44
- OPTIONS_WITHOUT_MAPPINGS = [:purple_light, :purple, :yellow_dark, :orange, :pink].freeze
45
- DEPRECATED_OPTIONS = [*MAPPINGS.keys, *OPTIONS_WITHOUT_MAPPINGS].freeze
46
-
47
- class << self
48
- def color(val)
49
- functional_color(
50
- key: "background",
51
- value: val,
52
- mappings: MAPPINGS,
53
- non_functional_prefix: "bg",
54
- functional_prefix: "color-bg",
55
- number_prefix: "bg",
56
- functional_options: OPTIONS,
57
- options_without_mappigs: OPTIONS_WITHOUT_MAPPINGS
58
- )
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "functional_colors"
4
-
5
- module Primer
6
- class Classify
7
- # Border specific functional colors
8
- # https://primer-css-git-mkt-color-modes-docs-primer.vercel.app/css/support/v16-migration#border
9
- class FunctionalBorderColors < FunctionalColors
10
- FUNCTIONAL_OPTIONS = {
11
- primary: :primary,
12
- secondary: :secondary,
13
- tertiary: :tertiary,
14
- info: :info,
15
- success: :success,
16
- warning: :warning,
17
- danger: :danger,
18
- inverse: :inverse
19
- }.freeze
20
-
21
- MAPPINGS = {
22
- gray: FUNCTIONAL_OPTIONS[:primary],
23
- gray_light: FUNCTIONAL_OPTIONS[:secondary],
24
- gray_dark: FUNCTIONAL_OPTIONS[:tertiary],
25
- blue: FUNCTIONAL_OPTIONS[:info],
26
- green: FUNCTIONAL_OPTIONS[:success],
27
- yellow: FUNCTIONAL_OPTIONS[:warning],
28
- red: FUNCTIONAL_OPTIONS[:danger],
29
- white: FUNCTIONAL_OPTIONS[:inverse]
30
- }.freeze
31
-
32
- OPTIONS = FUNCTIONAL_OPTIONS.values.freeze
33
- OPTIONS_WITHOUT_MAPPINGS = [:gray_darker, :blue_light, :red_light, :purple, :black_fade, :white_fade].freeze
34
- DEPRECATED_OPTIONS = [*MAPPINGS.keys, *OPTIONS_WITHOUT_MAPPINGS].freeze
35
-
36
- class << self
37
- def color(val)
38
- functional_color(
39
- key: "border",
40
- value: val,
41
- mappings: MAPPINGS,
42
- non_functional_prefix: "border",
43
- functional_prefix: "color-border",
44
- number_prefix: "border",
45
- functional_options: OPTIONS,
46
- options_without_mappigs: OPTIONS_WITHOUT_MAPPINGS
47
- )
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- class Classify
5
- # https://primer-css-git-mkt-color-modes-docs-primer.vercel.app/css/support/v16-migration
6
- class FunctionalColors
7
- class << self
8
- def color(val)
9
- # Implemented by class' childrens.
10
- end
11
-
12
- private
13
-
14
- # @param key [String|Symbol] Option name.
15
- # @param value [String|Symbol] Option value.
16
- # @param mappings [Hash] A `color` => `functional_color` mapping hash.
17
- # @param non_functional_prefix [String] The prefix to use for the non-functional color classes. E.g. "text" would create "text-value".
18
- # @param functional_prefix [String] The prefix to use for the functional color classes. E.g. "color-text" would create "color-text-value".
19
- # @param number_prefix [String] The prefix to use for colors ending with number. E.g. "text" would create "text-value-1".
20
- # @param functional_options [Array] All the acceptable functional values.
21
- # @param options_without_mappigs [Array] Non functional values that don't have an associated functional color.
22
- def functional_color(
23
- key:,
24
- value:,
25
- mappings:,
26
- non_functional_prefix:,
27
- functional_options:,
28
- functional_prefix: "",
29
- number_prefix: "",
30
- options_without_mappigs: []
31
- )
32
- sym_value = value.to_sym
33
- dasherized_value = value.to_s.dasherize
34
- # the value is a functional color
35
- return "#{number_prefix}-#{dasherized_value}" if ends_with_number?(sym_value)
36
- return "#{functional_prefix}-#{dasherized_value}" if functional_options.include?(sym_value)
37
- # if the app still allows non functional colors
38
- return "#{non_functional_prefix}-#{dasherized_value}" unless force_functional_colors?
39
-
40
- if mappings.key?(sym_value) || options_without_mappigs.include?(sym_value)
41
- functional_color = mappings[sym_value]
42
- # colors without functional mapping stay the same
43
- return "#{non_functional_prefix}-#{dasherized_value}" if functional_color.blank?
44
-
45
- ActiveSupport::Deprecation.warn("#{key} #{value} is deprecated. Please use #{functional_color} instead.") unless Rails.env.production? || silence_deprecations?
46
-
47
- return "#{functional_prefix}-#{functional_color.to_s.dasherize}"
48
- end
49
-
50
- raise ArgumentError, "#{key} #{value} does not exist." unless Rails.env.production?
51
- end
52
-
53
- def ends_with_number?(val)
54
- char_code = val[-1].ord
55
- char_code >= 48 && char_code <= 57
56
- end
57
-
58
- def force_functional_colors?
59
- Rails.application.config.primer_view_components.force_functional_colors
60
- end
61
-
62
- def silence_deprecations?
63
- Rails.application.config.primer_view_components.silence_deprecations
64
- end
65
- end
66
- end
67
- end
68
- end