primer_view_components 0.0.40 → 0.0.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +62 -0
  3. data/app/assets/javascripts/primer_view_components.js +1 -1
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  5. data/app/components/primer/auto_complete.rb +2 -0
  6. data/app/components/primer/avatar_stack_component.rb +2 -2
  7. data/app/components/primer/base_component.rb +5 -2
  8. data/app/components/primer/blankslate_component.rb +5 -5
  9. data/app/components/primer/clipboard_copy_component.js +13 -2
  10. data/app/components/primer/clipboard_copy_component.ts +15 -2
  11. data/app/components/primer/flash_component.rb +2 -2
  12. data/app/components/primer/image.rb +46 -0
  13. data/app/components/primer/image_crop.rb +1 -1
  14. data/app/components/primer/label_component.rb +6 -2
  15. data/app/components/primer/local_time.d.ts +1 -0
  16. data/app/components/primer/local_time.js +1 -0
  17. data/app/components/primer/local_time.rb +59 -0
  18. data/app/components/primer/local_time.ts +1 -0
  19. data/app/components/primer/navigation/tab_component.rb +8 -1
  20. data/app/components/primer/octicon_component.rb +13 -11
  21. data/app/components/primer/primer.d.ts +1 -0
  22. data/app/components/primer/primer.js +1 -0
  23. data/app/components/primer/primer.ts +1 -0
  24. data/app/components/primer/tab_nav_component.html.erb +2 -0
  25. data/app/components/primer/tab_nav_component.rb +22 -9
  26. data/app/components/primer/{tooltip_component.rb → tooltip.rb} +10 -8
  27. data/app/lib/primer/classify.rb +2 -2
  28. data/app/lib/primer/view_helper.rb +2 -1
  29. data/lib/primer/view_components/version.rb +1 -1
  30. data/lib/tasks/docs.rake +4 -1
  31. data/static/statuses.json +3 -1
  32. metadata +24 -5
@@ -2,4 +2,5 @@ import './auto_complete/auto_complete';
2
2
  import './clipboard_copy_component';
3
3
  import './tab_container_component';
4
4
  import './time_ago_component';
5
+ import './local_time';
5
6
  import './image_crop';
@@ -2,4 +2,5 @@ import './auto_complete/auto_complete';
2
2
  import './clipboard_copy_component';
3
3
  import './tab_container_component';
4
4
  import './time_ago_component';
5
+ import './local_time';
5
6
  import './image_crop';
@@ -2,4 +2,5 @@ import './auto_complete/auto_complete'
2
2
  import './clipboard_copy_component'
3
3
  import './tab_container_component'
4
4
  import './time_ago_component'
5
+ import './local_time'
5
6
  import './image_crop'
@@ -1,5 +1,7 @@
1
1
  <%= wrapper do %>
2
2
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
3
+ <%= extra %>
4
+
3
5
  <%= render Primer::BaseComponent.new(**@body_arguments) do %>
4
6
  <% tabs.each do |tab| %>
5
7
  <%= tab %>
@@ -22,6 +22,9 @@ module Primer
22
22
  )
23
23
  }
24
24
 
25
+ # Renders extra content to the `TabNav`. This will be rendered after the tabs.
26
+ renders_one :extra
27
+
25
28
  # @example Default
26
29
  # <%= render(Primer::TabNavComponent.new(label: "Default")) do |c| %>
27
30
  # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
@@ -68,12 +71,24 @@ module Primer
68
71
  # <% end %>
69
72
  # <% end %>
70
73
  #
74
+ # @example With extra content
75
+ # <%= render(Primer::TabNavComponent.new(label: "Default")) do |c| %>
76
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
77
+ # <% c.tab(href: "#") { "Tab 2" } %>
78
+ # <% c.tab(href: "#") { "Tab 3" } %>
79
+ # <% c.extra do %>
80
+ # <%= render(Primer::ButtonComponent.new(float: :right)) { "Button" } %>
81
+ # <% end %>
82
+ # <% end %>
83
+ #
71
84
  # @param label [String] Used to set the `aria-label` on the top level `<nav>` element.
72
85
  # @param with_panel [Boolean] Whether the TabNav should navigate through pages or panels.
86
+ # @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
73
87
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
74
- def initialize(label:, with_panel: false, **system_arguments)
88
+ def initialize(label:, with_panel: false, body_arguments: {}, **system_arguments)
75
89
  @with_panel = with_panel
76
90
  @system_arguments = system_arguments
91
+ @body_arguments = body_arguments
77
92
 
78
93
  @system_arguments[:tag] ||= :div
79
94
  @system_arguments[:classes] = class_names(
@@ -81,15 +96,13 @@ module Primer
81
96
  system_arguments[:classes]
82
97
  )
83
98
 
