primer_view_components 0.0.54 → 0.0.55

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 +37 -0
  3. data/app/components/primer/alpha/tab_nav.html.erb +11 -0
  4. data/app/components/primer/alpha/tab_nav.rb +130 -0
  5. data/app/components/primer/{tab_nav_component.html.erb → alpha/tab_panels.html.erb} +3 -8
  6. data/app/components/primer/alpha/tab_panels.rb +82 -0
  7. data/app/components/primer/alpha/underline_nav.rb +1 -7
  8. data/app/components/primer/alpha/underline_panels.html.erb +1 -1
  9. data/app/components/primer/base_component.rb +1 -1
  10. data/app/components/primer/beta/breadcrumbs.html.erb +2 -1
  11. data/app/components/primer/beta/breadcrumbs.rb +15 -13
  12. data/app/components/primer/navigation/tab_component.rb +2 -2
  13. data/app/components/primer/octicon_component.rb +6 -1
  14. data/app/components/primer/tab_container_component.rb +1 -1
  15. data/app/lib/primer/class_name_helper.rb +14 -13
  16. data/app/lib/primer/octicon/cache.rb +10 -2
  17. data/app/lib/primer/tab_nav_helper.rb +35 -0
  18. data/app/lib/primer/tabbed_component_helper.rb +3 -3
  19. data/lib/primer/classify/cache.rb +0 -6
  20. data/lib/primer/classify/utilities.rb +1 -1
  21. data/lib/primer/classify/utilities.yml +35 -0
  22. data/lib/primer/classify.rb +0 -5
  23. data/lib/primer/view_components/version.rb +1 -1
  24. data/lib/rubocop/cop/primer/base_cop.rb +28 -0
  25. data/lib/rubocop/cop/primer/deprecated_arguments.rb +1 -15
  26. data/lib/rubocop/cop/primer/system_argument_instead_of_class.rb +1 -15
  27. data/lib/tasks/docs.rake +5 -5
  28. data/lib/tasks/utilities.rake +2 -0
  29. data/static/arguments.yml +29 -36
  30. data/static/classes.yml +1 -0
  31. data/static/constants.json +16 -17
  32. data/static/statuses.json +2 -1
  33. metadata +22 -5
  34. data/app/components/primer/tab_nav_component.rb +0 -151
  35. data/lib/primer/classify/functional_text_colors.rb +0 -64
data/static/classes.yml CHANGED
@@ -76,6 +76,7 @@
76
76
  - ".border"
77
77
  - ".border-bottom-0"
78
78
  - ".breadcrumb-item"
79
+ - ".breadcrumb-item-selected"
79
80
  - ".btn"
80
81
  - ".btn-block"
81
82
  - ".btn-danger"
@@ -33,17 +33,23 @@
33
33
  "large"
34
34
  ]
35
35
  },
