primer_view_components 0.0.78 → 0.0.81

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
5
5
  <% elsif @icon.present? %>
6
6
  <%= primer_octicon @icon, size: @icon_size, classes: "blankslate-icon" %>
7
7
  <% elsif @image_src.present? && @image_alt.present? %>
8
- <%= image_tag "#{@image_src}", class: "mb-3", size: "56x56", alt: "#{@image_alt}" %>
8
+ <%= image_tag @image_src.to_s, class: "mb-3", size: "56x56", alt: @image_alt.to_s %>
9
9
  <% end %>
10
10
 
11
11
  <% if @title.present? %>
@@ -24,7 +24,7 @@
24
24
 
25
25
  <% if @link_text.present? && @link_url.present? %>
26
26
  <p>
27
- <%= link_to "#{@link_url}" do %><%= @link_text %><% end %>
27
+ <%= link_to @link_url.to_s do %><%= @link_text %><% end %>
28
28
  </p>
29
29
  <% end %>
30
30
  <% end %>
@@ -65,12 +65,10 @@ module Primer
65
65
  renders_one :tooltip, lambda { |**system_arguments|
66
66
  raise ArgumentError, "Buttons with a tooltip must have a unique `id` set on the `Button`." if @id.blank? && !Rails.env.production?
67
67
 
68
- @system_arguments = system_arguments
69
-
70
- @system_arguments[:for_id] = @id
71
- @system_arguments[:type] ||= :description
68
+ system_arguments[:for_id] = @id
69
+ system_arguments[:type] ||= :description
72
70
 
73
- Primer::Alpha::Tooltip.new(**@system_arguments)
71
+ Primer::Alpha::Tooltip.new(**system_arguments)
74
72
  }
75
73
 
76
74
  # @example Schemes
@@ -24,12 +24,10 @@ module Primer
24
24
  renders_one :tooltip, lambda { |**system_arguments|
25
25
  raise ArgumentError, "Links with a tooltip must have a unique `id` set on the `LinkComponent`." if @id.blank? && !Rails.env.production?
26
26
 
27
- @system_arguments = system_arguments
28
-
29
- @system_arguments[:for_id] = @id
30
- @system_arguments[:type] ||= :description
27
+ system_arguments[:for_id] = @id
28
+ system_arguments[:type] ||= :description
31
29
 
32
- Primer::Alpha::Tooltip.new(**@system_arguments)
30
+ Primer::Alpha::Tooltip.new(**system_arguments)
33
31
  }
34
32
 
35
33
  # @example Default
@@ -8,10 +8,12 @@ module Primer
8
8
  class OcticonComponent < Primer::Component
9
9
  status :beta
10
10
 
11
+ SIZE_XSMALL = :xsmall
11
12
  SIZE_DEFAULT = :small
12
13
  SIZE_MEDIUM = :medium
13
14
 
14
15
  SIZE_MAPPINGS = {
16
+ SIZE_XSMALL => 12,
15
17
  SIZE_DEFAULT => 16,
16
18
  SIZE_MEDIUM => 24
17
19
  }.freeze
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require_relative "helpers/rubocop_helpers"
5
+
6
+ module ERBLint
7
+ module Linters
8
+ # Finds usages of ActionList CSS classes.
9
+ class DisallowActionList < Linter
10
+ include ERBLint::LinterRegistry
11
+ include TagTreeHelpers
12
+
13
+ class ConfigSchema < LinterConfig
14
+ property :ignore_files, accepts: array_of?(String), default: -> { [] }
15
+ end
16
+ self.config_schema = ConfigSchema
17
+
18
+ def run(processed_source)
19
+ return if ignored?(processed_source.filename)
20
+
21
+ class_regex = /ActionList[\w-]*/
22
+ tags, * = build_tag_tree(processed_source)
23
+
24
+ tags.each do |tag|
25
+ next if tag.closing?
26
+
27
+ classes =
28
+ if (class_attrib = tag.attributes["class"])
29
+ loc = class_attrib.value_node.loc
30
+ loc.source_buffer.source[loc.begin_pos...loc.end_pos]
31
+ else
32
+ ""
33
+ end
34
+
35
+ indices = [].tap do |results|
36
+ classes.scan(class_regex) do
37
+ results << Regexp.last_match.offset(0)
38
+ end
39
+ end
40
+
41
+ next if indices.empty?
42
+
43
+ indices.each do |(start_idx, end_idx)|
44
+ new_loc = class_attrib.value_node.loc.with(
45
+ begin_pos: class_attrib.value_node.loc.begin_pos + start_idx,
46
+ end_pos: class_attrib.value_node.loc.begin_pos + end_idx
47
+ )
48
+
49
+ add_offense(
50
+ new_loc,
51
+ "ActionList classes are only designed to be used by Primer View Components and " \
52
+ "should be considered private. Please reach out in the #primer-rails Slack channel."
53
+ )
54
+ end
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def ignored?(filename)
61
+ filename = Pathname(filename)
62
+
63
+ begin
64
+ filename = filename.relative_path_from(Pathname(Dir.getwd))
65
+ rescue ArgumentError
66
+ # raised if the filename does not have Dir.getwd as a prefix
67
+ end
68
+
69
+ @config.ignore_files.any? { |pattern| filename.fnmatch?(pattern) }
70
+ end
71
+ end
72
+ end
73
+ end
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 78
8
+ PATCH = 81
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
@@ -1,9 +1,33 @@
1
1
  require:
