primer_view_components 0.0.39 → 0.0.44
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +269 -3
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/components/primer/alpha/button_marketing.rb +70 -0
- data/app/components/primer/auto_complete.rb +99 -41
- data/app/components/primer/auto_complete/auto_complete.html.erb +1 -0
- data/app/components/primer/avatar_stack_component.rb +7 -4
- data/app/components/primer/base_component.rb +17 -7
- data/app/components/primer/beta/text.rb +27 -0
- data/app/components/primer/blankslate_component.html.erb +1 -0
- data/app/components/primer/blankslate_component.rb +68 -49
- data/app/components/primer/button_component.rb +3 -2
- data/app/components/primer/button_group.rb +2 -2
- data/app/components/primer/clipboard_copy_component.js +13 -2
- data/app/components/primer/clipboard_copy_component.ts +15 -2
- data/app/components/primer/component.rb +6 -1
- data/app/components/primer/counter_component.rb +6 -1
- data/app/components/primer/details_component.rb +12 -1
- data/app/components/primer/dropdown.d.ts +1 -0
- data/app/components/primer/{dropdown_component.html.erb → dropdown.html.erb} +2 -1
- data/app/components/primer/dropdown.js +1 -0
- data/app/components/primer/dropdown.rb +149 -0
- data/app/components/primer/dropdown.ts +1 -0
- data/app/components/primer/dropdown/menu.d.ts +1 -0
- data/app/components/primer/dropdown/menu.html.erb +25 -0
- data/app/components/primer/dropdown/menu.js +1 -0
- data/app/components/primer/dropdown/menu.rb +99 -0
- data/app/components/primer/dropdown/menu.ts +1 -0
- data/app/components/primer/flash_component.rb +2 -2
- data/app/components/primer/flex_component.rb +27 -0
- data/app/components/primer/flex_item_component.rb +1 -1
- data/app/components/primer/heading_component.rb +11 -18
- data/app/components/primer/hidden_text_expander.rb +3 -3
- data/app/components/primer/icon_button.rb +20 -3
- data/app/components/primer/image.rb +46 -0
- data/app/components/primer/image_crop.d.ts +1 -0
- data/app/components/primer/image_crop.html.erb +12 -0
- data/app/components/primer/image_crop.js +1 -0
- data/app/components/primer/image_crop.rb +36 -0
- data/app/components/primer/image_crop.ts +1 -0
- data/app/components/primer/label_component.rb +6 -2
- data/app/components/primer/local_time.d.ts +1 -0
- data/app/components/primer/local_time.js +1 -0
- data/app/components/primer/local_time.rb +59 -0
- data/app/components/primer/local_time.ts +1 -0
- data/app/components/primer/{markdown_component.rb → markdown.rb} +11 -6
- data/app/components/primer/navigation/tab_component.rb +10 -3
- data/app/components/primer/octicon_component.html.erb +7 -0
- data/app/components/primer/octicon_component.rb +25 -15
- data/app/components/primer/octicon_symbols_component.html.erb +3 -0
- data/app/components/primer/octicon_symbols_component.rb +61 -0
- data/app/components/primer/primer.d.ts +3 -0
- data/app/components/primer/primer.js +3 -0
- data/app/components/primer/primer.ts +3 -0
- data/app/components/primer/spinner_component.rb +4 -2
- data/app/components/primer/subhead_component.rb +34 -4
- data/app/components/primer/tab_nav_component.html.erb +5 -1
- data/app/components/primer/tab_nav_component.rb +62 -9
- data/app/components/primer/{tooltip_component.rb → tooltip.rb} +10 -8
- data/app/components/primer/truncate.rb +6 -2
- data/app/components/primer/underline_nav_component.html.erb +1 -1
- data/app/components/primer/underline_nav_component.rb +17 -1
- data/app/lib/primer/classify.rb +21 -8
- data/app/lib/primer/classify/cache.rb +16 -1
- data/app/lib/primer/classify/grid.rb +45 -0
- data/app/lib/primer/octicon/cache.rb +4 -0
- data/app/lib/primer/tabbed_component_helper.rb +2 -2
- data/app/lib/primer/view_helper.rb +2 -1
- data/lib/primer/view_components.rb +1 -1
- data/lib/primer/view_components/engine.rb +2 -0
- data/lib/primer/view_components/linters.rb +3 -0
- data/lib/primer/view_components/linters/argument_mappers/button.rb +82 -0
- data/lib/primer/view_components/linters/argument_mappers/conversion_error.rb +10 -0
- data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +46 -0
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +35 -0
- data/lib/primer/view_components/linters/flash_component_migration_counter.rb +16 -0
- data/lib/primer/view_components/linters/helpers.rb +93 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/coverage.rake +14 -0
- data/lib/tasks/docs.rake +387 -0
- data/lib/tasks/statuses.rake +12 -0
- data/lib/yard/docs_helper.rb +67 -0
- data/static/statuses.json +56 -1
- metadata +72 -13
- data/app/components/primer/button_marketing_component.rb +0 -68
- data/app/components/primer/dropdown/menu_component.html.erb +0 -12
- data/app/components/primer/dropdown/menu_component.rb +0 -46
- data/app/components/primer/dropdown_component.rb +0 -73
- data/app/components/primer/text_component.rb +0 -22
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :statuses do
|
4
|
+
task :dump do
|
5
|
+
require File.expand_path("./../../demo/config/environment.rb", __dir__)
|
6
|
+
require "primer/view_components"
|
7
|
+
# Loads all components for `.descendants` to work properly
|
8
|
+
Dir["./app/components/primer/**/*.rb"].sort.each { |file| require file }
|
9
|
+
|
10
|
+
Primer::ViewComponents.dump_statuses
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module YARD
|
4
|
+
# Helper methods to use for yard documentation
|
5
|
+
module DocsHelper
|
6
|
+
def one_of(enumerable, lower: false, sort: true)
|
7
|
+
# Sort the array if requested
|
8
|
+
if sort
|
9
|
+
compare = ->(a, b) { a.class == b.class ? a <=> b : a.class.to_s <=> b.class.to_s }
|
10
|
+
enumerable = enumerable.sort { |a, b| compare.call(a, b) }
|
11
|
+
end
|
12
|
+
|
13
|
+
values =
|
14
|
+
case enumerable
|
15
|
+
when Hash
|
16
|
+
enumerable.map do |key, value|
|
17
|
+
"#{pretty_value(key)} (#{pretty_value(value)})"
|
18
|
+
end
|
19
|
+
else
|
20
|
+
enumerable.map do |key|
|
21
|
+
pretty_value(key)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
prefix = "One of"
|
26
|
+
prefix = prefix.downcase if lower
|
27
|
+
|
28
|
+
"#{prefix} #{values.to_sentence(last_word_connector: ', or ')}."
|
29
|
+
end
|
30
|
+
|
31
|
+
def link_to_accessibility
|
32
|
+
"[Accessibility](#system-arguments)"
|
33
|
+
end
|
34
|
+
|
35
|
+
def link_to_system_arguments_docs
|
36
|
+
"[System arguments](/system-arguments)"
|
37
|
+
end
|
38
|
+
|
39
|
+
def link_to_typography_docs
|
40
|
+
"[Typography](/system-arguments#typography)"
|
41
|
+
end
|
42
|
+
|
43
|
+
def link_to_component(component)
|
44
|
+
short_name = component.name.gsub(/Primer|::|Component/, "")
|
45
|
+
"[#{short_name}](/components/#{short_name.downcase})"
|
46
|
+
end
|
47
|
+
|
48
|
+
def link_to_octicons
|
49
|
+
"[Octicon](https://primer.style/octicons/)"
|
50
|
+
end
|
51
|
+
|
52
|
+
def link_to_heading_practices
|
53
|
+
"[Learn more about best heading practices (WAI Headings)](https://www.w3.org/WAI/tutorials/page-structure/headings/)"
|
54
|
+
end
|
55
|
+
|
56
|
+
def pretty_value(val)
|
57
|
+
case val
|
58
|
+
when nil
|
59
|
+
"`nil`"
|
60
|
+
when Symbol
|
61
|
+
"`:#{val}`"
|
62
|
+
else
|
63
|
+
"`#{val}`"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/static/statuses.json
CHANGED
@@ -1 +1,56 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"Primer::Alpha::ButtonMarketing": "alpha",
|
3
|
+
"Primer::AutoComplete": "beta",
|
4
|
+
"Primer::AutoComplete::Input": "alpha",
|
5
|
+
"Primer::AutoComplete::Item": "beta",
|
6
|
+
"Primer::AvatarComponent": "beta",
|
7
|
+
"Primer::AvatarStackComponent": "beta",
|
8
|
+
"Primer::BaseButton": "beta",
|
9
|
+
"Primer::BaseComponent": "beta",
|
10
|
+
"Primer::Beta::Text": "beta",
|
11
|
+
"Primer::BlankslateComponent": "beta",
|
12
|
+
"Primer::BorderBoxComponent": "beta",
|
13
|
+
"Primer::BoxComponent": "stable",
|
14
|
+
"Primer::BreadcrumbComponent": "beta",
|
15
|
+
"Primer::BreadcrumbComponent::ItemComponent": "alpha",
|
16
|
+
"Primer::ButtonComponent": "beta",
|
17
|
+
"Primer::ButtonGroup": "beta",
|
18
|
+
"Primer::ClipboardCopy": "alpha",
|
19
|
+
"Primer::CloseButton": "beta",
|
20
|
+
"Primer::CounterComponent": "beta",
|
21
|
+
"Primer::DetailsComponent": "beta",
|
22
|
+
"Primer::Dropdown": "alpha",
|
23
|
+
"Primer::Dropdown::Menu": "alpha",
|
24
|
+
"Primer::Dropdown::Menu::Item": "alpha",
|
25
|
+
"Primer::DropdownMenuComponent": "deprecated",
|
26
|
+
"Primer::FlashComponent": "beta",
|
27
|
+
"Primer::FlexComponent": "deprecated",
|
28
|
+
"Primer::FlexItemComponent": "deprecated",
|
29
|
+
"Primer::HeadingComponent": "beta",
|
30
|
+
"Primer::HiddenTextExpander": "alpha",
|
31
|
+
"Primer::IconButton": "beta",
|
32
|
+
"Primer::Image": "alpha",
|
33
|
+
"Primer::ImageCrop": "alpha",
|
34
|
+
"Primer::LabelComponent": "beta",
|
35
|
+
"Primer::LayoutComponent": "alpha",
|
36
|
+
"Primer::LinkComponent": "beta",
|
37
|
+
"Primer::LocalTime": "alpha",
|
38
|
+
"Primer::Markdown": "beta",
|
39
|
+
"Primer::MenuComponent": "alpha",
|
40
|
+
"Primer::Navigation::TabComponent": "alpha",
|
41
|
+
"Primer::OcticonComponent": "beta",
|
42
|
+
"Primer::OcticonSymbolsComponent": "alpha",
|
43
|
+
"Primer::PopoverComponent": "beta",
|
44
|
+
"Primer::ProgressBarComponent": "beta",
|
45
|
+
"Primer::SpinnerComponent": "beta",
|
46
|
+
"Primer::StateComponent": "beta",
|
47
|
+
"Primer::SubheadComponent": "beta",
|
48
|
+
"Primer::TabContainerComponent": "alpha",
|
49
|
+
"Primer::TabNavComponent": "beta",
|
50
|
+
"Primer::TimeAgoComponent": "beta",
|
51
|
+
"Primer::TimelineItemComponent": "beta",
|
52
|
+
"Primer::TimelineItemComponent::BadgeComponent": "alpha",
|
53
|
+
"Primer::Tooltip": "beta",
|
54
|
+
"Primer::Truncate": "beta",
|
55
|
+
"Primer::UnderlineNavComponent": "alpha"
|
56
|
+
}
|
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.44
|
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-
|
11
|
+
date: 2021-06-10 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,28 @@ dependencies:
|
|
120
134
|
requirements:
|
121
135
|
- - '='
|
122
136
|
- !ruby/object:Gem::Version
|
123
|
-
version: '0.
|
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.
|
144
|
+
version: '0.13'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: erb_lint
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
131
159
|
- !ruby/object:Gem::Dependency
|
132
160
|
name: listen
|
133
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -322,6 +350,7 @@ files:
|
|
322
350
|
- README.md
|
323
351
|
- app/assets/javascripts/primer_view_components.js
|
324
352
|
- app/assets/javascripts/primer_view_components.js.map
|
353
|
+
- app/components/primer/alpha/button_marketing.rb
|
325
354
|
- app/components/primer/auto_complete.rb
|
326
355
|
- app/components/primer/auto_complete/auto_complete.d.ts
|
327
356
|
- app/components/primer/auto_complete/auto_complete.html.erb
|
@@ -335,6 +364,7 @@ files:
|
|
335
364
|
- app/components/primer/avatar_stack_component.rb
|
336
365
|
- app/components/primer/base_button.rb
|
337
366
|
- app/components/primer/base_component.rb
|
367
|
+
- app/components/primer/beta/text.rb
|
338
368
|
- app/components/primer/blankslate_component.html.erb
|
339
369
|
- app/components/primer/blankslate_component.rb
|
340
370
|
- app/components/primer/border_box_component.html.erb
|
@@ -346,7 +376,6 @@ files:
|
|
346
376
|
- app/components/primer/button_component.rb
|
347
377
|
- app/components/primer/button_group.html.erb
|
348
378
|
- app/components/primer/button_group.rb
|
349
|
-
- app/components/primer/button_marketing_component.rb
|
350
379
|
- app/components/primer/clipboard_copy.html.erb
|
351
380
|
- app/components/primer/clipboard_copy.rb
|
352
381
|
- app/components/primer/clipboard_copy_component.d.ts
|
@@ -357,10 +386,16 @@ files:
|
|
357
386
|
- app/components/primer/counter_component.rb
|
358
387
|
- app/components/primer/details_component.html.erb
|
359
388
|
- app/components/primer/details_component.rb
|
360
|
-
- app/components/primer/dropdown
|
361
|
-
- app/components/primer/dropdown
|
362
|
-
- app/components/primer/
|
363
|
-
- app/components/primer/
|
389
|
+
- app/components/primer/dropdown.d.ts
|
390
|
+
- app/components/primer/dropdown.html.erb
|
391
|
+
- app/components/primer/dropdown.js
|
392
|
+
- app/components/primer/dropdown.rb
|
393
|
+
- app/components/primer/dropdown.ts
|
394
|
+
- app/components/primer/dropdown/menu.d.ts
|
395
|
+
- app/components/primer/dropdown/menu.html.erb
|
396
|
+
- app/components/primer/dropdown/menu.js
|
397
|
+
- app/components/primer/dropdown/menu.rb
|
398
|
+
- app/components/primer/dropdown/menu.ts
|
364
399
|
- app/components/primer/dropdown_menu_component.html.erb
|
365
400
|
- app/components/primer/dropdown_menu_component.rb
|
366
401
|
- app/components/primer/flash_component.html.erb
|
@@ -370,16 +405,29 @@ files:
|
|
370
405
|
- app/components/primer/heading_component.rb
|
371
406
|
- app/components/primer/hidden_text_expander.rb
|
372
407
|
- app/components/primer/icon_button.rb
|
408
|
+
- app/components/primer/image.rb
|
409
|
+
- app/components/primer/image_crop.d.ts
|
410
|
+
- app/components/primer/image_crop.html.erb
|
411
|
+
- app/components/primer/image_crop.js
|
412
|
+
- app/components/primer/image_crop.rb
|
413
|
+
- app/components/primer/image_crop.ts
|
373
414
|
- app/components/primer/label_component.rb
|
374
415
|
- app/components/primer/layout_component.html.erb
|
375
416
|
- app/components/primer/layout_component.rb
|
376
417
|
- app/components/primer/link_component.rb
|
377
|
-
- app/components/primer/
|
418
|
+
- app/components/primer/local_time.d.ts
|
419
|
+
- app/components/primer/local_time.js
|
420
|
+
- app/components/primer/local_time.rb
|
421
|
+
- app/components/primer/local_time.ts
|
422
|
+
- app/components/primer/markdown.rb
|
378
423
|
- app/components/primer/menu_component.html.erb
|
379
424
|
- app/components/primer/menu_component.rb
|
380
425
|
- app/components/primer/navigation/tab_component.html.erb
|
381
426
|
- app/components/primer/navigation/tab_component.rb
|
427
|
+
- app/components/primer/octicon_component.html.erb
|
382
428
|
- app/components/primer/octicon_component.rb
|
429
|
+
- app/components/primer/octicon_symbols_component.html.erb
|
430
|
+
- app/components/primer/octicon_symbols_component.rb
|
383
431
|
- app/components/primer/popover_component.html.erb
|
384
432
|
- app/components/primer/popover_component.rb
|
385
433
|
- app/components/primer/primer.d.ts
|
@@ -398,14 +446,13 @@ files:
|
|
398
446
|
- app/components/primer/tab_container_component.ts
|
399
447
|
- app/components/primer/tab_nav_component.html.erb
|
400
448
|
- app/components/primer/tab_nav_component.rb
|
401
|
-
- app/components/primer/text_component.rb
|
402
449
|
- app/components/primer/time_ago_component.d.ts
|
403
450
|
- app/components/primer/time_ago_component.js
|
404
451
|
- app/components/primer/time_ago_component.rb
|
405
452
|
- app/components/primer/time_ago_component.ts
|
406
453
|
- app/components/primer/timeline_item_component.html.erb
|
407
454
|
- app/components/primer/timeline_item_component.rb
|
408
|
-
- app/components/primer/
|
455
|
+
- app/components/primer/tooltip.rb
|
409
456
|
- app/components/primer/truncate.rb
|
410
457
|
- app/components/primer/underline_nav_component.html.erb
|
411
458
|
- app/components/primer/underline_nav_component.rb
|
@@ -417,6 +464,7 @@ files:
|
|
417
464
|
- app/lib/primer/classify/functional_border_colors.rb
|
418
465
|
- app/lib/primer/classify/functional_colors.rb
|
419
466
|
- app/lib/primer/classify/functional_text_colors.rb
|
467
|
+
- app/lib/primer/classify/grid.rb
|
420
468
|
- app/lib/primer/classify/spacing.rb
|
421
469
|
- app/lib/primer/fetch_or_fallback_helper.rb
|
422
470
|
- app/lib/primer/join_style_arguments_helper.rb
|
@@ -427,7 +475,18 @@ files:
|
|
427
475
|
- app/lib/primer/view_helper.rb
|
428
476
|
- lib/primer/view_components.rb
|
429
477
|
- lib/primer/view_components/engine.rb
|
478
|
+
- lib/primer/view_components/linters.rb
|
479
|
+
- lib/primer/view_components/linters/argument_mappers/button.rb
|
480
|
+
- lib/primer/view_components/linters/argument_mappers/conversion_error.rb
|
481
|
+
- lib/primer/view_components/linters/argument_mappers/system_arguments.rb
|
482
|
+
- lib/primer/view_components/linters/button_component_migration_counter.rb
|
483
|
+
- lib/primer/view_components/linters/flash_component_migration_counter.rb
|
484
|
+
- lib/primer/view_components/linters/helpers.rb
|
430
485
|
- lib/primer/view_components/version.rb
|
486
|
+
- lib/tasks/coverage.rake
|
487
|
+
- lib/tasks/docs.rake
|
488
|
+
- lib/tasks/statuses.rake
|
489
|
+
- lib/yard/docs_helper.rb
|
431
490
|
- lib/yard/renders_many_handler.rb
|
432
491
|
- lib/yard/renders_one_handler.rb
|
433
492
|
- static/statuses.json
|
@@ -451,7 +510,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
451
510
|
- !ruby/object:Gem::Version
|
452
511
|
version: '0'
|
453
512
|
requirements: []
|
454
|
-
rubygems_version: 3.
|
513
|
+
rubygems_version: 3.0.3
|
455
514
|
signing_key:
|
456
515
|
specification_version: 4
|
457
516
|
summary: ViewComponents for the Primer Design System
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# Use `ButtonMarketing` for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
|
5
|
-
class ButtonMarketingComponent < Primer::Component
|
6
|
-
DEFAULT_SCHEME = :default
|
7
|
-
SCHEME_MAPPINGS = {
|
8
|
-
DEFAULT_SCHEME => "",
|
9
|
-
:primary => "btn-primary-mktg",
|
10
|
-
:outline => "btn-outline-mktg",
|
11
|
-
:transparent => "btn-transparent"
|
12
|
-
}.freeze
|
13
|
-
SCHEME_OPTIONS = SCHEME_MAPPINGS.keys
|
14
|
-
|
15
|
-
DEFAULT_VARIANT = :default
|
16
|
-
VARIANT_MAPPINGS = {
|
17
|
-
DEFAULT_VARIANT => "",
|
18
|
-
:large => "btn-large-mktg"
|
19
|
-
}.freeze
|
20
|
-
VARIANT_OPTIONS = VARIANT_MAPPINGS.keys
|
21
|
-
|
22
|
-
DEFAULT_TAG = :button
|
23
|
-
TAG_OPTIONS = [DEFAULT_TAG, :a].freeze
|
24
|
-
|
25
|
-
DEFAULT_TYPE = :button
|
26
|
-
TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze
|
27
|
-
|
28
|
-
# @example Schemes
|
29
|
-
# <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
|
30
|
-
# <%= render(Primer::ButtonMarketingComponent.new(scheme: :primary, mr: 2)) { "Primary" } %>
|
31
|
-
# <%= render(Primer::ButtonMarketingComponent.new(scheme: :outline)) { "Outline" } %>
|
32
|
-
# <div class="color-bg-canvas-inverse">
|
33
|
-
# <%= render(Primer::ButtonMarketingComponent.new(scheme: :transparent)) { "Transparent" } %>
|
34
|
-
# </div>
|
35
|
-
#
|
36
|
-
# @example Sizes
|
37
|
-
# <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
|
38
|
-
# <%= render(Primer::ButtonMarketingComponent.new(variant: :large)) { "Large" } %>
|
39
|
-
#
|
40
|
-
# @param scheme [Symbol] <%= one_of(Primer::ButtonMarketingComponent::SCHEME_OPTIONS) %>
|
41
|
-
# @param variant [Symbol] <%= one_of(Primer::ButtonMarketingComponent::VARIANT_OPTIONS) %>
|
42
|
-
# @param tag [Symbol] <%= one_of(Primer::ButtonMarketingComponent::TAG_OPTIONS) %>
|
43
|
-
# @param type [Symbol] <%= one_of(Primer::ButtonMarketingComponent::TYPE_OPTIONS) %>
|
44
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
45
|
-
def initialize(
|
46
|
-
scheme: DEFAULT_SCHEME,
|
47
|
-
variant: DEFAULT_VARIANT,
|
48
|
-
tag: DEFAULT_TAG,
|
49
|
-
type: DEFAULT_TYPE,
|
50
|
-
**system_arguments
|
51
|
-
)
|
52
|
-
@system_arguments = system_arguments
|
53
|
-
@system_arguments[:block] = false
|
54
|
-
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
55
|
-
@system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
|
56
|
-
@system_arguments[:classes] = class_names(
|
57
|
-
"btn-mktg",
|
58
|
-
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)],
|
59
|
-
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
|
60
|
-
system_arguments[:classes]
|
61
|
-
)
|
62
|
-
end
|
63
|
-
|
64
|
-
def call
|
65
|
-
render(Primer::BaseButton.new(**@system_arguments)) { content }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
module Dropdown
|
5
|
-
# This component is part of `Dropdown` and should not be
|
6
|
-
# used as a standalone component.
|
7
|
-
class MenuComponent < Primer::Component
|
8
|
-
SCHEME_DEFAULT = :default
|
9
|
-
SCHEME_MAPPINGS = {
|
10
|
-
SCHEME_DEFAULT => "",
|
11
|
-
:dark => "dropdown-menu-dark"
|
12
|
-
}.freeze
|
13
|
-
|
14
|
-
DIRECTION_DEFAULT = :se
|
15
|
-
DIRECTION_OPTIONS = [DIRECTION_DEFAULT, :sw, :w, :e, :ne, :s].freeze
|
16
|
-
|
17
|
-
renders_many :items, lambda { |divider: false, **system_arguments|
|
18
|
-
system_arguments[:tag] = :li
|
19
|
-
system_arguments[:role] = :none if divider
|
20
|
-
system_arguments[:classes] = class_names(
|
21
|
-
system_arguments[:classes],
|
22
|
-
"dropdown-item" => !divider,
|
23
|
-
"dropdown-divider" => divider
|
24
|
-
)
|
25
|
-
|
26
|
-
Primer::BaseComponent.new(**system_arguments)
|
27
|
-
}
|
28
|
-
|
29
|
-
def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
|
30
|
-
@header = header
|
31
|
-
@direction = direction
|
32
|
-
@system_arguments = system_arguments
|
33
|
-
|
34
|
-
@system_arguments[:tag] = "details-menu"
|
35
|
-
@system_arguments[:role] = "menu"
|
36
|
-
|
37
|
-
@system_arguments[:classes] = class_names(
|
38
|
-
@system_arguments[:classes],
|
39
|
-
"dropdown-menu",
|
40
|
-
"dropdown-menu-#{fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT)}",
|
41
|
-
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, SCHEME_DEFAULT)]
|
42
|
-
)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|