primer_view_components 0.0.50 → 0.0.54
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +136 -0
- data/app/components/primer/alpha/underline_nav.html.erb +15 -0
- data/app/components/primer/alpha/underline_nav.rb +143 -0
- data/app/components/primer/{underline_nav_component.html.erb → alpha/underline_panels.html.erb} +3 -8
- data/app/components/primer/alpha/underline_panels.rb +86 -0
- data/app/components/primer/base_component.rb +2 -2
- data/app/components/primer/beta/avatar_stack.rb +9 -9
- data/app/components/primer/{breadcrumb_component.html.erb → beta/breadcrumbs.html.erb} +0 -0
- data/app/components/primer/beta/breadcrumbs.rb +59 -0
- data/app/components/primer/beta/truncate.html.erb +5 -0
- data/app/components/primer/beta/truncate.rb +110 -0
- data/app/components/primer/border_box_component.rb +27 -1
- data/app/components/primer/clipboard_copy.rb +1 -1
- data/app/components/primer/dropdown.rb +7 -7
- data/app/components/primer/icon_button.rb +1 -1
- data/app/components/primer/navigation/tab_component.rb +7 -5
- data/app/components/primer/progress_bar_component.rb +0 -3
- data/app/components/primer/tab_nav_component.html.erb +1 -1
- data/app/components/primer/tab_nav_component.rb +1 -1
- data/app/lib/primer/fetch_or_fallback_helper.rb +2 -0
- data/app/lib/primer/tabbed_component_helper.rb +3 -3
- data/app/lib/primer/underline_nav_helper.rb +44 -0
- data/app/lib/primer/view_helper.rb +1 -0
- data/lib/primer/classify/flex.rb +1 -1
- data/lib/primer/classify/functional_colors.rb +1 -1
- data/lib/primer/classify/utilities.rb +19 -2
- data/lib/primer/classify/utilities.yml +2 -2
- data/lib/primer/classify/validation.rb +18 -0
- data/lib/primer/classify.rb +5 -15
- data/lib/primer/view_components/constants.rb +1 -1
- data/lib/primer/view_components/linters/argument_mappers/base.rb +34 -8
- data/lib/primer/view_components/linters/argument_mappers/button.rb +5 -6
- data/lib/primer/view_components/linters/argument_mappers/clipboard_copy.rb +4 -3
- data/lib/primer/view_components/linters/argument_mappers/close_button.rb +43 -0
- data/lib/primer/view_components/linters/argument_mappers/flash.rb +32 -0
- data/lib/primer/view_components/linters/argument_mappers/helpers/erb_block.rb +48 -5
- data/lib/primer/view_components/linters/argument_mappers/label.rb +3 -4
- data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +5 -7
- data/lib/primer/view_components/linters/autocorrectable.rb +6 -4
- data/lib/primer/view_components/linters/{helpers.rb → base_linter.rb} +69 -29
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +4 -3
- data/lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb +3 -4
- data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +110 -3
- data/lib/primer/view_components/linters/flash_component_migration_counter.rb +18 -3
- data/lib/primer/view_components/linters/label_component_migration_counter.rb +2 -3
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/config/default.yml +5 -0
- data/lib/rubocop/cop/primer/deprecated_arguments.rb +277 -0
- data/lib/rubocop/cop/primer/no_tag_memoize.rb +1 -0
- data/lib/rubocop/cop/primer/primer_octicon.rb +178 -0
- data/lib/rubocop/cop/primer/system_argument_instead_of_class.rb +12 -16
- data/lib/rubocop/cop/primer.rb +1 -2
- data/lib/tasks/coverage.rake +4 -0
- data/lib/tasks/docs.rake +7 -5
- data/lib/tasks/utilities.rake +5 -3
- data/lib/yard/docs_helper.rb +6 -3
- data/static/arguments.yml +62 -37
- data/static/classes.yml +9 -0
- data/static/constants.json +38 -23
- data/static/statuses.json +8 -5
- metadata +37 -15
- data/app/components/primer/auto_complete/auto_component.d.ts +0 -1
- data/app/components/primer/auto_complete/auto_component.js +0 -1
- data/app/components/primer/breadcrumb_component.rb +0 -57
- data/app/components/primer/underline_nav_component.rb +0 -187
data/static/statuses.json
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"Primer::Alpha::ButtonMarketing": "alpha",
|
3
|
+
"Primer::Alpha::UnderlineNav": "alpha",
|
4
|
+
"Primer::Alpha::UnderlinePanels": "alpha",
|
3
5
|
"Primer::BaseButton": "beta",
|
4
6
|
"Primer::BaseComponent": "beta",
|
5
7
|
"Primer::Beta::AutoComplete": "beta",
|
@@ -7,15 +9,17 @@
|
|
7
9
|
"Primer::Beta::AutoComplete::Item": "beta",
|
8
10
|
"Primer::Beta::Avatar": "beta",
|
9
11
|
"Primer::Beta::AvatarStack": "beta",
|
12
|
+
"Primer::Beta::Breadcrumbs": "beta",
|
13
|
+
"Primer::Beta::Breadcrumbs::Item": "alpha",
|
10
14
|
"Primer::Beta::Text": "beta",
|
15
|
+
"Primer::Beta::Truncate": "beta",
|
16
|
+
"Primer::Beta::Truncate::TruncateText": "alpha",
|
11
17
|
"Primer::BlankslateComponent": "beta",
|
12
18
|
"Primer::BorderBoxComponent": "beta",
|
13
19
|
"Primer::BoxComponent": "stable",
|
14
|
-
"Primer::BreadcrumbComponent": "beta",
|
15
|
-
"Primer::BreadcrumbComponent::ItemComponent": "alpha",
|
16
20
|
"Primer::ButtonComponent": "beta",
|
17
21
|
"Primer::ButtonGroup": "beta",
|
18
|
-
"Primer::ClipboardCopy": "
|
22
|
+
"Primer::ClipboardCopy": "beta",
|
19
23
|
"Primer::CloseButton": "beta",
|
20
24
|
"Primer::CounterComponent": "beta",
|
21
25
|
"Primer::DetailsComponent": "beta",
|
@@ -51,6 +55,5 @@
|
|
51
55
|
"Primer::TimelineItemComponent": "beta",
|
52
56
|
"Primer::TimelineItemComponent::BadgeComponent": "alpha",
|
53
57
|
"Primer::Tooltip": "beta",
|
54
|
-
"Primer::Truncate": "beta"
|
55
|
-
"Primer::UnderlineNavComponent": "alpha"
|
58
|
+
"Primer::Truncate": "beta"
|
56
59
|
}
|
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.
|
4
|
+
version: 0.0.54
|
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-08-
|
11
|
+
date: 2021-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -218,14 +218,14 @@ dependencies:
|
|
218
218
|
requirements:
|
219
219
|
- - '='
|
220
220
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
221
|
+
version: 1.13.0
|
222
222
|
type: :development
|
223
223
|
prerelease: false
|
224
224
|
version_requirements: !ruby/object:Gem::Requirement
|
225
225
|
requirements:
|
226
226
|
- - '='
|
227
227
|
- !ruby/object:Gem::Version
|
228
|
-
version:
|
228
|
+
version: 1.13.0
|
229
229
|
- !ruby/object:Gem::Dependency
|
230
230
|
name: rubocop-github
|
231
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -324,6 +324,20 @@ dependencies:
|
|
324
324
|
- - ">="
|
325
325
|
- !ruby/object:Gem::Version
|
326
326
|
version: '0'
|
327
|
+
- !ruby/object:Gem::Dependency
|
328
|
+
name: timecop
|
329
|
+
requirement: !ruby/object:Gem::Requirement
|
330
|
+
requirements:
|
331
|
+
- - ">="
|
332
|
+
- !ruby/object:Gem::Version
|
333
|
+
version: '0'
|
334
|
+
type: :development
|
335
|
+
prerelease: false
|
336
|
+
version_requirements: !ruby/object:Gem::Requirement
|
337
|
+
requirements:
|
338
|
+
- - ">="
|
339
|
+
- !ruby/object:Gem::Version
|
340
|
+
version: '0'
|
327
341
|
- !ruby/object:Gem::Dependency
|
328
342
|
name: yard
|
329
343
|
requirement: !ruby/object:Gem::Requirement
|
@@ -338,7 +352,7 @@ dependencies:
|
|
338
352
|
- - "~>"
|
339
353
|
- !ruby/object:Gem::Version
|
340
354
|
version: 0.9.25
|
341
|
-
description:
|
355
|
+
description:
|
342
356
|
email:
|
343
357
|
- opensource+primer_view_components@github.com
|
344
358
|
executables: []
|
@@ -351,10 +365,12 @@ files:
|
|
351
365
|
- app/assets/javascripts/primer_view_components.js
|
352
366
|
- app/assets/javascripts/primer_view_components.js.map
|
353
367
|
- app/components/primer/alpha/button_marketing.rb
|
368
|
+
- app/components/primer/alpha/underline_nav.html.erb
|
369
|
+
- app/components/primer/alpha/underline_nav.rb
|
370
|
+
- app/components/primer/alpha/underline_panels.html.erb
|
371
|
+
- app/components/primer/alpha/underline_panels.rb
|
354
372
|
- app/components/primer/auto_complete/auto_complete.d.ts
|
355
373
|
- app/components/primer/auto_complete/auto_complete.js
|
356
|
-
- app/components/primer/auto_complete/auto_component.d.ts
|
357
|
-
- app/components/primer/auto_complete/auto_component.js
|
358
374
|
- app/components/primer/base_button.rb
|
359
375
|
- app/components/primer/base_component.rb
|
360
376
|
- app/components/primer/beta/auto_complete.rb
|
@@ -366,14 +382,16 @@ files:
|
|
366
382
|
- app/components/primer/beta/avatar.rb
|
367
383
|
- app/components/primer/beta/avatar_stack.html.erb
|
368
384
|
- app/components/primer/beta/avatar_stack.rb
|
385
|
+
- app/components/primer/beta/breadcrumbs.html.erb
|
386
|
+
- app/components/primer/beta/breadcrumbs.rb
|
369
387
|
- app/components/primer/beta/text.rb
|
388
|
+
- app/components/primer/beta/truncate.html.erb
|
389
|
+
- app/components/primer/beta/truncate.rb
|
370
390
|
- app/components/primer/blankslate_component.html.erb
|
371
391
|
- app/components/primer/blankslate_component.rb
|
372
392
|
- app/components/primer/border_box_component.html.erb
|
373
393
|
- app/components/primer/border_box_component.rb
|
374
394
|
- app/components/primer/box_component.rb
|
375
|
-
- app/components/primer/breadcrumb_component.html.erb
|
376
|
-
- app/components/primer/breadcrumb_component.rb
|
377
395
|
- app/components/primer/button_component.html.erb
|
378
396
|
- app/components/primer/button_component.rb
|
379
397
|
- app/components/primer/button_group.html.erb
|
@@ -456,8 +474,6 @@ files:
|
|
456
474
|
- app/components/primer/timeline_item_component.rb
|
457
475
|
- app/components/primer/tooltip.rb
|
458
476
|
- app/components/primer/truncate.rb
|
459
|
-
- app/components/primer/underline_nav_component.html.erb
|
460
|
-
- app/components/primer/underline_nav_component.rb
|
461
477
|
- app/lib/primer/class_name_helper.rb
|
462
478
|
- app/lib/primer/fetch_or_fallback_helper.rb
|
463
479
|
- app/lib/primer/join_style_arguments_helper.rb
|
@@ -465,6 +481,7 @@ files:
|
|
465
481
|
- app/lib/primer/status/dsl.rb
|
466
482
|
- app/lib/primer/tabbed_component_helper.rb
|
467
483
|
- app/lib/primer/test_selector_helper.rb
|
484
|
+
- app/lib/primer/underline_nav_helper.rb
|
468
485
|
- app/lib/primer/view_helper.rb
|
469
486
|
- lib/primer/classify.rb
|
470
487
|
- lib/primer/classify/cache.rb
|
@@ -476,6 +493,7 @@ files:
|
|
476
493
|
- lib/primer/classify/grid.rb
|
477
494
|
- lib/primer/classify/utilities.rb
|
478
495
|
- lib/primer/classify/utilities.yml
|
496
|
+
- lib/primer/classify/validation.rb
|
479
497
|
- lib/primer/view_components.rb
|
480
498
|
- lib/primer/view_components/constants.rb
|
481
499
|
- lib/primer/view_components/engine.rb
|
@@ -483,22 +501,26 @@ files:
|
|
483
501
|
- lib/primer/view_components/linters/argument_mappers/base.rb
|
484
502
|
- lib/primer/view_components/linters/argument_mappers/button.rb
|
485
503
|
- lib/primer/view_components/linters/argument_mappers/clipboard_copy.rb
|
504
|
+
- lib/primer/view_components/linters/argument_mappers/close_button.rb
|
486
505
|
- lib/primer/view_components/linters/argument_mappers/conversion_error.rb
|
506
|
+
- lib/primer/view_components/linters/argument_mappers/flash.rb
|
487
507
|
- lib/primer/view_components/linters/argument_mappers/helpers/erb_block.rb
|
488
508
|
- lib/primer/view_components/linters/argument_mappers/label.rb
|
489
509
|
- lib/primer/view_components/linters/argument_mappers/system_arguments.rb
|
490
510
|
- lib/primer/view_components/linters/autocorrectable.rb
|
511
|
+
- lib/primer/view_components/linters/base_linter.rb
|
491
512
|
- lib/primer/view_components/linters/button_component_migration_counter.rb
|
492
513
|
- lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb
|
493
514
|
- lib/primer/view_components/linters/close_button_component_migration_counter.rb
|
494
515
|
- lib/primer/view_components/linters/flash_component_migration_counter.rb
|
495
|
-
- lib/primer/view_components/linters/helpers.rb
|
496
516
|
- lib/primer/view_components/linters/label_component_migration_counter.rb
|
497
517
|
- lib/primer/view_components/statuses.rb
|
498
518
|
- lib/primer/view_components/version.rb
|
499
519
|
- lib/rubocop/config/default.yml
|
500
520
|
- lib/rubocop/cop/primer.rb
|
521
|
+
- lib/rubocop/cop/primer/deprecated_arguments.rb
|
501
522
|
- lib/rubocop/cop/primer/no_tag_memoize.rb
|
523
|
+
- lib/rubocop/cop/primer/primer_octicon.rb
|
502
524
|
- lib/rubocop/cop/primer/system_argument_instead_of_class.rb
|
503
525
|
- lib/tasks/constants.rake
|
504
526
|
- lib/tasks/coverage.rake
|
@@ -518,7 +540,7 @@ licenses:
|
|
518
540
|
- MIT
|
519
541
|
metadata:
|
520
542
|
allowed_push_host: https://rubygems.org
|
521
|
-
post_install_message:
|
543
|
+
post_install_message:
|
522
544
|
rdoc_options: []
|
523
545
|
require_paths:
|
524
546
|
- lib
|
@@ -534,7 +556,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
534
556
|
version: '0'
|
535
557
|
requirements: []
|
536
558
|
rubygems_version: 3.1.2
|
537
|
-
signing_key:
|
559
|
+
signing_key:
|
538
560
|
specification_version: 4
|
539
561
|
summary: ViewComponents for the Primer Design System
|
540
562
|
test_files: []
|
@@ -1 +0,0 @@
|
|
1
|
-
import '@github/auto-complete-element';
|
@@ -1 +0,0 @@
|
|
1
|
-
import '@github/auto-complete-element';
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# Use `Breadcrumb` to display page hierarchy within a section of the site. All of the items in the breadcrumb "trail" are links except for the final item, which is a plain string indicating the current page.
|
5
|
-
class BreadcrumbComponent < Primer::Component
|
6
|
-
status :beta
|
7
|
-
|
8
|
-
# _Note: if both `href` and `selected: true` are passed in, `href` will be ignored and the item will not be rendered as a link._
|
9
|
-
#
|
10
|
-
# @param href [String] The URL to link to.
|
11
|
-
# @param selected [Boolean] Whether or not the item is selected and not rendered as a link.
|
12
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
13
|
-
renders_many :items, "ItemComponent"
|
14
|
-
|
15
|
-
# @example Basic
|
16
|
-
# <%= render(Primer::BreadcrumbComponent.new) do |component| %>
|
17
|
-
# <% component.item(href: "/") do %>Home<% end %>
|
18
|
-
# <% component.item(href: "/about") do %>About<% end %>
|
19
|
-
# <% component.item(selected: true) do %>Team<% end %>
|
20
|
-
# <% end %>
|
21
|
-
#
|
22
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
23
|
-
def initialize(**system_arguments)
|
24
|
-
@system_arguments = system_arguments
|
25
|
-
@system_arguments[:tag] = :nav
|
26
|
-
@system_arguments[:aria] = { label: "Breadcrumb" }
|
27
|
-
end
|
28
|
-
|
29
|
-
def render?
|
30
|
-
items.any?
|
31
|
-
end
|
32
|
-
|
33
|
-
# This component is part of `Primer::BreadcrumbComponent` and should not be
|
34
|
-
# used as a standalone component.
|
35
|
-
class ItemComponent < Primer::Component
|
36
|
-
def initialize(href: nil, selected: false, **system_arguments)
|
37
|
-
@href = href
|
38
|
-
@system_arguments = system_arguments
|
39
|
-
|
40
|
-
@href = nil if selected
|
41
|
-
@system_arguments[:tag] = :li
|
42
|
-
@system_arguments[:"aria-current"] = "page" if selected
|
43
|
-
@system_arguments[:classes] = "breadcrumb-item #{@system_arguments[:classes]}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def call
|
47
|
-
render(Primer::BaseComponent.new(**@system_arguments)) do
|
48
|
-
if @href.present?
|
49
|
-
render(Primer::LinkComponent.new(href: @href)) { content }
|
50
|
-
else
|
51
|
-
content
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,187 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# Use `UnderlineNav` to style navigation with a minimal
|
5
|
-
# underlined selected state, typically used for navigation placed at the top
|
6
|
-
# of the page.
|
7
|
-
class UnderlineNavComponent < Primer::Component
|
8
|
-
include Primer::TabbedComponentHelper
|
9
|
-
|
10
|
-
ALIGN_DEFAULT = :left
|
11
|
-
ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
|
12
|
-
|
13
|
-
BODY_TAG_DEFAULT = :div
|
14
|
-
BODY_TAG_OPTIONS = [BODY_TAG_DEFAULT, :ul].freeze
|
15
|
-
|
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) %>.
|
21
|
-
#
|
22
|
-
# @param panel_id [String] Only applies if `with_panel` is `true`. Unique id of panel.
|
23
|
-
# @param selected [Boolean] Whether the tab is selected.
|
24
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
25
|
-
renders_many :tabs, lambda { |selected: false, **system_arguments|
|
26
|
-
system_arguments[:classes] = class_names(
|
27
|
-
"UnderlineNav-item",
|
28
|
-
system_arguments[:classes]
|
29
|
-
)
|
30
|
-
|
31
|
-
Primer::Navigation::TabComponent.new(
|
32
|
-
list: list?,
|
33
|
-
selected: selected,
|
34
|
-
with_panel: @with_panel,
|
35
|
-
icon_classes: "UnderlineNav-octicon",
|
36
|
-
**system_arguments
|
37
|
-
)
|
38
|
-
}
|
39
|
-
|
40
|
-
# Use actions for a call to action.
|
41
|
-
#
|
42
|
-
# @param tag [Symbol] (Primer::UnderlineNavComponent::ACTIONS_TAG_DEFAULT) <%= one_of(Primer::UnderlineNavComponent::ACTIONS_TAG_OPTIONS) %>
|
43
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
44
|
-
renders_one :actions, lambda { |tag: ACTIONS_TAG_DEFAULT, **system_arguments|
|
45
|
-
system_arguments[:tag] = fetch_or_fallback(ACTIONS_TAG_OPTIONS, tag, ACTIONS_TAG_DEFAULT)
|
46
|
-
system_arguments[:classes] = class_names("UnderlineNav-actions", system_arguments[:classes])
|
47
|
-
|
48
|
-
Primer::BaseComponent.new(**system_arguments)
|
49
|
-
}
|
50
|
-
|
51
|
-
# @example Default
|
52
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "Default")) do |component| %>
|
53
|
-
# <% component.tab(href: "#", selected: true) { "Item 1" } %>
|
54
|
-
# <% component.tab(href: "#") { "Item 2" } %>
|
55
|
-
# <% component.actions do %>
|
56
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
57
|
-
# <% end %>
|
58
|
-
# <% end %>
|
59
|
-
#
|
60
|
-
# @example With icons and counters
|
61
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "With icons and counters")) do |component| %>
|
62
|
-
# <% component.tab(href: "#", selected: true) do |t| %>
|
63
|
-
# <% t.icon(icon: :star) %>
|
64
|
-
# <% t.text { "Item 1" } %>
|
65
|
-
# <% end %>
|
66
|
-
# <% component.tab(href: "#") do |t| %>
|
67
|
-
# <% t.icon(icon: :star) %>
|
68
|
-
# <% t.text { "Item 2" } %>
|
69
|
-
# <% t.counter(count: 10) %>
|
70
|
-
# <% end %>
|
71
|
-
# <% component.tab(href: "#") do |t| %>
|
72
|
-
# <% t.text { "Item 3" } %>
|
73
|
-
# <% t.counter(count: 10) %>
|
74
|
-
# <% end %>
|
75
|
-
# <% component.actions do %>
|
76
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
77
|
-
# <% end %>
|
78
|
-
# <% end %>
|
79
|
-
#
|
80
|
-
# @example Align right
|
81
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "Align right", align: :right)) do |component| %>
|
82
|
-
# <% component.tab(href: "#", selected: true) do |t| %>
|
83
|
-
# <% t.text { "Item 1" } %>
|
84
|
-
# <% end %>
|
85
|
-
# <% component.tab(href: "#") do |t| %>
|
86
|
-
# <% t.text { "Item 2" } %>
|
87
|
-
# <% end %>
|
88
|
-
# <% component.actions do %>
|
89
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
90
|
-
# <% end %>
|
91
|
-
# <% end %>
|
92
|
-
#
|
93
|
-
# @example As a list
|
94
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "As a list", body_arguments: { tag: :ul })) do |component| %>
|
95
|
-
# <% component.tab(href: "#", selected: true) do |t| %>
|
96
|
-
# <% t.text { "Item 1" } %>
|
97
|
-
# <% end %>
|
98
|
-
# <% component.tab(href: "#") do |t| %>
|
99
|
-
# <% t.text { "Item 2" } %>
|
100
|
-
# <% end %>
|
101
|
-
# <% component.actions do %>
|
102
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
103
|
-
# <% end %>
|
104
|
-
# <% end %>
|
105
|
-
#
|
106
|
-
# @example With panels
|
107
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "With panels", with_panel: true)) do |component| %>
|
108
|
-
# <% component.tab(selected: true, id: "tab-1", panel_id: "panel-1") do |t| %>
|
109
|
-
# <% t.text { "Item 1" } %>
|
110
|
-
# <% t.panel do %>
|
111
|
-
# Panel 1
|
112
|
-
# <% end %>
|
113
|
-
# <% end %>
|
114
|
-
# <% component.tab(id: "tab-2", panel_id: "panel-2") do |t| %>
|
115
|
-
# <% t.text { "Item 2" } %>
|
116
|
-
# <% t.panel do %>
|
117
|
-
# Panel 2
|
118
|
-
# <% end %>
|
119
|
-
# <% end %>
|
120
|
-
# <% component.actions do %>
|
121
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
122
|
-
# <% end %>
|
123
|
-
# <% end %>
|
124
|
-
#
|
125
|
-
# @example Customizing the body
|
126
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "Default", body_arguments: { tag: :ul, classes: "custom-class", border: true, border_color: :info })) do |c| %>
|
127
|
-
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
128
|
-
# <% c.tab(href: "#") { "Tab 2" } %>
|
129
|
-
# <% c.tab(href: "#") { "Tab 3" } %>
|
130
|
-
# <% end %>
|
131
|
-
#
|
132
|
-
# @example Customizing the wrapper
|
133
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "Default", wrapper_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
|
134
|
-
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
135
|
-
# <% c.tab(href: "#") { "Tab 2" } %>
|
136
|
-
# <% c.tab(href: "#") { "Tab 3" } %>
|
137
|
-
# <% end %>
|
138
|
-
#
|
139
|
-
# @param label [String] The `aria-label` on top level `<nav>` element.
|
140
|
-
# @param with_panel [Boolean] Whether the `UnderlineNav` should navigate through pages or panels. When true, <%= link_to_component(Primer::TabContainerComponent) %> is
|
141
|
-
# rendered along with JavaScript behavior.
|
142
|
-
# @param align [Symbol] <%= one_of(Primer::UnderlineNavComponent::ALIGN_OPTIONS) %> - Defaults to <%= Primer::UnderlineNavComponent::ALIGN_DEFAULT %>
|
143
|
-
# @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
|
144
|
-
# @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper. Only applies if `with_panel` is `true`.
|
145
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
146
|
-
def initialize(label:, with_panel: false, align: ALIGN_DEFAULT, body_arguments: { tag: BODY_TAG_DEFAULT }, wrapper_arguments: {}, **system_arguments)
|
147
|
-
@with_panel = with_panel
|
148
|
-
@align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
|
149
|
-
@wrapper_arguments = wrapper_arguments
|
150
|
-
|
151
|
-
@system_arguments = system_arguments
|
152
|
-
@system_arguments[:tag] = navigation_tag(with_panel)
|
153
|
-
@system_arguments[:classes] = class_names(
|
154
|
-
@system_arguments[:classes],
|
155
|
-
"UnderlineNav",
|
156
|
-
"UnderlineNav--right" => @align == :right
|
157
|
-
)
|
158
|
-
|
159
|
-
@body_arguments = body_arguments
|
160
|
-
@body_tag = fetch_or_fallback(BODY_TAG_OPTIONS, body_arguments[:tag]&.to_sym, BODY_TAG_DEFAULT)
|
161
|
-
|
162
|
-
@body_arguments[:tag] = @body_tag
|
163
|
-
@body_arguments[:classes] = class_names(
|
164
|
-
"UnderlineNav-body",
|
165
|
-
@body_arguments[:classes],
|
166
|
-
"list-style-none" => list?
|
167
|
-
)
|
168
|
-
|
169
|
-
if with_panel
|
170
|
-
@body_arguments[:role] = :tablist
|
171
|
-
@body_arguments[:"aria-label"] = label
|
172
|
-
else
|
173
|
-
@system_arguments[:"aria-label"] = label
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
private
|
178
|
-
|
179
|
-
def list?
|
180
|
-
@body_tag == :ul
|
181
|
-
end
|
182
|
-
|
183
|
-
def body
|
184
|
-
Primer::BaseComponent.new(**@body_arguments)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|