84
- @body_arguments = {
85
- tag: navigation_tag(with_panel),
86
- classes: "tabnav-tabs",
87
- aria: {
88
- label: label
89
- }
90
- }
91
-
99
+ @body_arguments[:tag] = navigation_tag(with_panel)
100
+ @body_arguments[:"aria-label"] = label
92
101
  @body_arguments[:role] = :tablist if @with_panel
102
+ @body_arguments[:classes] = class_names(
103
+ "tabnav-tabs",
104
+ body_arguments[:classes]
105
+ )
93
106
  end
94
107
  end
95
108
  end
@@ -2,7 +2,9 @@
2
2
 
3
3
  module Primer
4
4
  # `Tooltip` is a wrapper component that will apply a tooltip to the provided content.
5
- class TooltipComponent < Primer::Component
5
+ class Tooltip < Primer::Component
6
+ status :beta
7
+
6
8
  DIRECTION_DEFAULT = :n
7
9
  ALIGN_DEFAULT = :default
8
10
  MULTILINE_DEFAULT = false
@@ -28,34 +30,34 @@ module Primer
28
30
 
29
31
  # @example Default
30
32
  # <div class="pt-5">
31
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder")) { "Default Bold Text" } %>
33
+ # <%= render(Primer::Tooltip.new(label: "Even bolder")) { "Default Bold Text" } %>
32
34
  # </div>
33
35
  #
34
36
  # @example Wrapping another component
35
37
  # <div class="pt-5">
36
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder")) do %>
38
+ # <%= render(Primer::Tooltip.new(label: "Even bolder")) do %>
37
39
  # <%= render(Primer::ButtonComponent.new) { "Bold Button" } %>
38
40
  # <% end %>
39
41
  # </div>
40
42
  #
41
43
  # @example With a direction
42
44
  # <div class="pt-5">
43
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder", direction: :s)) { "Bold Text With a Direction" } %>
45
+ # <%= render(Primer::Tooltip.new(label: "Even bolder", direction: :s)) { "Bold Text With a Direction" } %>
44
46
  # </div>
45
47
  #
46
48
  # @example With an alignment
47
49
  # <div class="pt-5">
48
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder", direction: :s, alignment: :right_1)) { "Bold Text With an Alignment" } %>
50
+ # <%= render(Primer::Tooltip.new(label: "Even bolder", direction: :s, alignment: :right_1)) { "Bold Text With an Alignment" } %>
49
51
  # </div>
50
52
  #
51
53
  # @example Without a delay
52
54
  # <div class="pt-5">
53
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder", direction: :s, no_delay: true)) { "Bold Text without a delay" } %>
55
+ # <%= render(Primer::Tooltip.new(label: "Even bolder", direction: :s, no_delay: true)) { "Bold Text without a delay" } %>
54
56
  # </div>
55
57
  #
56
58
  # @param label [String] the text to appear in the tooltip
57
- # @param direction [String] Direction of the tooltip. <%= one_of(Primer::TooltipComponent::DIRECTION_OPTIONS) %>
58
- # @param align [String] Align tooltips to the left or right of an element, combined with a `direction` to specify north or south. <%= one_of(Primer::TooltipComponent::ALIGN_MAPPING.keys) %>
59
+ # @param direction [String] Direction of the tooltip. <%= one_of(Primer::Tooltip::DIRECTION_OPTIONS) %>
60
+ # @param align [String] Align tooltips to the left or right of an element, combined with a `direction` to specify north or south. <%= one_of(Primer::Tooltip::ALIGN_MAPPING.keys) %>
59
61
  # @param multiline [Boolean] Use this when you have long content
60
62
  # @param no_delay [Boolean] By default the tooltips have a slight delay before appearing. Set true to override this
61
63
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -123,13 +123,13 @@ module Primer
123
123
  def validated_class_names(classes)
124
124
  return if classes.blank?
125
125
 
126
- if ENV["RAILS_ENV"] == "development"
126
+ if ENV["RAILS_ENV"] == "development" && !ENV["PRIMER_WARNINGS_DISABLED"]
127
127
  invalid_class_names =
128
128
  classes.split(" ").each_with_object([]) do |class_name, memo|
129
129
  memo << class_name if INVALID_CLASS_NAME_PREFIXES.any? { |prefix| class_name.start_with?(prefix) }
130
130
  end
131
131
 
132
- raise ArgumentError, "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." if invalid_class_names.any?
132
+ raise ArgumentError, "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. Set PRIMER_WARNINGS_DISABLED=1 to disable this warning." if invalid_class_names.any?
133
133
  end
134
134
 
135
135
  classes
@@ -8,7 +8,8 @@ module Primer
8
8
  HELPERS = {
9
9
  octicon: "Primer::OcticonComponent",
10
10
  heading: "Primer::HeadingComponent",
11
- time_ago: "Primer::TimeAgoComponent"
11
+ time_ago: "Primer::TimeAgoComponent",
12
+ image: "Primer::Image"
12
13
  }.freeze
