primer_view_components 0.0.45 → 0.0.46

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -0
  3. data/app/components/primer/auto_complete.rb +2 -1
  4. data/app/components/primer/{auto_complete_component.d.ts → auto_complete/auto_component.d.ts} +0 -0
  5. data/app/components/primer/{auto_complete_component.js → auto_complete/auto_component.js} +0 -0
  6. data/app/components/primer/avatar_stack_component.rb +7 -1
  7. data/app/components/primer/base_component.rb +36 -7
  8. data/app/components/primer/border_box_component.rb +3 -0
  9. data/app/components/primer/component.rb +4 -0
  10. data/app/components/primer/details_component.rb +6 -2
  11. data/app/components/primer/image_crop.rb +1 -1
  12. data/app/components/primer/menu_component.rb +7 -3
  13. data/app/components/primer/navigation/tab_component.rb +4 -4
  14. data/app/components/primer/popover_component.rb +2 -2
  15. data/app/components/primer/tab_nav_component.rb +5 -3
  16. data/app/components/primer/tooltip.rb +1 -1
  17. data/app/components/primer/underline_nav_component.rb +10 -4
  18. data/{app/lib → lib}/primer/classify.rb +11 -28
  19. data/{app/lib → lib}/primer/classify/cache.rb +6 -20
  20. data/{app/lib → lib}/primer/classify/flex.rb +0 -0
  21. data/{app/lib → lib}/primer/classify/functional_background_colors.rb +2 -0
  22. data/{app/lib → lib}/primer/classify/functional_border_colors.rb +2 -0
  23. data/{app/lib → lib}/primer/classify/functional_colors.rb +0 -0
  24. data/{app/lib → lib}/primer/classify/functional_text_colors.rb +2 -0
  25. data/{app/lib → lib}/primer/classify/grid.rb +0 -0
  26. data/{app/lib → lib}/primer/classify/utilities.rb +0 -0
  27. data/{app/lib → lib}/primer/classify/utilities.yml +124 -0
  28. data/lib/primer/view_components.rb +1 -0
  29. data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +1 -2
  30. data/lib/primer/view_components/version.rb +1 -1
  31. data/lib/tasks/docs.rake +2 -2
  32. data/lib/tasks/utilities.rake +8 -2
  33. metadata +18 -20
  34. data/app/components/primer/details_menu_component.d.ts +0 -1
  35. data/app/components/primer/details_menu_component.js +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8953ba874b51d234f8b42590fb30c2cc073c54ffd3b7a56dad24b9e6aa4d2f26
4
- data.tar.gz: a0ac7e3a02d41fde2096547c8c68a91f99c003dee28bcb18a5e0862f46c1058f
3
+ metadata.gz: 19a15f3c293e45a99165f8fe3ceb6967626cabfa15e726cdbcb614223c6e39c5
4
+ data.tar.gz: 6554eeda36440b40d83ee5b5cd395fd6af3cfc9e35c0ac971e14be31dae5d5bf
5
5
  SHA512:
6
- metadata.gz: 89aa1e3a6f977a4bf25675092205034efc9797d275ea9d8e01b7bc50423506f67b2d05ca03a74b69dd3b16b669c6fa68d12b96895647218ca758034ed00d29ab
7
- data.tar.gz: 46eead3cd6ae2b57008f2f7699e572029e736c5000dfd480c0cd5f399de7ac6160f746ccfab2d79305216f7e0602fc280b356051cd120e796f88988dde0fe303
6
+ metadata.gz: d480348ff38e2a89907c58c352632bf3462f1bb8a2cd365e70a04318e9843bf7bf5ba9f4d945d4a51601b5d6786afb2db323d7dd237101ad200f62a297e0d299
7
+ data.tar.gz: dc0876004af2d8e32cb06b8b703ea0290f764c4d53333b3d0c9053bd73e2f8d87facb12f76776c54d03ca4a7a73fd2e41e1b41db0600a32a4039f442db0840f1
data/CHANGELOG.md CHANGED
@@ -1,7 +1,95 @@
1
1
  # CHANGELOG
2
2
 
3
+ <!--
4
+ Authoring changelog entries
5
+
6
+ This file holds all the changes made in previous versions of Primer View Components and the ones coming to the next version.
7
+ To add yours, you need to find in which category to write it under the `main` section. `Main` is the first section on top of the document.
8
+ There are six categories currently in use, `New`, `Updates`, `Bug fixes`, `Breaking changes`, `Deprecations` and `Misc`.
9
+
10
+ - New
11
+ Category for new components, system behaviours, options and arguments changes
12
+
13
+ - Updates
14
+ Every non-breaking change to the source code go there.
15
+
16
+ - Bug Fixes
17
+ Non-breaking bug fixes to existing code.
18
+
19
+ - Breaking Changes
20
+ The category for changes creating incompatibilities to code written with previous versions.
21
+ It includes any changes to components name, signature and behaviour. Also, include removing tags options or changing file location.
22
+ If you are not sure you made breaking changes, ask us in your pull request.
23
+
24
+ - Deprecations
25
+ For changes that explicitly deprecate part of the code base.
26
+
27
+ - Misc
28
+ The category for changes related to documentation, testing and tooling. Also, for pull requests that can't fit in other sections.
29
+ -->
30
+
3
31
  ## main
4
32
 