36
+ "Primer::Alpha::TabNav": {
37
+ "BODY_TAG_DEFAULT": "ul",
38
+ "TAG_DEFAULT": "nav",
39
+ "TAG_OPTIONS": [
40
+ "nav",
41
+ "div"
42
+ ]
43
+ },
44
+ "Primer::Alpha::TabPanels": {
45
+ "BODY_TAG_DEFAULT": "ul",
46
+ "TAG_DEFAULT": "nav",
47
+ "TAG_OPTIONS": [
48
+ "nav",
49
+ "div"
50
+ ]
51
+ },
36
52
  "Primer::Alpha::UnderlineNav": {
37
- "ACTIONS_TAG_DEFAULT": "div",
38
- "ACTIONS_TAG_OPTIONS": [
39
- "div",
40
- "span"
41
- ],
42
- "ALIGN_DEFAULT": "left",
43
- "ALIGN_OPTIONS": [
44
- "left",
45
- "right"
46
- ],
47
53
  "BODY_TAG_DEFAULT": "ul",
48
54
  "TAG_DEFAULT": "nav",
49
55
  "TAG_OPTIONS": [
@@ -594,13 +600,6 @@
594
600
  },
595
601
  "Primer::TabContainerComponent": {
596
602
  },
597
- "Primer::TabNavComponent": {
598
- "DEFAULT_EXTRA_ALIGN": "left",
599
- "EXTRA_ALIGN_OPTIONS": [
600
- "left",
601
- "right"
602
- ]
603
- },
604
603
  "Primer::TimeAgoComponent": {
605
604
  },
606
605
  "Primer::TimelineItemComponent": {
data/static/statuses.json CHANGED
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "Primer::Alpha::ButtonMarketing": "alpha",
3
+ "Primer::Alpha::TabNav": "alpha",
4
+ "Primer::Alpha::TabPanels": "alpha",
3
5
  "Primer::Alpha::UnderlineNav": "alpha",
4
6
  "Primer::Alpha::UnderlinePanels": "alpha",
5
7
  "Primer::BaseButton": "beta",
@@ -50,7 +52,6 @@
50
52
  "Primer::StateComponent": "beta",
51
53
  "Primer::SubheadComponent": "beta",
52
54
  "Primer::TabContainerComponent": "alpha",
53
- "Primer::TabNavComponent": "beta",
54
55
  "Primer::TimeAgoComponent": "beta",
55
56
  "Primer::TimelineItemComponent": "beta",
56
57
  "Primer::TimelineItemComponent::BadgeComponent": "alpha",
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.54
4
+ version: 0.0.55
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-31 00:00:00.000000000 Z
11
+ date: 2021-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "<"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: allocation_stats
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.1'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: allocation_tracer
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -365,6 +379,10 @@ files:
365
379
  - app/assets/javascripts/primer_view_components.js
366
380
  - app/assets/javascripts/primer_view_components.js.map
367
381
  - app/components/primer/alpha/button_marketing.rb
382
+ - app/components/primer/alpha/tab_nav.html.erb
383
+ - app/components/primer/alpha/tab_nav.rb
384
+ - app/components/primer/alpha/tab_panels.html.erb
385
+ - app/components/primer/alpha/tab_panels.rb
368
386
  - app/components/primer/alpha/underline_nav.html.erb
369
387
  - app/components/primer/alpha/underline_nav.rb
370
388
  - app/components/primer/alpha/underline_panels.html.erb
@@ -464,8 +482,6 @@ files:
464
482
  - app/components/primer/tab_container_component.js
465
483
  - app/components/primer/tab_container_component.rb
466
484
  - app/components/primer/tab_container_component.ts
467
- - app/components/primer/tab_nav_component.html.erb
468
- - app/components/primer/tab_nav_component.rb
469
485
  - app/components/primer/time_ago_component.d.ts
470
486
  - app/components/primer/time_ago_component.js
471
487
  - app/components/primer/time_ago_component.rb
@@ -479,6 +495,7 @@ files:
479
495
  - app/lib/primer/join_style_arguments_helper.rb
480
496
  - app/lib/primer/octicon/cache.rb
481
497
  - app/lib/primer/status/dsl.rb
498
+ - app/lib/primer/tab_nav_helper.rb
482
499
  - app/lib/primer/tabbed_component_helper.rb
483
500
  - app/lib/primer/test_selector_helper.rb
484
501
  - app/lib/primer/underline_nav_helper.rb
@@ -489,7 +506,6 @@ files:
489
506
  - lib/primer/classify/functional_background_colors.rb
490
507
  - lib/primer/classify/functional_border_colors.rb
491
508
  - lib/primer/classify/functional_colors.rb
492
- - lib/primer/classify/functional_text_colors.rb
493
509
  - lib/primer/classify/grid.rb
494
510
  - lib/primer/classify/utilities.rb
495
511
  - lib/primer/classify/utilities.yml
@@ -518,6 +534,7 @@ files:
518
534
  - lib/primer/view_components/version.rb
519
535
  - lib/rubocop/config/default.yml
520
536
  - lib/rubocop/cop/primer.rb
537
+ - lib/rubocop/cop/primer/base_cop.rb
521
538
  - lib/rubocop/cop/primer/deprecated_arguments.rb
522
539
  - lib/rubocop/cop/primer/no_tag_memoize.rb
523
540
  - lib/rubocop/cop/primer/primer_octicon.rb
@@ -1,151 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- # Use `TabNav` to style navigation with a tab-based selected state, typically used for navigation placed at the top of the page.
5
- class TabNavComponent < Primer::Component
6
- include Primer::TabbedComponentHelper
7
-
8
- status :beta
9
-
10
- DEFAULT_EXTRA_ALIGN = :left
11
- EXTRA_ALIGN_OPTIONS = [DEFAULT_EXTRA_ALIGN, :right].freeze
12
-
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) %>.
15
- #
16
- # @param panel_id [String] Only applies if `with_panel` is `true`. Unique ID of panel.
17
- # @param selected [Boolean] Whether the tab is selected.
18
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
19
- renders_many :tabs, lambda { |selected: false, **system_arguments|
20
- system_arguments[:classes] = class_names(
21
- "tabnav-tab",
22
- system_arguments[:classes]
23
- )
24
-
25
- Primer::Navigation::TabComponent.new(
26
- selected: selected,
27
- with_panel: @with_panel,
28
- **system_arguments
29
- )
30
- }
31
-
32
- # Renders extra content to the `TabNav`. This will be rendered after the tabs.
33
- #
34
- # @param align [Symbol] <%= one_of(Primer::TabNavComponent::EXTRA_ALIGN_OPTIONS) %>
35
- renders_one :extra, lambda { |align: DEFAULT_EXTRA_ALIGN, &block|
36
- @align = fetch_or_fallback(EXTRA_ALIGN_OPTIONS, align, DEFAULT_EXTRA_ALIGN)
37
-
38
- view_context.capture { block&.call }
39
- }
40
-
41
- # @example Default
42
- # <%= render(Primer::TabNavComponent.new(label: "Default")) do |c| %>
43
- # <% c.tab(selected: true, href: "#") { "Tab 1" } %>
44
- # <% c.tab(href: "#") { "Tab 2" } %>
45
- # <% c.tab(href: "#") { "Tab 3" } %>
46
- # <% end %>
47
- #
48
- # @example With icons and counters
49
- # <%= render(Primer::TabNavComponent.new(label: "With icons and counters")) do |component| %>
50
- # <% component.tab(href: "#", selected: true) do |t| %>
51
- # <% t.icon(icon: :star) %>
52
- # <% t.text { "Item 1" } %>
53
- # <% end %>
54
- # <% component.tab(href: "#") do |t| %>
55
- # <% t.icon(icon: :star) %>
56
- # <% t.text { "Item 2" } %>
57
- # <% t.counter(count: 10) %>
58
- # <% end %>
59
- # <% component.tab(href: "#") do |t| %>
60
- # <% t.text { "Item 3" } %>
61
- # <% t.counter(count: 10) %>
62
- # <% end %>
63
- # <% end %>
64
- #
65
- # @example With panels
66
- # <%= render(Primer::TabNavComponent.new(label: "With panels", with_panel: true)) do |c| %>
67
- # <% c.tab(selected: true, panel_id: "panel-1", id: "tab-1") do |t| %>
68
- # <% t.text { "Tab 1" } %>
69
- # <% t.panel do %>
70
- # Panel 1
71
- # <% end %>
72
- # <% end %>
73
- # <% c.tab(id: "tab-2", panel_id: "panel-2") do |t| %>
74
- # <% t.text { "Tab 2" } %>
75
- # <% t.panel do %>
76
- # Panel 2
77
- # <% end %>
78
- # <% end %>
79
- # <% c.tab(id: "tab-3", panel_id: "panel-3") do |t| %>
80
- # <% t.text { "Tab 3" } %>
81
- # <% t.panel do %>
82
- # Panel 3
83
- # <% end %>
84
- # <% end %>
85
- # <% end %>
86
- #
87
- # @example With extra content
88
- # <%= render(Primer::TabNavComponent.new(label: "With extra content")) do |c| %>
89
- # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
90
- # <% c.tab(href: "#") { "Tab 2" } %>
91
- # <% c.tab(href: "#") { "Tab 3" } %>
92
- # <% c.extra do %>
93
- # <%= render(Primer::ButtonComponent.new(float: :right)) { "Button" } %>
94
- # <% end %>
95
- # <% end %>
96
- #
97
- # @example Adding extra content after the tabs
98
- # <%= render(Primer::TabNavComponent.new(label: "Adding extra content after the tabs", display: :flex, body_arguments: { flex: 1 })) do |c| %>
99
- # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
100
- # <% c.tab(href: "#") { "Tab 2" } %>
101
- # <% c.tab(href: "#") { "Tab 3" } %>
102
- # <% c.extra(align: :right) do %>
103
- # <div>
104
- # <%= render(Primer::ButtonComponent.new) { "Button" } %>
105
- # </div>
106
- # <% end %>
107
- # <% end %>
108
- #
109
- # @example Customizing the body
110
- # <%= render(Primer::TabNavComponent.new(label: "Default", body_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
111
- # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
112
- # <% c.tab(href: "#") { "Tab 2" } %>
113
- # <% c.tab(href: "#") { "Tab 3" } %>
114
- # <% end %>
115
- #
116
- # @example Customizing the wrapper
117
- # <%= render(Primer::TabNavComponent.new(label: "Default", wrapper_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
118
- # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
119
- # <% c.tab(href: "#") { "Tab 2" } %>
120
- # <% c.tab(href: "#") { "Tab 3" } %>
121
- # <% end %>
122
- #
123
- # @param label [String] Used to set the `aria-label` on the top level `<nav>` element.
124
- # @param with_panel [Boolean] Whether the TabNav should navigate through pages or panels. When true, <%= link_to_component(Primer::TabContainerComponent) %>
125
- # is rendered along with JavaScript behavior. Additionally, the `tab` slot will render as a button as opposed to an anchor.
126
- # @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
127
- # @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper. Only applies if `with_panel` is `true`.
128
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
129
- def initialize(label:, with_panel: false, body_arguments: {}, wrapper_arguments: {}, **system_arguments)
130
- @align = DEFAULT_EXTRA_ALIGN
131
- @with_panel = with_panel
132
- @system_arguments = system_arguments
133
- @body_arguments = body_arguments
134
- @wrapper_arguments = wrapper_arguments
135
-
136
- @system_arguments[:tag] = :div
137
- @system_arguments[:classes] = class_names(
138
- "tabnav",
139
- system_arguments[:classes]
140
- )
141
-
142
- @body_arguments[:tag] = navigation_tag(with_panel)
143
- @body_arguments[:"aria-label"] = label
144
- @body_arguments[:role] = :tablist if @with_panel
145
- @body_arguments[:classes] = class_names(
146
- "tabnav-tabs",
147
- body_arguments[:classes]
148
- )
149
- end
150
- end
151
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "functional_colors"
4
-
5
- module Primer
6
- class Classify
7
- # Text specific functional colors.
8
- # https://primer-css-git-mkt-color-modes-docs-primer.vercel.app/css/support/v16-migration#text
9
- class FunctionalTextColors < FunctionalColors
10
- FUNCTIONAL_OPTIONS = {
11
- primary: :text_primary,
12
- secondary: :text_secondary,
13
- tertiary: :text_tertiary,
14
- link: :text_link,
15
- success: :text_success,
16
- warning: :text_warning,
17
- danger: :text_danger,
18
- white: :text_white,
19
- inverse: :text_inverse
20
- }.freeze
21
-
22
- # colors mapping to `nil` will preserve the old classes.
23
- # e.g. `text: :orange` will generate `text-orange`.
24
- MAPPINGS = {
25
- gray_dark: FUNCTIONAL_OPTIONS[:primary],
26
- gray: FUNCTIONAL_OPTIONS[:secondary],
27
- gray_light: FUNCTIONAL_OPTIONS[:tertiary],
28
- blue: FUNCTIONAL_OPTIONS[:link],
29
- green: FUNCTIONAL_OPTIONS[:success],
30
- yellow: FUNCTIONAL_OPTIONS[:warning],
31
- red: FUNCTIONAL_OPTIONS[:danger],
32
- white: FUNCTIONAL_OPTIONS[:white]
33
- }.freeze
34
-
35
- OPTIONS = [
36
- :icon_primary,
37
- :icon_secondary,
38
- :icon_tertiary,
39
- :icon_info,
40
- :icon_success,
41
- :icon_warning,
42
- :icon_danger,
43
- *FUNCTIONAL_OPTIONS.values
44
- ].freeze
45
- OPTIONS_WITHOUT_MAPPINGS = [:black, :orange, :orange_light, :purple, :pink, :inherit].freeze
46
- DEPRECATED_OPTIONS = [*MAPPINGS.keys, *OPTIONS_WITHOUT_MAPPINGS].freeze
47
-
48
- class << self
49
- def color(val)
50
- functional_color(
51
- key: "color",
52
- value: val,
53
- mappings: MAPPINGS,
54
- non_functional_prefix: "text",
55
- functional_prefix: "color",
56
- number_prefix: "color",
57
- functional_options: OPTIONS,
58
- options_without_mappigs: OPTIONS_WITHOUT_MAPPINGS
59
- )
60
- end
61
- end
62
- end
63
- end
64
- end