primer_view_components 0.0.65 → 0.0.66

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63241aa31675216aea8f62b033158b0c4579b6d23948a1e18a37121227db5950
4
- data.tar.gz: 318312368ae79269609964c085921d6c3a152644e2e0fbe14bd0d60d277f47ce
3
+ metadata.gz: f4a6941b7f05efc52cc514263c9d727dcccd549e0dd135ceb960c15e47aaf525
4
+ data.tar.gz: fe5dfd05411605f430910fd91439282a7fa7cfb75d1044648a5ca8373f44d668
5
5
  SHA512:
6
- metadata.gz: 13aed5a21c4b87d3934b5b8269bf5fa24547b1616c9872be2d88897b3a1d712ea337b510119a07496d64f7ad1af2e8f337596c4a8d8e089d069fa2a31a1cd922
7
- data.tar.gz: c4b70c2613f21b890c9a6cac679bac409160acc055a16dc669a90bb318c617c477d595d51c2ae07841e277aef1a2c6125b82caa3783240caea958731fb4cb4e0
6
+ metadata.gz: 6e439f3027b7fbc6400c10ade09932ef6b3194f6ee2d0bf85aa6f741dc099128257cde449f7e4652e76f883b5740be4ed6bdf524ca47bc891a8a3974774522b2
7
+ data.tar.gz: 4d80d97768d80aeb523f25ff4403d7e4685048a537249e827941fb7e2cf503b380c7c90bccdd193e121fecef8197a2922c74c16c872bfa44f07c3d2d04cd19d4
data/CHANGELOG.md CHANGED
@@ -30,6 +30,12 @@ The category for changes related to documentation, testing and tooling. Also, fo
30
30
 
31
31
  ## main
32
32
 
33
+ ## 0.0.66
34
+
35
+ - Revert optimization changes to utilities.
36
+
37
+ _Josh Klina_
38
+
33
39
  ## 0.0.65
34
40
 
35
41
  ### Breaking Changes
@@ -19,6 +19,20 @@ module Primer
19
19
 
20
20
  BREAKPOINTS = ["", "-sm", "-md", "-lg", "-xl"].freeze
21
21
 
22
+ # Replacements for some classnames that end up being a different argument key
23
+ REPLACEMENT_KEYS = {
24
+ "^anim" => "animation",
25
+ "^v-align" => "vertical_align",
26
+ "^d" => "display",
27
+ "^wb" => "word_break",
28
+ "^v" => "visibility",
29
+ "^width" => "w",
30
+ "^height" => "h",
31
+ "^color-bg" => "bg",
32
+ "^color-border" => "border_color",
33
+ "^color-fg" => "color"
34
+ }.freeze
35
+
22
36
  SUPPORTED_KEY_CACHE = Hash.new { |h, k| h[k] = !UTILITIES[k].nil? }
23
37
  BREAKPOINT_INDEX_CACHE = Hash.new { |h, k| h[k] = BREAKPOINTS.index(k) }
24
38
 
@@ -159,15 +173,30 @@ module Primer
159
173
  private
160
174
 
161
175
  def find_selector(selector)
162
- # Build hash indexed on the selector for fast lookup.
163
- @selector_cache ||= UTILITIES.each_with_object({}) do |(keyword, argument_w_selectors), dict|
164
- argument_w_selectors.each do |argument, selectors|
165
- selectors.each_with_index do |css_selector, index|
166
- dict[css_selector] = [keyword, argument, index]
167
- end
168
- end
176
+ key = infer_selector_key(selector)
177
+ value_hash = UTILITIES[key]
178
+
179
+ return nil if value_hash.blank?
180
+
181
+ # Each value hash will also contain an array of classnames for breakpoints
182
+ # Key argument `0`, classes `[ "mr-0", "mr-sm-0", "mr-md-0", "mr-lg-0", "mr-xl-0" ]`
183
+ value_hash.each do |key_argument, classnames|
184
+ # Skip each value hash until we get one with the selector
185
+ next unless classnames.include?(selector)
186
+
187
+ # Return [:mr, 0, 1]
188
+ # has index of classname, so we can match it up with responsive array `mr: [nil, 0]`
189
+ return [key, key_argument, classnames.index(selector)]
190
+ end
191
+
192
+ nil
193
+ end
194
+
195
+ def infer_selector_key(selector)
196
+ REPLACEMENT_KEYS.each do |k, v|
197
+ return v.to_sym if selector.match?(Regexp.new(k))
169
198
  end
170
- @selector_cache[selector]
199
+ selector.split("-").first.to_sym
171
200
  end
172
201
  end
173
202
  end
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 65
8
+ PATCH = 66
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
@@ -5,6 +5,7 @@ namespace :utilities do
5
5
  require "yaml"
6
6
  require "json"
7
7
  require File.expand_path("./../../demo/config/environment.rb", __dir__)
8
+ require "primer/classify/utilities"
8
9
 
9
10
  # Keys that are looked for to be included in the utilities.yml file
10
11
  # rubocop:disable Lint/ConstantDefinitionInBlock
@@ -28,20 +29,6 @@ namespace :utilities do
28
29
  /^v\b/
29
30
  ].freeze
30
31
 
31
- # Replacements for some classnames that end up being a different argument key
32
- REPLACEMENT_KEYS = {
33
- "^anim" => "animation",
34
- "^v-align" => "vertical_align",
35
- "^d" => "display",
36
- "^wb" => "word_break",
37
- "^v" => "visibility",
38
- "^width" => "w",
39
- "^height" => "h",
40
- "^color-bg" => "bg",
41
- "^color-border" => "border_color",
42
- "^color-fg" => "color"
43
- }.freeze
44
-
45
32
  BREAKPOINTS = [nil, "sm", "md", "lg", "xl"].freeze
46
33
  # rubocop:enable Lint/ConstantDefinitionInBlock
47
34
 
@@ -80,7 +67,7 @@ namespace :utilities do
80
67
  key = ""
81
68
 
82
69
  # Look for a replacement key
83
- REPLACEMENT_KEYS.each do |k, v|
70
+ Primer::Classify::Utilities::REPLACEMENT_KEYS.each do |k, v|
84
71
  next unless classname.match?(Regexp.new(k))
85
72
 
86
73
  key = v
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.65
4
+ version: 0.0.66
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
@@ -586,7 +586,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
586
586
  - !ruby/object:Gem::Version
587
587
  version: '0'
588
588
  requirements: []
589
- rubygems_version: 3.1.2
589
+ rubygems_version: 3.1.6
590
590
  signing_key:
591
591
  specification_version: 4
592
592
  summary: ViewComponents for the Primer Design System