13
14
 
14
15
  HELPERS.each do |name, component|
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 40
8
+ PATCH = 41
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
data/lib/tasks/docs.rake CHANGED
@@ -47,6 +47,8 @@ namespace :docs do
47
47
  registry = YARD::RegistryStore.new
48
48
  registry.load!(".yardoc")
49
49
  components = [
50
+ Primer::Image,
51
+ Primer::LocalTime,
50
52
  Primer::OcticonSymbolsComponent,
51
53
  Primer::ImageCrop,
52
54
  Primer::IconButton,
@@ -90,12 +92,13 @@ namespace :docs do
90
92
  Primer::TextComponent,
91
93
  Primer::TimeAgoComponent,
92
94
  Primer::TimelineItemComponent,
93
- Primer::TooltipComponent,
95
+ Primer::Tooltip,
94
96
  Primer::Truncate,
95
97
  Primer::UnderlineNavComponent
96
98
  ]
97
99
 
98
100
  js_components = [
101
+ Primer::LocalTime,
99
102
  Primer::ImageCrop,
100
103
  Primer::AutoComplete,
101
104
  Primer::ClipboardCopy,
data/static/statuses.json CHANGED
@@ -26,10 +26,12 @@
26
26
  "Primer::HeadingComponent": "beta",
27
27
  "Primer::HiddenTextExpander": "alpha",
28
28
  "Primer::IconButton": "beta",
29
+ "Primer::Image": "alpha",
29
30
  "Primer::ImageCrop": "alpha",
30
31
  "Primer::LabelComponent": "beta",
31
32
  "Primer::LayoutComponent": "alpha",
32
33
  "Primer::LinkComponent": "beta",
34
+ "Primer::LocalTime": "alpha",
33
35
  "Primer::Markdown": "beta",
34
36
  "Primer::MenuComponent": "alpha",
35
37
  "Primer::Navigation::TabComponent": "alpha",
@@ -46,7 +48,7 @@
46
48
  "Primer::TimeAgoComponent": "beta",
47
49
  "Primer::TimelineItemComponent": "beta",
48
50
  "Primer::TimelineItemComponent::BadgeComponent": "alpha",
49
- "Primer::TooltipComponent": "alpha",
51
+ "Primer::Tooltip": "beta",
50
52
  "Primer::Truncate": "beta",
51
53
  "Primer::UnderlineNavComponent": "alpha"
52
54
  }
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.40
4
+ version: 0.0.41
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-05-06 00:00:00.000000000 Z
11
+ date: 2021-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -86,6 +86,20 @@ dependencies:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: 0.6.3
89
+ - !ruby/object:Gem::Dependency
90
+ name: axe-core-api
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '4.1'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '4.1'
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: benchmark-ips
91
105
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +134,14 @@ dependencies:
120
134
  requirements:
121
135
  - - '='
122
136
  - !ruby/object:Gem::Version
123
- version: '0.11'
137
+ version: '0.13'
124
138
  type: :development
125
139
  prerelease: false
126
140
  version_requirements: !ruby/object:Gem::Requirement
127
141
  requirements:
128
142
  - - '='
129
143
  - !ruby/object:Gem::Version
130
- version: '0.11'
144
+ version: '0.13'
131
145
  - !ruby/object:Gem::Dependency
132
146
  name: listen
133
147
  requirement: !ruby/object:Gem::Requirement
@@ -370,6 +384,7 @@ files:
370
384
  - app/components/primer/heading_component.rb
371
385
  - app/components/primer/hidden_text_expander.rb
372
386
  - app/components/primer/icon_button.rb
387
+ - app/components/primer/image.rb
373
388
  - app/components/primer/image_crop.d.ts
374
389
  - app/components/primer/image_crop.html.erb
375
390
  - app/components/primer/image_crop.js
@@ -379,6 +394,10 @@ files:
379
394
  - app/components/primer/layout_component.html.erb
380
395
  - app/components/primer/layout_component.rb
381
396
  - app/components/primer/link_component.rb
397
+ - app/components/primer/local_time.d.ts
398
+ - app/components/primer/local_time.js
399
+ - app/components/primer/local_time.rb
400
+ - app/components/primer/local_time.ts
382
401
  - app/components/primer/markdown.rb
383
402
  - app/components/primer/menu_component.html.erb
384
403
  - app/components/primer/menu_component.rb
@@ -413,7 +432,7 @@ files:
413
432
  - app/components/primer/time_ago_component.ts
414
433
  - app/components/primer/timeline_item_component.html.erb
415
434
  - app/components/primer/timeline_item_component.rb
416
- - app/components/primer/tooltip_component.rb
435
+ - app/components/primer/tooltip.rb
417
436
  - app/components/primer/truncate.rb
418
437
  - app/components/primer/underline_nav_component.html.erb
419
438
  - app/components/primer/underline_nav_component.rb