2
2
  - rubocop/cop/primer
3
+ - rubocop-rails
3
4
 
4
- AllCops:
5
- DisabledByDefault: true
5
+ ####### RUBOCOP'S DEFAULTS #######
6
+ # we don't want these in .erb files
7
+ Style/FrozenStringLiteralComment:
8
+ Enabled: false
9
+
10
+ # lots of false-positives in .erb files
11
+ Layout/InitialIndentation:
12
+ Enabled: false
13
+
14
+ Style/StringLiterals:
15
+ EnforcedStyle: double_quotes
16
+
17
+ # lots of false-positives - this cop is meant for Ruby code, not .erb
18
+ Layout/TrailingEmptyLines:
19
+ Enabled: false
20
+
21
+ # it's often not desirable to add unnecessary newlines into .erb files, as
22
+ # they will appear in the rendered HTML
23
+ Layout/LineLength:
24
+ Enabled: false
25
+
26
+ # calling .html_safe in templates is ok
27
+ Rails/OutputSafety:
28
+ Enabled: false
6
29
 
30
+ ####### PRIMER COPS #######
7
31
  Primer/SystemArgumentInsteadOfClass:
8
32
  Enabled: true
9
33
 
@@ -33,22 +33,6 @@ module RuboCop
33
33
  # }
34
34
  #
35
35
  DEPRECATED = {
36
- is_label_inline: {
37
- true => nil,
38
- false => nil
39
- },
40
- with_icon: {
41
- true => nil,
42
- false => nil
43
- },
44
- is_label_visible: {
45
- false => "visually_hide_label: true",
46
- true => "visually_hide_label: false"
47
- },
48
- is_clearable: {
49
- false => "show_clear_button: false",
50
- true => "show_clear_button: true"
51
- },
52
36
  bg: {
53
37
  white: "bg: :primary",
54
38
  gray_light: "bg: :secondary",
data/static/arguments.yml CHANGED
@@ -885,7 +885,7 @@
885
885
  - name: size
886
886
  type: Symbol
887
887
  default: "`:small`"
888
- description: One of `:small` (`16`) and `:medium` (`24`).
888
+ description: One of `:xsmall` (`12`), `:small` (`16`), or `:medium` (`24`).
889
889
  - name: use_symbol
890
890
  type: Boolean
891
891
  default: "`false`"
@@ -644,14 +644,17 @@
644
644
  "Primer::OcticonComponent": {
645
645
  "SIZE_DEFAULT": "small",
646
646
  "SIZE_MAPPINGS": {
647
+ "xsmall": 12,
647
648
  "small": 16,
648
649
  "medium": 24
649
650
  },
650
651
  "SIZE_MEDIUM": "medium",
651
652
  "SIZE_OPTIONS": [
653
+ "xsmall",
652
654
  "small",
653
655
  "medium"
654
- ]
656
+ ],
657
+ "SIZE_XSMALL": "xsmall"
655
658
  },
656
659
  "Primer::OcticonSymbolsComponent": {
657
660
  },
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.78
4
+ version: 0.0.81
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: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -536,6 +536,7 @@ files:
536
536
  - lib/primer/view_components/linters/button_component_migration_counter.rb
537
537
  - lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb
538
538
  - lib/primer/view_components/linters/close_button_component_migration_counter.rb
539
+ - lib/primer/view_components/linters/disallow_action_list.rb
539
540
  - lib/primer/view_components/linters/flash_migration_counter.rb
540
541
  - lib/primer/view_components/linters/helpers/rubocop_helpers.rb
541
542
  - lib/primer/view_components/linters/label_component_migration_counter.rb
@@ -594,7 +595,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
594
595
  - !ruby/object:Gem::Version
595
596
  version: '0'
596
597
  requirements: []
597
- rubygems_version: 3.2.32
598
+ rubygems_version: 3.2.22
598
599
  signing_key:
599
600
  specification_version: 4
600
601
  summary: ViewComponents for the Primer Design System