primer_view_components 0.0.50 → 0.0.51

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81f226f5fd176e5a1565b2064ba3a85a8af1c11bfd7c3c9503714f3f5cd41dac
4
- data.tar.gz: d655dc0cfa7260a09de3f1f662a1317eb2540914407f33cfdbc07b369a6cd5b0
3
+ metadata.gz: 2e619cd65db4a67059cc81f1d9f7d57a9c3b6c9cf9dadf9cfb2cd4c37fdcedc2
4
+ data.tar.gz: 18eaf89147d7a3e415520b09f117bf4b748fbb9a06e166df12ccc3a930506007
5
5
  SHA512:
6
- metadata.gz: 07bc38eedefeae46a76d6f7a4b28892a4f01ab0018564c610d8143919c3fed93da3ad91c7970225fdfaac1fd12a294b51e245633f690e87b7392a21d3d3d65f8
7
- data.tar.gz: c162cf3fca8accf0a92b9045e9e77bce16d3e646793a3fd479b12efd7e545e0cb9c56cc60884b39965ed7f41baf502d990cee3279170a3b896c845558a3ba714
6
+ metadata.gz: 821f1b4b53b823049bbc8e1a740b1f21d36ada796e69c59471c9f9a28183b5d94a61958544ef3c3e6386424b595e72627abcab2cd05d61de10104ea40941e201
7
+ data.tar.gz: 58d0e5f7961736bee805ed3d99d5432bb4dfa16df8170abe89b1f24f2857cf80a17a578fb762b0f6f1e5b307fe96a9803e960cce6a1a2901282908e678295f79
data/CHANGELOG.md CHANGED
@@ -30,6 +30,20 @@ The category for changes related to documentation, testing and tooling. Also, fo
30
30
 
31
31
  ## main
32
32
 
33
+ ## 0.0.51
34
+
35
+ ### Breaking changes
36
+
37
+ * Rename `width` and `height` System Arguments to `w` and `h`, resolving conflict with HTML attribute names.
38
+
39
+ *Manuel Puyol*
40
+
41
+ ### Updates
42
+
43
+ * `SystemArgumentInsteadOfClass` linter will check for arguments in ViewHelpers.
44
+
45
+ *Manuel Puyol*
46
+
33
47
  ## 0.0.50
34
48
 
35
49
  ### New
@@ -93,8 +93,8 @@ module Primer
93
93
  # | Name | Type | Description |
94
94
  # | :- | :- | :- |
95
95
  # | `display` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:display)) %> |
96
- # | `width` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:width)) %>. Also supports integer values. |
97
- # | `height` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:height)) %>. Also supports integer values. |
96
+ # | `w` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:w)) %> Also supports integer values. |
97
+ # | `h` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:h)) %> Also supports integer values. |
98
98
  # | `hide` | Symbol | Hide the element at a specific breakpoint. <%= one_of(Primer::Classify::Utilities.mappings(:hide)) %> |
99
99
  # | `visibility` | Symbol | Visibility. <%= one_of(Primer::Classify::Utilities.mappings(:visibility)) %> |
100
100
  # | `vertical_align` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:vertical_align)) %> |
@@ -20,8 +20,6 @@ module Primer
20
20
  COLOR_KEY = :color
21
21
  BG_KEY = :bg
22
22
  TEXT_KEYS = %i[font_family font_style font_weight text_align text_transform].freeze
23
- WIDTH_KEY = :width
24
- HEIGHT_KEY = :height
25
23
  BOX_SHADOW_KEY = :box_shadow
26
24
  CONTAINER_KEY = :container
27
25
 
@@ -94,8 +92,6 @@ module Primer
94
92
  BORDER_RADIUS_KEY,
95
93
  COLOR_KEY,
96
94
  BG_KEY,
97
- WIDTH_KEY,
98
- HEIGHT_KEY,
99
95
  BOX_SHADOW_KEY,
100
96
  CONTAINER_KEY
101
97
  ]
@@ -170,9 +166,7 @@ module Primer
170
166
  def extract_value(memo, key, val, breakpoint)
171
167
  return if val.nil? || val == ""
172
168
 
173
- if (key == WIDTH_KEY || key == HEIGHT_KEY) && !val.is_a?(Symbol)
174
- memo[key] = val
175
- elsif Primer::Classify::Utilities.supported_key?(key)
169
+ if Primer::Classify::Utilities.supported_key?(key)
176
170
  memo[:classes] << Primer::Classify::Utilities.classname(key, val, breakpoint)
177
171
  elsif BOOLEAN_MAPPINGS.key?(key)
178
172
  BOOLEAN_MAPPINGS[key][:mappings].each do |m|
@@ -24,7 +24,9 @@ module Primer
24
24
  "^v-align" => "vertical_align",
25
25
  "^d" => "display",
26
26
  "^wb" => "word_break",
27
- "^v" => "visibility"
27
+ "^v" => "visibility",
28
+ "^width" => "w",
29
+ "^height" => "h"
28
30
  }.freeze
29
31
 
30
32
  class << self
@@ -85,7 +85,7 @@
85
85
  - float-md-none
86
86
  - float-lg-none
87
87
  - float-xl-none
88
- :width:
88
+ :w:
89
89
  :fit:
90
90
  - width-fit
91
91
  :full:
@@ -96,7 +96,7 @@
96
96
  - width-md-auto
97
97
  - width-lg-auto
98
98
  - width-xl-auto
99
- :height:
99
+ :h:
100
100
  :fit:
101
101
  - height-fit
102
102
  :full:
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 50
8
+ PATCH = 51
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
@@ -3,6 +3,7 @@
3
3
  require "rubocop"
4
4
  require "primer/classify/utilities"
5
5
  require "primer/view_components/statuses"
6
+ require_relative "../../../../app/lib/primer/view_helper"
6
7
 
7
8
  module RuboCop
8
9
  module Cop
@@ -20,8 +21,7 @@ module RuboCop
20
21
  STR
21
22
 
22
23
  def on_send(node)
23
- return unless node.method_name == :new
24
- return unless ::Primer::ViewComponents::STATUSES.key?(node.receiver.const_name)
24
+ return unless valid_node?(node)
25
25
  return unless node.arguments?
26
26
 
27
27
  # we are looking for hash arguments and they are always last
@@ -55,6 +55,16 @@ module RuboCop
55
55
 
56
56
  private
57
57
 
58
+ # We only verify SystemArguments if it's a `.new` call on a component or
59
+ # a ViewHleper call.
60
+ def valid_node?(node)
61
+ view_helpers.include?(node.method_name) || (node.method_name == :new && ::Primer::ViewComponents::STATUSES.key?(node.receiver.const_name))
62
+ end
63
+
64
+ def view_helpers
65
+ ::Primer::ViewHelper::HELPERS.keys.map { |key| "primer_#{key}".to_sym }
66
+ end
67
+
58
68
  def arguments_as_string(system_arguments)
59
69
  system_arguments.map do |key, value|
60
70
  val = case value
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.50
4
+ version: 0.0.51
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-08-03 00:00:00.000000000 Z
11
+ date: 2021-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview