primer_view_components 0.0.8 → 0.0.13

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +66 -37
  3. data/README.md +2 -161
  4. data/app/components/primer/avatar_component.rb +22 -11
  5. data/app/components/primer/base_component.rb +56 -11
  6. data/app/components/primer/blankslate_component.html.erb +2 -2
  7. data/app/components/primer/blankslate_component.rb +71 -116
  8. data/app/components/primer/border_box_component.html.erb +5 -5
  9. data/app/components/primer/border_box_component.rb +45 -33
  10. data/app/components/primer/box_component.rb +6 -4
  11. data/app/components/primer/breadcrumb_component.html.erb +2 -2
  12. data/app/components/primer/breadcrumb_component.rb +23 -30
  13. data/app/components/primer/button_component.rb +28 -11
  14. data/app/components/primer/component.rb +1 -0
  15. data/app/components/primer/counter_component.rb +14 -9
  16. data/app/components/primer/details_component.html.erb +1 -1
  17. data/app/components/primer/details_component.rb +18 -18
  18. data/app/components/primer/dropdown_menu_component.html.erb +1 -1
  19. data/app/components/primer/dropdown_menu_component.rb +6 -6
  20. data/app/components/primer/flash_component.html.erb +2 -2
  21. data/app/components/primer/flash_component.rb +43 -13
  22. data/app/components/primer/flex_component.rb +5 -5
  23. data/app/components/primer/flex_item_component.rb +5 -5
  24. data/app/components/primer/heading_component.rb +4 -4
  25. data/app/components/primer/label_component.rb +25 -8
  26. data/app/components/primer/layout_component.html.erb +1 -1
  27. data/app/components/primer/layout_component.rb +23 -6
  28. data/app/components/primer/link_component.rb +17 -7
  29. data/app/components/primer/octicon_component.rb +23 -5
  30. data/app/components/primer/popover_component.html.erb +1 -1
  31. data/app/components/primer/popover_component.rb +61 -23
  32. data/app/components/primer/progress_bar_component.html.erb +2 -2
  33. data/app/components/primer/progress_bar_component.rb +40 -30
  34. data/app/components/primer/slot.rb +1 -0
  35. data/app/components/primer/spinner_component.html.erb +6 -0
  36. data/app/components/primer/spinner_component.rb +39 -0
  37. data/app/components/primer/state_component.rb +26 -14
  38. data/app/components/primer/subhead_component.html.erb +4 -4
  39. data/app/components/primer/subhead_component.rb +68 -43
  40. data/app/components/primer/text_component.rb +10 -4
  41. data/app/components/primer/timeline_item_component.html.erb +4 -4
  42. data/app/components/primer/timeline_item_component.rb +48 -24
  43. data/app/components/primer/underline_nav_component.html.erb +1 -1
  44. data/app/components/primer/underline_nav_component.rb +5 -5
  45. data/app/components/primer/view_components.rb +1 -0
  46. data/lib/primer/classify.rb +2 -4
  47. data/lib/primer/view_components/version.rb +1 -1
  48. metadata +22 -6
@@ -1,16 +1,16 @@
1
- <%= render Primer::BaseComponent.new(**@kwargs) do %>
1
+ <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
2
  <% if heading.present? %>
3
- <%= render Primer::BaseComponent.new(**heading.kwargs) do %>
3
+ <%= render Primer::BaseComponent.new(**heading.system_arguments) do %>
4
4
  <%= heading.content %>
5
5
  <% end %>
6
6
  <% end %>
7
7
  <% if actions.present? %>
8
- <%= render Primer::BaseComponent.new(**actions.kwargs) do %>
8
+ <%= render Primer::BaseComponent.new(**actions.system_arguments) do %>
9
9
  <%= actions.content %>
10
10
  <% end %>
11
11
  <% end %>
12
12
  <% if description.present? %>
13
- <%= render Primer::BaseComponent.new(**description.kwargs) do %>
13
+ <%= render Primer::BaseComponent.new(**description.system_arguments) do %>
14
14
  <%= description.content %>
15
15
  <% end %>
16
16
  <% end %>
@@ -1,26 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This component consists of a .Subhead container, which has a light gray bottom border.
4
-
5
- # Use a heading element whenever possible as they can be
6
- # used as navigation for assistive technologies, and avoid skipping levels.
7
-
8
- # ## Basic example
9
-
10
- # The `Primer::SubheadComponent` can take the following arguments:
11
-
12
- # 1. `heading` (string). The heading to be rendered.
13
- # 2. `actions` (content). Slot to render any actions to the right of heading.
14
- # 3. `description` (string). Slot to render description under the heading.
15
-
16
- # ```erb
17
- # <%= Primer::SubheadComponent.new(heading: "Hello world")) do |component| %>
18
- # <% component.slot(:actions) do %>
19
- # My Actions
20
- # <% end %>
21
- # <% end %>
22
- # ```
23
3
  module Primer
4
+ # Use the Subhead component for page headings.
24
5
  class SubheadComponent < Primer::Component
25
6
  include ViewComponent::Slotable
26
7
 
@@ -28,18 +9,58 @@ module Primer
28
9
  with_slot :actions, class_name: "Actions"
29
10
  with_slot :description, class_name: "Description"
30
11
 
31
- def initialize(spacious: false, hide_border: false, **kwargs)
32
- @kwargs = kwargs
33
-
34
- @kwargs[:tag] = :div
35
- @kwargs[:classes] =
12
+ # @example 95|Default
13
+ # <%= render(Primer::SubheadComponent.new) do |component| %>
14
+ # <% component.slot(:heading) do %>
15
+ # My Heading
16
+ # <% end %>
17
+ # <% component.slot(:description) do %>
18
+ # My Description
19
+ # <% end %>
20
+ # <% end %>
21
+ #
22
+ # @example 95|Without border
23
+ # <%= render(Primer::SubheadComponent.new(hide_border: true)) do |component| %>
24
+ # <% component.slot(:heading) do %>
25
+ # My Heading
26
+ # <% end %>
27
+ # <% component.slot(:description) do %>
28
+ # My Description
29
+ # <% end %>
30
+ # <% end %>
31
+ #
32
+ # @example 95|With actions
33
+ # <%= render(Primer::SubheadComponent.new) do |component| %>
34
+ # <% component.slot(:heading) do %>
35
+ # My Heading
36
+ # <% end %>
37
+ # <% component.slot(:description) do %>
38
+ # My Description
39
+ # <% end %>
40
+ # <% component.slot(:actions) do %>
41
+ # <%= render(
42
+ # Primer::ButtonComponent.new(
43
+ # tag: :a, href: "http://www.google.com", button_type: :danger
44
+ # )
45
+ # ) { "Action" } %>
46
+ # <% end %>
47
+ # <% end %>
48
+ #
49
+ # @param spacious [Boolean] Whether to add spacing to the Subhead.
50
+ # @param hide_border [Boolean] Whether to hide the border under the heading.
51
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
52
+ def initialize(spacious: false, hide_border: false, **system_arguments)
53
+ @system_arguments = system_arguments
54
+
55
+ @system_arguments[:tag] = :div
56
+ @system_arguments[:classes] =
36
57
  class_names(
37
- @kwargs[:classes],
58
+ @system_arguments[:classes],
38
59
  "Subhead hx_Subhead--responsive",
39
60
  "Subhead--spacious": spacious,
40
61
  "border-bottom-0": hide_border
41
62
  )
42
- @kwargs[:mb] ||= hide_border ? 0 : nil
63
+ @system_arguments[:mb] ||= hide_border ? 0 : nil
43
64
  end
44
65
 
45
66
  def render?
@@ -49,13 +70,15 @@ module Primer
49
70
  class Heading < ViewComponent::Slot
50
71
  include ClassNameHelper
51
72
 
52
- attr_reader :kwargs
73
+ attr_reader :system_arguments
53
74
 
54
- def initialize(danger: false, **kwargs)
55
- @kwargs = kwargs
56
- @kwargs[:tag] ||= :div
57
- @kwargs[:classes] = class_names(
58
- @kwargs[:classes],
75
+ # @param danger [Boolean] Whether to style the heading as dangerous.
76
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
77
+ def initialize(danger: false, **system_arguments)
78
+ @system_arguments = system_arguments
79
+ @system_arguments[:tag] ||= :div
80
+ @system_arguments[:classes] = class_names(
81
+ @system_arguments[:classes],
59
82
  "Subhead-heading",
60
83
  "Subhead-heading--danger": danger
61
84
  )
@@ -65,24 +88,26 @@ module Primer
65
88
  class Actions < ViewComponent::Slot
66
89
  include ClassNameHelper
67
90
 
68
- attr_reader :kwargs
91
+ attr_reader :system_arguments
69
92
 
70
- def initialize(**kwargs)
71
- @kwargs = kwargs
72
- @kwargs[:tag] = :div
73
- @kwargs[:classes] = class_names(@kwargs[:classes], "Subhead-actions")
93
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
94
+ def initialize(**system_arguments)
95
+ @system_arguments = system_arguments
96
+ @system_arguments[:tag] = :div
97
+ @system_arguments[:classes] = class_names(@system_arguments[:classes], "Subhead-actions")
74
98
  end
75
99
  end
76
100
 
77
101
  class Description < ViewComponent::Slot
78
102
  include ClassNameHelper
79
103
 
80
- attr_reader :kwargs
104
+ attr_reader :system_arguments
81
105
 
82
- def initialize(**kwargs)
83
- @kwargs = kwargs
84
- @kwargs[:tag] = :div
85
- @kwargs[:classes] = class_names(@kwargs[:classes], "Subhead-description")
106
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
107
+ def initialize(**system_arguments)
108
+ @system_arguments = system_arguments
109
+ @system_arguments[:tag] = :div
110
+ @system_arguments[:classes] = class_names(@system_arguments[:classes], "Subhead-description")
86
111
  end
87
112
  end
88
113
  end
@@ -1,14 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
+ # The Text component is a wrapper component that will apply typography styles to the text inside.
4
5
  class TextComponent < Primer::Component
5
- def initialize(**kwargs)
6
- @kwargs = kwargs
7
- @kwargs[:tag] ||= :span
6
+ # @example 70|Default
7
+ # <%= render(Primer::TextComponent.new(tag: :p, font_weight: :bold)) { "Bold Text" } %>
8
+ # <%= render(Primer::TextComponent.new(tag: :p, color: :red_5)) { "Red Text" } %>
9
+ #
10
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
11
+ def initialize(**system_arguments)
12
+ @system_arguments = system_arguments
13
+ @system_arguments[:tag] ||= :span
8
14
  end
9
15
 
10
16
  def call
11
- render(Primer::BaseComponent.new(**@kwargs)) { content }
17
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
12
18
  end
13
19
  end
14
20
  end
@@ -1,16 +1,16 @@
1
- <%= render Primer::BaseComponent.new(**kwargs) do %>
1
+ <%= render Primer::BaseComponent.new(**system_arguments) do %>
2
2
  <% if avatar %>
3
- <%= render Primer::AvatarComponent.new(alt: avatar.alt, src: avatar.src, size: avatar.size, square: avatar.square, **avatar.kwargs) %>
3
+ <%= render Primer::AvatarComponent.new(alt: avatar.alt, src: avatar.src, size: avatar.size, square: avatar.square, **avatar.system_arguments) %>
4
4
  <% end %>
5
5
 
6
6
  <% if badge %>
7
- <%= render Primer::BaseComponent.new(**badge.kwargs) do %>
7
+ <%= render Primer::BaseComponent.new(**badge.system_arguments) do %>
8
8
  <%= octicon badge.icon %>
9
9
  <% end %>
10
10
  <% end %>
11
11
 
12
12
  <% if body %>
13
- <%= render Primer::BaseComponent.new(**body.kwargs) do %>
13
+ <%= render Primer::BaseComponent.new(**body.system_arguments) do %>
14
14
  <%= body.content %>
15
15
  <% end %>
16
16
  <% end %>
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
+ # Use `TimelineItem` to display items on a vertical timeline, connected by badge elements.
4
5
  class TimelineItemComponent < Primer::Component
5
6
  include ViewComponent::Slotable
6
7
 
@@ -8,14 +9,26 @@ module Primer
8
9
  with_slot :badge, class_name: "Badge"
9
10
  with_slot :body, class_name: "Body"
10
11
 
11
- attr_reader :kwargs
12
- def initialize(condensed: false, **kwargs)
13
- @kwargs = kwargs
14
- @kwargs[:tag] = :div
15
- @kwargs[:classes] = class_names(
12
+ attr_reader :system_arguments
13
+
14
+ # @example 75|Default
15
+ # <div style="padding-left: 60px">
16
+ # <%= render(Primer::TimelineItemComponent.new) do |component| %>
17
+ # <% component.slot(:avatar, src: "https://github.com/github.png", alt: "github") %>
18
+ # <% component.slot(:badge, bg: :green, color: :white, icon: :check) %>
19
+ # <% component.slot(:body) { "Success!" } %>
20
+ # <% end %>
21
+ # </div>
22
+ #
23
+ # @param condensed [Boolean] Reduce the vertical padding and remove the background from the badge item. Most commonly used in commits.
24
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
25
+ def initialize(condensed: false, **system_arguments)
26
+ @system_arguments = system_arguments
27
+ @system_arguments[:tag] = :div
28
+ @system_arguments[:classes] = class_names(
16
29
  "TimelineItem",
17
30
  condensed ? "TimelineItem--condensed" : "",
18
- kwargs[:classes]
31
+ system_arguments[:classes]
19
32
  )
20
33
  end
21
34
 
@@ -24,44 +37,55 @@ module Primer
24
37
  end
25
38
 
26
39
  class Avatar < Primer::Slot
27
- attr_reader :kwargs, :alt, :src, :size, :square
28
- def initialize(alt: nil, src: nil, size: 40, square: true, **kwargs)
40
+ attr_reader :system_arguments, :alt, :src, :size, :square
41
+
42
+ # @param alt [String] Alt text for avatar image.
43
+ # @param src [String] Src attribute for avatar image.
44
+ # @param size [Integer] Image size.
45
+ # @param square [Boolean] Whether to round the edges of the image.
46
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
47
+ def initialize(alt: nil, src: nil, size: 40, square: true, **system_arguments)
29
48
  @alt = alt
30
49
  @src = src
31
50
  @size = size
32
51
  @square = square
33
52
 
34
- @kwargs = kwargs
35
- @kwargs[:tag] = :div
36
- @kwargs[:classes] = class_names(
53
+ @system_arguments = system_arguments
54
+ @system_arguments[:tag] = :div
55
+ @system_arguments[:classes] = class_names(
37
56
  "TimelineItem-avatar",
38
- kwargs[:classes]
57
+ system_arguments[:classes]
39
58
  )
40
59
  end
41
60
  end
42
61
 
43
62
  class Badge < Primer::Slot
44
- attr_reader :kwargs, :icon
45
- def initialize(icon: nil, **kwargs)
63
+ attr_reader :system_arguments, :icon
64
+
65
+ # @param icon [String] Name of [Octicon](https://primer.style/octicons/) to use.
66
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
67
+ def initialize(icon: nil, **system_arguments)
46
68
  @icon = icon
47
69
 
48
- @kwargs = kwargs
49
- @kwargs[:tag] = :div
50
- @kwargs[:classes] = class_names(
70
+ @system_arguments = system_arguments
71
+ @system_arguments[:tag] = :div
72
+ @system_arguments[:classes] = class_names(
51
73
  "TimelineItem-badge",
52
- kwargs[:classes]
74
+ system_arguments[:classes]
53
75
  )
54
76
  end
55
77
  end
56
78
 
57
79
  class Body < Primer::Slot
58
- attr_reader :kwargs
59
- def initialize(**kwargs)
60
- @kwargs = kwargs
61
- @kwargs[:tag] = :div
62
- @kwargs[:classes] = class_names(
80
+ attr_reader :system_arguments
81
+
82
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
83
+ def initialize(**system_arguments)
84
+ @system_arguments = system_arguments
85
+ @system_arguments[:tag] = :div
86
+ @system_arguments[:classes] = class_names(
63
87
  "TimelineItem-body",
64
- kwargs[:classes]
88
+ system_arguments[:classes]
65
89
  )
66
90
  end
67
91
  end
@@ -1,4 +1,4 @@
1
- <%= render Primer::BaseComponent.new(**@kwargs) do %>
1
+ <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
2
  <% if actions && @align == :right %>
3
3
  <%= actions %>
4
4
  <% end %>
@@ -7,13 +7,13 @@ module Primer
7
7
 
8
8
  with_content_areas :body, :actions
9
9
 
10
- def initialize(align: ALIGN_DEFAULT, **kwargs)
10
+ def initialize(align: ALIGN_DEFAULT, **system_arguments)
11
11
  @align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
12
12
 
13
- @kwargs = kwargs
14
- @kwargs[:tag] = :nav
15
- @kwargs[:classes] = class_names(
16
- @kwargs[:classes],
13
+ @system_arguments = system_arguments
14
+ @system_arguments[:tag] = :nav
15
+ @system_arguments[:classes] = class_names(
16
+ @system_arguments[:classes],
17
17
  "UnderlineNav",
18
18
  "UnderlineNav--right" => @align == :right
19
19
  )
@@ -43,6 +43,7 @@ require_relative "link_component"
43
43
  require_relative "octicon_component"
44
44
  require_relative "popover_component"
45
45
  require_relative "progress_bar_component"
46
+ require_relative "spinner_component"
46
47
  require_relative "state_component"
47
48
  require_relative "subhead_component"
48
49
  require_relative "text_component"
@@ -9,7 +9,7 @@ module Primer
9
9
  ALIGN_ITEMS_KEY = :align_items
10
10
  DISPLAY_KEY = :display
11
11
  RESPONSIVE_KEYS = ([DISPLAY_KEY, DIRECTION_KEY, JUSTIFY_CONTENT_KEY, ALIGN_ITEMS_KEY, :col, :float] + SPACING_KEYS).freeze
12
- BREAKPOINTS = ["", "-sm", "-md", "-lg"]
12
+ BREAKPOINTS = ["", "-sm", "-md", "-lg", "-xl"]
13
13
 
14
14
  # Keys where we can simply translate { key: value } into ".key-value"
15
15
  CONCAT_KEYS = SPACING_KEYS + [:hide, :position, :v, :float, :col, :text, :box_shadow].freeze
@@ -131,9 +131,7 @@ module Primer
131
131
 
132
132
  if invalid_class_names.any?
133
133
  raise ArgumentError.new(
134
- "Primer CSS class #{'name'.pluralize(invalid_class_names.length)} \
135
- #{invalid_class_names.to_sentence} #{'is'.pluralize(invalid_class_names.length)} \
136
- not allowed, use style arguments instead (https://github.com/primer/view_components#built-in-styling-arguments). This warning will not be raised in production.",
134
+ "Use System Arguments (https://primer.style/view-components/system-arguments) instead of Primer CSS class #{'name'.pluralize(invalid_class_names.length)} #{invalid_class_names.to_sentence}. This warning will not be raised in production.",
137
135
  )
138
136
  end
139
137
  end
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 8
8
+ PATCH = 13
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  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.8
4
+ version: 0.0.13
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: 2020-09-14 00:00:00.000000000 Z
11
+ date: 2020-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -70,6 +70,20 @@ dependencies:
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
72
  version: 12.0.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: listen
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '3.0'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '3.0'
73
87
  - !ruby/object:Gem::Dependency
74
88
  name: minitest
75
89
  requirement: !ruby/object:Gem::Requirement
@@ -168,7 +182,7 @@ dependencies:
168
182
  - - "~>"
169
183
  - !ruby/object:Gem::Version
170
184
  version: 0.9.25
171
- description:
185
+ description:
172
186
  email:
173
187
  - opensource+primer_view_components@github.com
174
188
  executables: []
@@ -209,6 +223,8 @@ files:
209
223
  - app/components/primer/progress_bar_component.html.erb
210
224
  - app/components/primer/progress_bar_component.rb
211
225
  - app/components/primer/slot.rb
226
+ - app/components/primer/spinner_component.html.erb
227
+ - app/components/primer/spinner_component.rb
212
228
  - app/components/primer/state_component.rb
213
229
  - app/components/primer/subhead_component.html.erb
214
230
  - app/components/primer/subhead_component.rb
@@ -229,7 +245,7 @@ licenses:
229
245
  - MIT
230
246
  metadata:
231
247
  allowed_push_host: https://rubygems.org
232
- post_install_message:
248
+ post_install_message:
233
249
  rdoc_options: []
234
250
  require_paths:
235
251
  - lib
@@ -245,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
261
  version: '0'
246
262
  requirements: []
247
263
  rubygems_version: 3.1.2
248
- signing_key:
264
+ signing_key:
249
265
  specification_version: 4
250
266
  summary: ViewComponents for the Primer Design System
251
267
  test_files: []