33
+ ## 0.0.46
34
+
35
+ ### Updates
36
+
37
+ * Default to matching `name` and `id` of `input`.
38
+
39
+ *Kate Higa*
40
+
41
+ * Restrict usage of padding system arguments on BorderBox, recommending use of `padding` density instead.
42
+
43
+ *Joel Hawksley*
44
+
45
+ ### Breaking changes
46
+
47
+ * Restrict `TabNav`and `Tab` tags.
48
+
49
+ *Kate Higa*
50
+
51
+ * Restrict `AvatarStack` body slot tag and `ImageCrop` spinner tag.
52
+
53
+ *Kate Higa*
54
+
55
+ * Restrict `Details` body slot tags and `UnderlineNav` body slot tags.
56
+
57
+ *Kate Higa*
58
+
59
+ * Move Primer::Classify from `app/lib/` to `lib/`. This requires an extra `require "primer/classify"` statement for anywhere Classify is needed.
60
+
61
+ *Manuel Puyol, Jon Rohan*
62
+
63
+ * Restrict `Menu` heading slot tags to heading tags and require `tag` argument.
64
+
65
+ *Kate Higa*
66
+
67
+ * Adding animation, vertical_align, word_break, display, visibility, & position arguments to the utilities class. `animation: :grow` is now `animation: :hover_grow` this was a change because we changed the class name in primer.
68
+
69
+ *Jon Rohan*
70
+
71
+ ### Misc
72
+
73
+ * Update contributing guidelines with release instructions.
74
+
75
+ *Kate Higa*
76
+
77
+ * Prevent flexible tag syntax with rubocop rule.
78
+
79
+ *Kate Higa*
80
+
81
+ * Update linter autocorrection to use `""` instead of `true` for boolean attributes.
82
+
83
+ *Manuel Puyol*
84
+
85
+ * Update Storybook version.
86
+
87
+ *Manuel Puyol*
88
+
89
+ * Added a changelog authoring guide to `CHANGELOG.md`.
90
+
91
+ *Amélia Chavot*
92
+
5
93
  ## 0.0.45
6
94
 
7
95
  ### Updates
@@ -34,7 +34,8 @@ module Primer
34
34
  system_arguments[:aria]&.delete(:label)
35
35
  end
36
36
 
37
- Input.new(id: @input_id, **system_arguments)
37
+ name = system_arguments[:name] || @input_id
38
+ Input.new(id: @input_id, name: name, **system_arguments)
38
39
  }
39
40
 
40
41
  # Optional icon to be rendered before the input. Has the same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
@@ -10,6 +10,9 @@ module Primer
10
10
 
11
11
  DEFAULT_TAG = :div
12
12
  TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
13
+
14
+ DEFAULT_BODY_TAG = :div
15
+ BODY_TAG_OPTIONS = TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
13
16
  # Required list of stacked avatars.
14
17
  #
15
18
  # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::AvatarComponent) %>.
@@ -40,6 +43,8 @@ module Primer
40
43
  # @param align [Symbol] <%= one_of(Primer::AvatarStackComponent::ALIGN_OPTIONS) %>
41
44
  # @param tooltipped [Boolean] Whether to add a tooltip to the stack or not.
42
45
  # @param body_arguments [Hash] Parameters to add to the Body. If `tooltipped` is set, has the same arguments as <%= link_to_component(Primer::Tooltip) %>.
46
+ # The default tag is <%= pretty_value(Primer::AvatarStackComponent::DEFAULT_BODY_TAG) %> but can be changed using `tag:`
47
+ # to <%= one_of(Primer::AvatarStackComponent::BODY_TAG_OPTIONS, lower: true) %>
43
48
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
44
49
  def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, tooltipped: false, body_arguments: {}, **system_arguments)
45
50
  @align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
@@ -47,7 +52,8 @@ module Primer
47
52
  @tooltipped = tooltipped
48
53
  @body_arguments = body_arguments
49
54
 
50
- @body_arguments[:tag] ||= :div
55
+ body_tag = @body_arguments[:tag] || DEFAULT_BODY_TAG
56
+ @body_arguments[:tag] = fetch_or_fallback(BODY_TAG_OPTIONS, body_tag, DEFAULT_BODY_TAG)
51
57
  @body_arguments[:classes] = class_names(
52
58
  "AvatarStack-body",
53
59
  @body_arguments[:classes]
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "primer/classify"
4
+
3
5
  module Primer
4
6
  # All Primer ViewComponents accept a standard set of options called system arguments, mimicking the [styled-system API](https://styled-system.com/table) used by [Primer React](https://primer.style/components/system-props).
5
7
  #
@@ -43,7 +45,7 @@ module Primer
43
45
  #
44
46
  # | Name | Type | Description |
45
47
  # | :- | :- | :- |
46
- # | `animation` | Symbol | <%= one_of([:fade_in, :fade_out, :fade_up, :fade_down, :scale_in, :pulse, :grow_x, :grow]) %> |
48
+ # | `animation` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:animation)) %> |
47
49
  #
48
50
  # ## Border
49
51
  #
@@ -61,7 +63,7 @@ module Primer
61
63
  #
62
64
  # | Name | Type | Description |
63
65
  # | :- | :- | :- |
64
- # | `bg` | String, Symbol | Background color. Accepts either a hex value as a String or <%= one_of(Primer::Classify::FunctionalBorderColors::OPTIONS, lower: true) %> |
66
+ # | `bg` | String, Symbol | Background color. Accepts either a hex value as a String or <%= one_of(Primer::Classify::FunctionalBackgroundColors::OPTIONS, lower: true) %> |
65
67
  # | `border_color` | Symbol | Border color. <%= one_of(Primer::Classify::FunctionalBorderColors::OPTIONS) %> |
66
68
  # | `color` | Symbol | Text color. <%= one_of(Primer::Classify::FunctionalTextColors::OPTIONS) %> |
67
69
  #
@@ -91,11 +93,11 @@ module Primer
91
93
  #
92
94
  # | Name | Type | Description |
93
95
  # | :- | :- | :- |
94
- # | `display` | Symbol | <%= one_of([:none, :block, :flex, :inline, :inline_block, :inline_flex, :table, :table_cell]) %> |
96
+ # | `display` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:display)) %> |
95
97
  # | `height` | Symbol | <%= one_of([:fit]) %> |
96
98
  # | `hide` | Symbol | Hide the element at a specific breakpoint. <%= one_of(Primer::Classify::Utilities.mappings(:hide)) %> |
97
- # | `v` | Symbol | Visibility. <%= one_of([:hidden, :visible]) %> |
98
- # | `vertical_align` | Symbol | <%= one_of([:baseline, :top, :middle, :bottom, :text_top, :text_bottom]) %> |
99
+ # | `visibility` | Symbol | Visibility. <%= one_of(Primer::Classify::Utilities.mappings(:visibility)) %> |
100
+ # | `vertical_align` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:vertical_align)) %> |
99
101
  #
100
102
  # ## Position
101
103
  #
@@ -104,7 +106,7 @@ module Primer
104
106
  # | `bottom` | Boolean | If `false`, sets `bottom: 0`. |
105
107
  # | `float` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:float)) %> |
106
108
  # | `left` | Boolean | If `false`, sets `left: 0`. |
107
- # | `position` | Symbol | <%= one_of([:relative, :absolute, :fixed]) %> |
109
+ # | `position` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:position)) %> |
108
110
  # | `right` | Boolean | If `false`, sets `right: 0`. |
109
111
  # | `top` | Boolean | If `false`, sets `top: 0`. |
110
112
  #
@@ -138,7 +140,7 @@ module Primer
138
140
  # | `text_align` | Symbol | Text alignment. <%= one_of([:left, :right, :center]) %> |
139
141
  # | `text_transform` | Symbol | Text alignment. <%= one_of([:uppercase]) %> |
140
142
  # | `underline` | Boolean | Whether text should be underlined. |
141
- # | `word_break` | Symbol | Whether to break words on line breaks. Can only be `:break_all`. |
143
+ # | `word_break` | Symbol | Whether to break words on line breaks. <%= one_of(Primer::Classify::Utilities.mappings(:word_break)) %> |
142
144
  #
143
145
  # ## Other
144
146
  #
@@ -152,6 +154,33 @@ module Primer
152
154
 
153
155
  raise ArgumentError, "`class` is an invalid argument. Use `classes` instead." if system_arguments.key?(:class) && !Rails.env.production?
154
156
 
157
+ if (denylist = system_arguments[:system_arguments_denylist])
158
+ if force_system_arguments? && !ENV["PRIMER_WARNINGS_DISABLED"]
159
+ # Convert denylist from:
160
+ # { [:p, :pt] => "message" } to:
161
+ # { p: "message", pt: "message" }
162
+ unpacked_denylist =
163
+ denylist.each_with_object({}) do |(keys, value), memo|
164
+ keys.each { |key| memo[key] = value }
165
+ end
166
+
167
+ violations = unpacked_denylist.keys & @system_arguments.keys
168
+
169
+ if violations.any?
170
+ message = "Found #{violations.count} #{'violation'.pluralize(violations)}:"
171
+ violations.each do |violation|
172
+ message += "\n The #{violation} system argument is not allowed here. #{unpacked_denylist[violation]}"
173
+ end
174
+
175
+ raise(ArgumentError, message)
176
+ end
177
+ end
178
+
179
+ # Remove :system_arguments_denylist key and any denied keys from system arguments
180
+ @system_arguments.except!(:system_arguments_denylist)
181
+ @system_arguments.except!(*denylist.keys.flatten)
182
+ end
183
+
155
184
  @result = Primer::Classify.call(**@system_arguments.merge(classes: classes))
156
185
 
157
186
  @system_arguments[:"data-view-component"] = true
@@ -11,6 +11,7 @@ module Primer
11
11
  :condensed => "Box--condensed",
12
12
  :spacious => "Box--spacious"
13
13
  }.freeze
14
+ PADDING_SUGGESTION = "Perhaps you could consider using :padding options of #{PADDING_MAPPINGS.keys.to_sentence}?"
14
15
 
15
16
  # Optional Header.
16
17
  #
@@ -111,6 +112,8 @@ module Primer
111
112
  PADDING_MAPPINGS[fetch_or_fallback(PADDING_MAPPINGS.keys, padding, DEFAULT_PADDING)],
112
113
  system_arguments[:classes]
113
114
  )
115
+
116
+ @system_arguments[:system_arguments_denylist] = { [:p, :pt, :pb, :pr, :pl] => PADDING_SUGGESTION }
114
117
  end
115
118
 
116
119
  def render?
@@ -15,6 +15,10 @@ module Primer
15
15
 
16
16
  private
17
17
 
18
+ def force_system_arguments?
19
+ Rails.application.config.primer_view_components.force_system_arguments
20
+ end
21
+
18
22
  def deprecated_component_warning(new_class: nil, version: nil)
19
23
  return if Rails.env.production? || silence_deprecations?
20
24
 
@@ -5,6 +5,8 @@ module Primer
5
5
  class DetailsComponent < Primer::Component
6
6
  status :beta
