primer_view_components 0.0.65 → 0.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/primer/classify/utilities.rb +37 -8
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/utilities.rake +2 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4a6941b7f05efc52cc514263c9d727dcccd549e0dd135ceb960c15e47aaf525
|
4
|
+
data.tar.gz: fe5dfd05411605f430910fd91439282a7fa7cfb75d1044648a5ca8373f44d668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e439f3027b7fbc6400c10ade09932ef6b3194f6ee2d0bf85aa6f741dc099128257cde449f7e4652e76f883b5740be4ed6bdf524ca47bc891a8a3974774522b2
|
7
|
+
data.tar.gz: 4d80d97768d80aeb523f25ff4403d7e4685048a537249e827941fb7e2cf503b380c7c90bccdd193e121fecef8197a2922c74c16c872bfa44f07c3d2d04cd19d4
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
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
|
-
|
199
|
+
selector.split("-").first.to_sym
|
171
200
|
end
|
172
201
|
end
|
173
202
|
end
|
data/lib/tasks/utilities.rake
CHANGED
@@ -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.
|
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.
|
589
|
+
rubygems_version: 3.1.6
|
590
590
|
signing_key:
|
591
591
|
specification_version: 4
|
592
592
|
summary: ViewComponents for the Primer Design System
|