7
7
 
8
+ BODY_TAG_DEFAULT = :div
9
+ BODY_TAG_OPTIONS = [:ul, :"details-menu", :"details-dialog", BODY_TAG_DEFAULT].freeze
8
10
  NO_OVERLAY = :none
9
11
  OVERLAY_MAPPINGS = {
10
12
  NO_OVERLAY => "",
@@ -27,9 +29,11 @@ module Primer
27
29
 
28
30
  # Use the Body slot as the main content to be shown when triggered by the Summary.
29
31
  #
32
+ # @param tag [String] (Primer::DetailsComponent::BODY_TAG_DEFAULT) <%= one_of(Primer::DetailsComponent::BODY_TAG_OPTIONS) %>
30
33
  # @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>.
31
- renders_one :body, lambda { |**system_arguments|
32
- system_arguments[:tag] ||= :div
34
+ renders_one :body, lambda { |tag: BODY_TAG_DEFAULT, **system_arguments|
35
+ system_arguments[:tag] = fetch_or_fallback(BODY_TAG_OPTIONS, tag, BODY_TAG_DEFAULT)
36
+
33
37
  Primer::BaseComponent.new(**system_arguments)
34
38
  }
35
39
 
@@ -6,7 +6,7 @@ module Primer
6
6
  # A loading indicator that is shown while the image is loading.
7
7
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
8
8
  renders_one :loading, lambda { |**system_arguments|
9
- system_arguments[:tag] ||= :div
9
+ system_arguments[:tag] = :div
10
10
  system_arguments[:"data-loading-slot"] = true
11
11
 
12
12
  Primer::BaseComponent.new(**system_arguments)
@@ -3,11 +3,15 @@
3
3
  module Primer
4
4
  # Use `Menu` to create vertical lists of navigational links.
5
5
  class MenuComponent < Primer::Component
6
+ HEADING_TAG_OPTIONS = [:h1, :h2, :h3, :h4, :h5, :h6].freeze
7
+ HEADING_TAG_FALLBACK = :h2
8
+
6
9
  # Optional menu heading
7
10
  #
11
+ # @param tag [Symbol] <%= one_of(Primer::MenuComponent::HEADING_TAG_OPTIONS) %>
8
12
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
9
- renders_one :heading, lambda { |**system_arguments|
10
- system_arguments[:tag] ||= :span
13
+ renders_one :heading, lambda { |tag:, **system_arguments|
14
+ system_arguments[:tag] = fetch_or_fallback(HEADING_TAG_OPTIONS, tag, HEADING_TAG_FALLBACK)
11
15
  system_arguments[:classes] = class_names(
12
16
  "menu-heading",
13
17
  system_arguments[:classes]
@@ -35,7 +39,7 @@ module Primer
35
39
 
36
40
  # @example Default
37
41
  # <%= render(Primer::MenuComponent.new) do |c| %>
38
- # <% c.heading do %>
42
+ # <% c.heading(tag: :h2) do %>
39
43
  # Heading
40
44
  # <% end %>
41
45
  # <% c.item(selected: true, href: "#url") do %>
@@ -18,7 +18,7 @@ module Primer
18
18
  #
19
19
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
20
20
  renders_one :panel, lambda { |**system_arguments|
21
- system_arguments[:tag] ||= :div
21
+ system_arguments[:tag] = :div
22
22
  system_arguments[:role] ||= :tabpanel
23
23
  system_arguments[:hidden] = true unless @selected
24
24
 
@@ -96,12 +96,12 @@ module Primer
96
96
 
97
97
  @system_arguments = system_arguments
98
98
 
99
- if with_panel
100
- @system_arguments[:tag] ||= :button
99
+ if with_panel || @system_arguments[:tag] == :button
100
+ @system_arguments[:tag] = :button
101
101
  @system_arguments[:type] = :button
102
102
  @system_arguments[:role] = :tab
103
103
  else
104
- @system_arguments[:tag] ||= :a
104
+ @system_arguments[:tag] = :a
105
105
  end
106
106
 
107
107
  @wrapper_arguments = wrapper_arguments
@@ -28,7 +28,7 @@ module Primer
28
28
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
29
29
  renders_one :heading, lambda { |**system_arguments|
30
30
  system_arguments[:mb] ||= 2
31
- system_arguments[:tag] ||= :h4
31
+ system_arguments[:tag] ||= :h4 # rubocop:disable Primer/NoTagMemoize
32
32
 
33
33
  Primer::HeadingComponent.new(**system_arguments)
34
34
  }
@@ -106,7 +106,7 @@ module Primer
106
106
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
107
107
  def initialize(**system_arguments)
108
108
  @system_arguments = system_arguments
109
- @system_arguments[:tag] ||= :div
109
+ @system_arguments[:tag] ||= :div # rubocop:disable Primer/NoTagMemoize
110
110
  @system_arguments[:classes] = class_names(
111
111
  system_arguments[:classes],
112
112
  "Popover"
@@ -10,7 +10,8 @@ module Primer
10
10
  DEFAULT_EXTRA_ALIGN = :left
11
11
  EXTRA_ALIGN_OPTIONS = [DEFAULT_EXTRA_ALIGN, :right].freeze
12
12
 
13
- # Tabs to be rendered. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
13
+ # Tabs to be rendered. When `with_panel` is set on the parent, a button is rendered for panel navigation. Otherwise,
14
+ # an anchor tag is rendered for page navigation. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
14
15
  #
15
16
  # @param selected [Boolean] Whether the tab is selected.
16
17
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -119,7 +120,8 @@ module Primer
119
120
  # <% end %>
120
121
  #
121
122
  # @param label [String] Used to set the `aria-label` on the top level `<nav>` element.
122
- # @param with_panel [Boolean] Whether the TabNav should navigate through pages or panels.
123
+ # @param with_panel [Boolean] Whether the TabNav should navigate through pages or panels. When true, <%= link_to_component(Primer::TabContainerComponent) %>
124
+ # is rendered along with JavaScript behavior. Additionally, the `tab` slot will render as a button as opposed to an anchor.
123
125
  # @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
124
126
  # @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper. Only applies if `with_panel` is `true`.
125
127
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -130,7 +132,7 @@ module Primer
130
132
  @body_arguments = body_arguments
131
133
  @wrapper_arguments = wrapper_arguments
132
134
 
133
- @system_arguments[:tag] ||= :div
135
+ @system_arguments[:tag] = :div
134
136
  @system_arguments[:classes] = class_names(
135
137
  "tabnav",
136
138
  system_arguments[:classes]
@@ -70,7 +70,7 @@ module Primer
70
70
  **system_arguments
71
71
  )
72
72
  @system_arguments = system_arguments
73
- @system_arguments[:tag] ||= :span
73
+ @system_arguments[:tag] ||= :span # rubocop:disable Primer/NoTagMemoize
74
74
  @system_arguments[:aria] = { label: label }
75
75
 
76
76
  @system_arguments[:classes] = class_names(
@@ -13,7 +13,11 @@ module Primer
13
13
  BODY_TAG_DEFAULT = :div
14
14
  BODY_TAG_OPTIONS = [BODY_TAG_DEFAULT, :ul].freeze
15
15
 
16
- # Use the tabs to list navigation items. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
16
+ ACTIONS_TAG_DEFAULT = :div
17
+ ACTIONS_TAG_OPTIONS = [ACTIONS_TAG_DEFAULT, :span].freeze
18
+
19
+ # Use the tabs to list navigation items. When `with_panel` is set on the parent, a button is rendered for panel navigation. Otherwise,
20
+ # an anchor tag is rendered for page navigation. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
17
21
  #
18
22
  # @param selected [Boolean] Whether the tab is selected.
19
23
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -34,9 +38,10 @@ module Primer
34
38
 
35
39
  # Use actions for a call to action.
36
40
  #
41
+ # @param tag [String] (Primer::UnderlineNavComponent::ACTIONS_TAG_DEFAULT) <%= one_of(Primer::UnderlineNavComponent::ACTIONS_TAG_OPTIONS) %>
37
42
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
38
- renders_one :actions, lambda { |**system_arguments|
39
- system_arguments[:tag] ||= :div
43
+ renders_one :actions, lambda { |tag: ACTIONS_TAG_DEFAULT, **system_arguments|
44
+ system_arguments[:tag] = fetch_or_fallback(ACTIONS_TAG_OPTIONS, tag, ACTIONS_TAG_DEFAULT)
40
45
  system_arguments[:classes] = class_names("UnderlineNav-actions", system_arguments[:classes])
41
46
 
42
47
  Primer::BaseComponent.new(**system_arguments)
@@ -131,7 +136,8 @@ module Primer
131
136
  # <% end %>
132
137
  #
133
138
  # @param label [String] The `aria-label` on top level `<nav>` element.
134
- # @param with_panel [Boolean] Whether the TabNav should navigate through pages or panels.
139
+ # @param with_panel [Boolean] Whether the `UnderlineNav` should navigate through pages or panels. When true, <%= link_to_component(Primer::TabContainerComponent) %> is
140
+ # rendered along with JavaScript behavior.
135
141
  # @param align [Symbol] <%= one_of(Primer::UnderlineNavComponent::ALIGN_OPTIONS) %> - Defaults to <%= Primer::UnderlineNavComponent::ALIGN_DEFAULT %>
136
142
  # @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
137
143
  # @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper. Only applies if `with_panel` is `true`.
@@ -1,5 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "classify/cache"
4
+ require_relative "classify/flex"
5
+ require_relative "classify/functional_background_colors"
6
+ require_relative "classify/functional_border_colors"
7
+ require_relative "classify/functional_text_colors"
8
+ require_relative "classify/grid"
9
+ require_relative "classify/utilities"
10
+
3
11
  module Primer
4
12
  # :nodoc:
5
13
  class Classify
@@ -13,28 +21,22 @@ module Primer
13
21
  ).freeze
14
22
  # rubocop:enable Security/YAMLLoad
15
23
 
16
- DISPLAY_KEY = :display
17
-
18
24
  # Keys where we can simply translate { key: value } into ".key-value"
19
- CONCAT_KEYS = %i[position v text box_shadow].freeze
25
+ CONCAT_KEYS = %i[text box_shadow].freeze
20
26
 
21
27
  INVALID_CLASS_NAME_PREFIXES =
22
- (["bg-", "color-", "text-", "d-", "v-align-", "wb-", "box-shadow-"] + CONCAT_KEYS.map { |k| "#{k}-" }).freeze
28
+ (["bg-", "color-", "text-", "box-shadow-"] + CONCAT_KEYS.map { |k| "#{k}-" }).freeze
23
29
 
24
30
  COLOR_KEY = :color
25
31
  BG_KEY = :bg
26
- VERTICAL_ALIGN_KEY = :vertical_align
27
- WORD_BREAK_KEY = :word_break
28
32
  TEXT_KEYS = %i[font_family font_style font_weight text_align text_transform].freeze
29
33
  WIDTH_KEY = :width
30
34
  HEIGHT_KEY = :height
31
35
  BOX_SHADOW_KEY = :box_shadow
32
- VISIBILITY_KEY = :visibility
33
- ANIMATION_KEY = :animation
34
36
  CONTAINER_KEY = :container
35
37
 
36
38
  BREAKPOINTS = ["", "-sm", "-md", "-lg", "-xl"].freeze
37
- RESPONSIVE_KEYS = ([DISPLAY_KEY, Primer::Classify::Grid::COL_KEY] + Primer::Classify::Flex::RESPONSIVE_KEYS).freeze
39
+ RESPONSIVE_KEYS = ([Primer::Classify::Grid::COL_KEY] + Primer::Classify::Flex::RESPONSIVE_KEYS).freeze
38
40
 
39
41
  BOOLEAN_MAPPINGS = {
40
42
  underline: {
@@ -102,14 +104,9 @@ module Primer
102
104
  BORDER_RADIUS_KEY,
103
105
  COLOR_KEY,
104
106
  BG_KEY,
105
- DISPLAY_KEY,
106
- VERTICAL_ALIGN_KEY,
107
- WORD_BREAK_KEY,
108
107
  WIDTH_KEY,
109
108
  HEIGHT_KEY,
110
109
  BOX_SHADOW_KEY,
111
- VISIBILITY_KEY,
112
- ANIMATION_KEY,
113
110
  CONTAINER_KEY
114
111
  ]
115
112
  ).freeze
@@ -197,12 +194,6 @@ module Primer
197
194
  end
198
195
  elsif key == COLOR_KEY
199
196
  memo[:classes] << Primer::Classify::FunctionalTextColors.color(val)
200
- elsif key == DISPLAY_KEY
201
- memo[:classes] << "d#{breakpoint}-#{val.to_s.dasherize}"
202
- elsif key == VERTICAL_ALIGN_KEY
203
- memo[:classes] << "v-align-#{val.to_s.dasherize}"
204
- elsif key == WORD_BREAK_KEY
205
- memo[:classes] << "wb-#{val.to_s.dasherize}"
206
197
  elsif key == BORDER_KEY
207
198
  border_value = if val == true
208
199
  "border"
@@ -243,14 +234,6 @@ module Primer
243
234
  else
244
235
  "color-shadow-#{val.to_s.dasherize}"
245
236
  end
246
- elsif key == VISIBILITY_KEY
247
- memo[:classes] << "v-#{val.to_s.dasherize}"
248
- elsif key == ANIMATION_KEY
249
- memo[:classes] << if val == :grow
250
- "hover-grow"
251
- else
252
- "anim-#{val.to_s.dasherize}"
253
- end
254
237
  else
255
238
  memo[:classes] << "#{key.to_s.dasherize}#{breakpoint}-#{val.to_s.dasherize}"
256
239
  end
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "flex"
4
+ require_relative "functional_background_colors"
5
+ require_relative "functional_border_colors"
6
+ require_relative "functional_text_colors"
7
+ require_relative "grid"
8
+
3
9
  module Primer
4
10
  class Classify
5
11
  # :nodoc:
@@ -49,11 +55,6 @@ module Primer
49
55
  values: Primer::Classify::Grid::COL_VALUES
50
56
  )
51
57
 
52
- preload(
53
- keys: Primer::Classify::DISPLAY_KEY,
54
- values: [:flex, :block, :inline_block, :inline_flex, :none, :table, :table_cell]
55
- )
56
-
57
58
  preload(
58
59
  keys: [Primer::Classify::COLOR_KEY],
59
60
  values: Primer::Classify::FunctionalTextColors::OPTIONS
@@ -64,16 +65,6 @@ module Primer
64
65
  values: Primer::Classify::FunctionalBackgroundColors::OPTIONS
65
66
  )
66
67
 
67
- preload(
68
- keys: Primer::Classify::VERTICAL_ALIGN_KEY,
69
- values: [:baseline, :top, :middle, :bottom, :text_top, :text_bottom]
70
- )
71
-
72
- preload(
73
- keys: Primer::Classify::WORD_BREAK_KEY,
74
- values: [:break_all]
75
- )
76
-
77
68
  preload(
78
69
  keys: :text_align,
79
70
  values: [:left, :center, :right]
@@ -113,11 +104,6 @@ module Primer
113
104
  keys: Primer::Classify::BOX_SHADOW_KEY,
114
105
  values: [true, :small, :medium, :large, :extra_large, :none]
115
106
  )
116
-
117
- preload(
118
- keys: Primer::Classify::VISIBILITY_KEY,
119
- values: [:hidden, :visible]
120
- )
121
107
  end
122
108
 
123
109
  def preload(keys:, values:)
File without changes
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "functional_colors"
4
+
3
5
  module Primer
4
6
  class Classify
5
7
  # Background specific functional colors
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "functional_colors"
4
+
3
5
  module Primer
4
6
  class Classify
5
7
  # Border specific functional colors
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "functional_colors"
4
+
3
5
  module Primer
4
6
  class Classify
5
7
  # Text specific functional colors.
File without changes
File without changes
@@ -1,4 +1,71 @@
1
1
  ---
2
+ :animation:
3
+ :fade_in:
4
+ - anim-fade-in
5
+ :fade_out:
6
+ - anim-fade-out
7
+ :fade_up:
8
+ - anim-fade-up
9
+ :fade_down:
10
+ - anim-fade-down
11
+ :grow_x:
12
+ - anim-grow-x
13
+ :shrink_x:
14
+ - anim-shrink-x
15
+ :scale_in:
16
+ - anim-scale-in
17
+ :pulse:
18
+ - anim-pulse
19
+ :pulse_in:
20
+ - anim-pulse-in
21
+ :hover_grow:
22
+ - anim-hover-grow
23
+ :rotate:
24
+ - anim-rotate
25
+ :position:
26
+ :static:
27
+ - position-static
28
+ - position-sm-static
29
+ - position-md-static
30
+ - position-lg-static
31
+ - position-xl-static
32
+ :relative:
33
+ - position-relative
34
+ - position-sm-relative
35
+ - position-md-relative
36
+ - position-lg-relative
37
+ - position-xl-relative
38
+ :absolute:
39
+ - position-absolute
40
+ - position-sm-absolute
41
+ - position-md-absolute
42
+ - position-lg-absolute
43
+ - position-xl-absolute
44
+ :fixed:
45
+ - position-fixed
46
+ - position-sm-fixed
47
+ - position-md-fixed
48
+ - position-lg-fixed
49
+ - position-xl-fixed
50
+ :sticky:
51
+ - position-sticky
52
+ - position-sm-sticky
53
+ - position-md-sticky
54
+ - position-lg-sticky
55
+ - position-xl-sticky
56
+ :vertical_align:
57
+ :middle:
58
+ - v-align-middle
59
+ :top:
60
+ - v-align-top
61
+ :bottom:
62
+ - v-align-bottom
63
+ :text_top:
64
+ - v-align-text-top
65
+ :text_bottom:
66
+ - v-align-text-bottom
67
+ :baseline:
68
+ - v-align-baseline
2
69
  :float:
3
70
  :left:
4
71
  - float-left
@@ -1136,6 +1203,63 @@
1136
1203
  - py-md-12
1137
1204
  - py-lg-12
1138
1205
  - py-xl-12
1206
+ :word_break:
1207
+ :break_all:
1208
+ - wb-break-all
1209
+ :display:
1210
+ :block:
1211
+ - d-block
1212
+ - d-sm-block
1213
+ - d-md-block
1214
+ - d-lg-block
1215
+ - d-xl-block
1216
+ :flex:
1217
+ - d-flex
1218
+ - d-sm-flex
1219
+ - d-md-flex
1220
+ - d-lg-flex
1221
+ - d-xl-flex
1222
+ :inline:
1223
+ - d-inline
1224
+ - d-sm-inline
1225
+ - d-md-inline
1226
+ - d-lg-inline
1227
+ - d-xl-inline
1228
+ :inline_block:
1229
+ - d-inline-block
1230
+ - d-sm-inline-block
1231
+ - d-md-inline-block
1232
+ - d-lg-inline-block
1233
+ - d-xl-inline-block
1234
+ :inline_flex:
1235
+ - d-inline-flex
1236
+ - d-sm-inline-flex
1237
+ - d-md-inline-flex
1238
+ - d-lg-inline-flex
1239
+ - d-xl-inline-flex
1240
+ :none:
1241
+ - d-none
1242
+ - d-sm-none
1243
+ - d-md-none
1244
+ - d-lg-none
1245
+ - d-xl-none
1246
+ :table:
1247
+ - d-table
1248
+ - d-sm-table
1249
+ - d-md-table
1250
+ - d-lg-table
1251
+ - d-xl-table
1252
+ :table_cell:
1253
+ - d-table-cell
1254
+ - d-sm-table-cell
1255
+ - d-md-table-cell
1256
+ - d-lg-table-cell
1257
+ - d-xl-table-cell
1258
+ :visibility:
1259
+ :hidden:
1260
+ - v-hidden
1261
+ :visible:
1262
+ - v-visible
1139
1263
  :hide:
1140
1264
  :sm:
1141
1265
  - hide-sm
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "primer/classify"
3
4
  require "primer/view_components/version"
4
5
  require "primer/view_components/engine"
5
6
 
@@ -32,8 +32,7 @@ module ERBLint
32
32
  elsif attr_name.start_with?(*STRING_PARAMETERS)
33
33
  raise ConversionError, "Cannot convert attribute \"#{attr_name}\" because its value contains an erb block" if attribute.value_node&.children&.any? { |n| n.try(:type) == :erb }
34
34
 
35
- # if attribute has no value_node, it means it is a boolean attribute.
36
- { "\"#{attr_name}\"" => attribute.value_node ? attribute.value.to_json : true }
35
+ { "\"#{attr_name}\"" => attribute.value.to_json }
37
36
  else
38
37
  raise ConversionError, "Cannot convert attribute \"#{attr_name}\""
39
38
  end
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 45
8
+ PATCH = 46
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
data/lib/tasks/docs.rake CHANGED
@@ -176,10 +176,10 @@ namespace :docs do
176
176
  "name" => tag.name,
177
177
  "type" => tag.types.join(", "),
178
178
  "default" => default_value,
179
- "description" => view_context.render(inline: tag.text)
179
+ "description" => view_context.render(inline: tag.text.squish)
180
180
  }
181
181
 
182
- f.puts("| `#{tag.name}` | `#{tag.types.join(', ')}` | #{default_value} | #{view_context.render(inline: tag.text)} |")
182
+ f.puts("| `#{tag.name}` | `#{tag.types.join(', ')}` | #{default_value} | #{view_context.render(inline: tag.text.squish)} |")
183
183
  end
184
184
 
185
185
  component_args = {
@@ -8,14 +8,20 @@ namespace :utilities do
8
8
 
9
9
  # Keys that are looked for to be included in the utilities.yml file
10
10
  SUPPORTED_KEYS = %i[
11
- hide
11
+ anim
12
+ d
12
13
  float
14
+ hide
13
15
  m mt mr mb ml mx my
14
16
  p pt pr pb pl px py
17
+ position
18
+ wb
19
+ v
15
20
  ].freeze
16
21
 
17
22
  # Replacements for some classnames that end up being a different argument key
18
23
  REPLACEMENT_KEYS = {
24
+ "^anim" => "animation",
19
25
  "^v-align" => "vertical_align",
20
26
  "^d" => "display",
21
27
  "^wb" => "word_break",
@@ -92,7 +98,7 @@ namespace :utilities do
92
98
  x.transform_values { |y| y.reverse.drop_while(&:nil?).reverse }
93
99
  end
94
100
 
95
- File.open("app/lib/primer/classify/utilities.yml", "w") do |f|
101
+ File.open("lib/primer/classify/utilities.yml", "w") do |f|
96
102
  f.puts YAML.dump(output)
97
103
  end
98
104
  end
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.45
4
+ version: 0.0.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-16 00:00:00.000000000 Z
11
+ date: 2021-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -338,7 +338,7 @@ dependencies:
338
338
  - - "~>"
339
339
  - !ruby/object:Gem::Version
340
340
  version: 0.9.25
341
- description:
341
+ description:
342
342
  email:
343
343
  - opensource+primer_view_components@github.com
344
344
  executables: []
@@ -356,9 +356,9 @@ files:
356
356
  - app/components/primer/auto_complete/auto_complete.html.erb
357
357
  - app/components/primer/auto_complete/auto_complete.js
358
358
  - app/components/primer/auto_complete/auto_complete.ts
359
+ - app/components/primer/auto_complete/auto_component.d.ts
360
+ - app/components/primer/auto_complete/auto_component.js
359
361
  - app/components/primer/auto_complete/item.rb
360
- - app/components/primer/auto_complete_component.d.ts
361
- - app/components/primer/auto_complete_component.js
362
362
  - app/components/primer/avatar_component.rb
363
363
  - app/components/primer/avatar_stack_component.html.erb
364
364
  - app/components/primer/avatar_stack_component.rb
@@ -386,8 +386,6 @@ files:
386
386
  - app/components/primer/counter_component.rb
387
387
  - app/components/primer/details_component.html.erb
388
388
  - app/components/primer/details_component.rb
389
- - app/components/primer/details_menu_component.d.ts
390
- - app/components/primer/details_menu_component.js
391
389
  - app/components/primer/dropdown.d.ts
392
390
  - app/components/primer/dropdown.html.erb
393
391
  - app/components/primer/dropdown.js
@@ -459,16 +457,6 @@ files:
459
457
  - app/components/primer/underline_nav_component.html.erb
460
458
  - app/components/primer/underline_nav_component.rb
461
459
  - app/lib/primer/class_name_helper.rb
462
- - app/lib/primer/classify.rb
463
- - app/lib/primer/classify/cache.rb
464
- - app/lib/primer/classify/flex.rb
465
- - app/lib/primer/classify/functional_background_colors.rb
466
- - app/lib/primer/classify/functional_border_colors.rb
467
- - app/lib/primer/classify/functional_colors.rb
468
- - app/lib/primer/classify/functional_text_colors.rb
469
- - app/lib/primer/classify/grid.rb
470
- - app/lib/primer/classify/utilities.rb
471
- - app/lib/primer/classify/utilities.yml
472
460
  - app/lib/primer/fetch_or_fallback_helper.rb
473
461
  - app/lib/primer/join_style_arguments_helper.rb
474
462
  - app/lib/primer/octicon/cache.rb
@@ -476,6 +464,16 @@ files:
476
464
  - app/lib/primer/tabbed_component_helper.rb
477
465
  - app/lib/primer/test_selector_helper.rb
478
466
  - app/lib/primer/view_helper.rb
467
+ - lib/primer/classify.rb
468
+ - lib/primer/classify/cache.rb
469
+ - lib/primer/classify/flex.rb
470
+ - lib/primer/classify/functional_background_colors.rb
471
+ - lib/primer/classify/functional_border_colors.rb
472
+ - lib/primer/classify/functional_colors.rb
473
+ - lib/primer/classify/functional_text_colors.rb
474
+ - lib/primer/classify/grid.rb
475
+ - lib/primer/classify/utilities.rb
476
+ - lib/primer/classify/utilities.yml
479
477
  - lib/primer/view_components.rb
480
478
  - lib/primer/view_components/engine.rb
481
479
  - lib/primer/view_components/linters.rb
@@ -499,7 +497,7 @@ licenses:
499
497
  - MIT
500
498
  metadata:
501
499
  allowed_push_host: https://rubygems.org
502
- post_install_message:
500
+ post_install_message:
503
501
  rdoc_options: []
504
502
  require_paths:
505
503
  - lib
@@ -515,7 +513,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
515
513
  version: '0'
516
514
  requirements: []
517
515
  rubygems_version: 3.1.2
518
- signing_key:
516
+ signing_key:
519
517
  specification_version: 4
520
518
  summary: ViewComponents for the Primer Design System
521
519
  test_files: []
@@ -1 +0,0 @@
1
- import '@github/details-menu-element';
@@ -1 +0,0 @@
1
- import '@github/details-menu-element';