primer_view_components 0.0.101 → 0.0.103
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_list.rb +0 -2
- data/app/components/primer/alpha/modal_dialog.d.ts +1 -1
- data/app/components/primer/alpha/modal_dialog.js +48 -40
- data/app/components/primer/alpha/modal_dialog.ts +55 -47
- data/app/components/primer/alpha/nav_list/item.rb +1 -1
- data/app/components/primer/alpha/nav_list.js +3 -3
- data/app/components/primer/alpha/nav_list.ts +3 -3
- data/app/components/primer/alpha/toggle_switch.d.ts +2 -1
- data/app/components/primer/alpha/toggle_switch.js +0 -1
- data/app/components/primer/alpha/toggle_switch.ts +1 -1
- data/app/components/primer/beta/button.html.erb +1 -1
- data/app/components/primer/layout_component.html.erb +1 -2
- data/app/components/primer/layout_component.rb +2 -0
- data/app/forms/after_content_form/after_content.html.erb +1 -0
- data/app/forms/after_content_form.rb +13 -0
- data/app/forms/application_form.rb +5 -0
- data/app/forms/array_check_box_group_form/places_lopez_caption.html.erb +1 -0
- data/app/forms/array_check_box_group_form.rb +15 -0
- data/app/forms/both_types_of_caption_form/first_name_caption.html.erb +1 -0
- data/app/forms/both_types_of_caption_form.rb +13 -0
- data/app/forms/caption_template_form/age_middle_aged_caption.html.erb +1 -0
- data/app/forms/caption_template_form/age_young_caption.html.erb +1 -0
- data/app/forms/caption_template_form/cool_caption.html.erb +1 -0
- data/app/forms/caption_template_form/first_name_caption.html.erb +1 -0
- data/app/forms/caption_template_form.rb +22 -0
- data/app/forms/check_box_group_form.rb +28 -0
- data/app/forms/composed_form.rb +14 -0
- data/app/forms/first_name_form.rb +13 -0
- data/app/forms/horizontal_form.rb +34 -0
- data/app/forms/invalid_form.rb +21 -0
- data/app/forms/last_name_form.rb +13 -0
- data/app/forms/multi_input_form.rb +25 -0
- data/app/forms/multi_text_field_form.rb +27 -0
- data/app/forms/radio_button_group_form.rb +12 -0
- data/app/forms/radio_button_with_nested_form.rb +39 -0
- data/app/forms/select_list_form.rb +12 -0
- data/app/forms/single_text_field_form.rb +13 -0
- data/app/forms/submit_button_form.rb +20 -0
- data/app/forms/text_field_and_checkbox_form.rb +19 -0
- data/lib/primer/deprecations.rb +0 -6
- data/lib/primer/view_components/engine.rb +1 -0
- data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +1 -1
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/docs.rake +1 -3
- data/lib/tasks/test.rake +26 -4
- data/previews/primer/alpha/dialog_preview/nested_dialog.html.erb +14 -0
- data/previews/primer/alpha/dialog_preview.rb +15 -0
- data/previews/primer/alpha/underline_nav_preview.rb +1 -1
- data/static/arguments.json +0 -60
- data/static/audited_at.json +0 -6
- data/static/constants.json +0 -68
- data/static/statuses.json +0 -6
- metadata +29 -8
- data/app/components/primer/close_button.rb +0 -7
- data/app/components/primer/details_component.rb +0 -7
- data/app/components/primer/flex_component.rb +0 -146
- data/app/components/primer/flex_item_component.rb +0 -55
- data/app/components/primer/heading_component.rb +0 -7
- data/app/components/primer/hidden_text_expander.rb +0 -7
data/static/arguments.json
CHANGED
@@ -1559,66 +1559,6 @@
|
|
1559
1559
|
}
|
1560
1560
|
]
|
1561
1561
|
},
|
1562
|
-
{
|
1563
|
-
"component": "Flex",
|
1564
|
-
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/flex_component.rb",
|
1565
|
-
"parameters": [
|
1566
|
-
{
|
1567
|
-
"name": "justify_content",
|
1568
|
-
"type": "Symbol",
|
1569
|
-
"default": "`JUSTIFY_CONTENT_DEFAULT`",
|
1570
|
-
"description": "Use this param to distribute space between and around flex items along the main axis of the container. One of `nil`, `:center`, `:flex_end`, `:flex_start`, `:space_around`, or `:space_between`."
|
1571
|
-
},
|
1572
|
-
{
|
1573
|
-
"name": "inline",
|
1574
|
-
"type": "Boolean",
|
1575
|
-
"default": "`false`",
|
1576
|
-
"description": "Defaults to false."
|
1577
|
-
},
|
1578
|
-
{
|
1579
|
-
"name": "flex_wrap",
|
1580
|
-
"type": "Boolean",
|
1581
|
-
"default": "`FLEX_WRAP_DEFAULT`",
|
1582
|
-
"description": "Defaults to nil."
|
1583
|
-
},
|
1584
|
-
{
|
1585
|
-
"name": "align_items",
|
1586
|
-
"type": "Symbol",
|
1587
|
-
"default": "`ALIGN_ITEMS_DEFAULT`",
|
1588
|
-
"description": "Use this param to align items on the cross axis. One of `nil`, `:baseline`, `:center`, `:end`, `:start`, or `:stretch`."
|
1589
|
-
},
|
1590
|
-
{
|
1591
|
-
"name": "direction",
|
1592
|
-
"type": "Symbol",
|
1593
|
-
"default": "`nil`",
|
1594
|
-
"description": "Use this param to define the orientation of the main axis (row or column). By default, flex items will display in a row. One of `nil`, `:column`, `:column_reverse`, `:row`, or `:row_reverse`."
|
1595
|
-
},
|
1596
|
-
{
|
1597
|
-
"name": "system_arguments",
|
1598
|
-
"type": "Hash",
|
1599
|
-
"default": "N/A",
|
1600
|
-
"description": "[System arguments](/system-arguments)"
|
1601
|
-
}
|
1602
|
-
]
|
1603
|
-
},
|
1604
|
-
{
|
1605
|
-
"component": "FlexItem",
|
1606
|
-
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/flex_item_component.rb",
|
1607
|
-
"parameters": [
|
1608
|
-
{
|
1609
|
-
"name": "flex_auto",
|
1610
|
-
"type": "Boolean",
|
1611
|
-
"default": "`false`",
|
1612
|
-
"description": "Fills available space and auto-sizes based on the content. Defaults to false"
|
1613
|
-
},
|
1614
|
-
{
|
1615
|
-
"name": "system_arguments",
|
1616
|
-
"type": "Hash",
|
1617
|
-
"default": "N/A",
|
1618
|
-
"description": "[System arguments](/system-arguments)"
|
1619
|
-
}
|
1620
|
-
]
|
1621
|
-
},
|
1622
1562
|
{
|
1623
1563
|
"component": "HellipButton",
|
1624
1564
|
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/hellip_button.rb",
|
data/static/audited_at.json
CHANGED
@@ -51,20 +51,14 @@
|
|
51
51
|
"Primer::BoxComponent": "",
|
52
52
|
"Primer::ButtonComponent": "",
|
53
53
|
"Primer::ClipboardCopy": "",
|
54
|
-
"Primer::CloseButton": "",
|
55
54
|
"Primer::ConditionalWrapper": "",
|
56
55
|
"Primer::Content": "",
|
57
56
|
"Primer::CounterComponent": "",
|
58
|
-
"Primer::DetailsComponent": "",
|
59
57
|
"Primer::Dropdown": "",
|
60
58
|
"Primer::Dropdown::Menu": "",
|
61
59
|
"Primer::Dropdown::Menu::Item": "",
|
62
60
|
"Primer::DropdownMenuComponent": "",
|
63
|
-
"Primer::FlexComponent": "",
|
64
|
-
"Primer::FlexItemComponent": "",
|
65
|
-
"Primer::HeadingComponent": "",
|
66
61
|
"Primer::HellipButton": "",
|
67
|
-
"Primer::HiddenTextExpander": "",
|
68
62
|
"Primer::IconButton": "",
|
69
63
|
"Primer::Image": "",
|
70
64
|
"Primer::ImageCrop": "",
|
data/static/constants.json
CHANGED
@@ -608,16 +608,12 @@
|
|
608
608
|
},
|
609
609
|
"Primer::ClipboardCopy": {
|
610
610
|
},
|
611
|
-
"Primer::CloseButton": {
|
612
|
-
},
|
613
611
|
"Primer::ConditionalWrapper": {
|
614
612
|
},
|
615
613
|
"Primer::Content": {
|
616
614
|
},
|
617
615
|
"Primer::CounterComponent": {
|
618
616
|
},
|
619
|
-
"Primer::DetailsComponent": {
|
620
|
-
},
|
621
617
|
"Primer::Dropdown": {
|
622
618
|
"Menu": "Primer::Dropdown::Menu"
|
623
619
|
},
|
@@ -671,72 +667,8 @@
|
|
671
667
|
"dark": "dropdown-menu-dark"
|
672
668
|
}
|
673
669
|
},
|
674
|
-
"Primer::FlexComponent": {
|
675
|
-
"ALIGN_ITEMS_DEFAULT": null,
|
676
|
-
"ALIGN_ITEMS_MAPPINGS": {
|
677
|
-
"start": "flex-items-start",
|
678
|
-
"end": "flex-items-end",
|
679
|
-
"center": "flex-items-center",
|
680
|
-
"baseline": "flex-items-baseline",
|
681
|
-
"stretch": "flex-items-stretch"
|
682
|
-
},
|
683
|
-
"ALIGN_ITEMS_OPTIONS": [
|
684
|
-
null,
|
685
|
-
"start",
|
686
|
-
"end",
|
687
|
-
"center",
|
688
|
-
"baseline",
|
689
|
-
"stretch"
|
690
|
-
],
|
691
|
-
"ALLOWED_DIRECTIONS": [
|
692
|
-
null,
|
693
|
-
"column",
|
694
|
-
"column_reverse",
|
695
|
-
"row",
|
696
|
-
"row_reverse"
|
697
|
-
],
|
698
|
-
"DEFAULT_DIRECTION": null,
|
699
|
-
"FLEX_WRAP_DEFAULT": null,
|
700
|
-
"FLEX_WRAP_OPTIONS": [
|
701
|
-
null,
|
702
|
-
true,
|
703
|
-
false
|
704
|
-
],
|
705
|
-
"INLINE_DEFAULT": false,
|
706
|
-
"INLINE_OPTIONS": [
|
707
|
-
false,
|
708
|
-
true
|
709
|
-
],
|
710
|
-
"JUSTIFY_CONTENT_DEFAULT": null,
|
711
|
-
"JUSTIFY_CONTENT_MAPPINGS": {
|
712
|
-
"flex_start": "flex-justify-start",
|
713
|
-
"flex_end": "flex-justify-end",
|
714
|
-
"center": "flex-justify-center",
|
715
|
-
"space_between": "flex-justify-between",
|
716
|
-
"space_around": "flex-justify-around"
|
717
|
-
},
|
718
|
-
"JUSTIFY_CONTENT_OPTIONS": [
|
719
|
-
null,
|
720
|
-
"flex_start",
|
721
|
-
"flex_end",
|
722
|
-
"center",
|
723
|
-
"space_between",
|
724
|
-
"space_around"
|
725
|
-
]
|
726
|
-
},
|
727
|
-
"Primer::FlexItemComponent": {
|
728
|
-
"FLEX_AUTO_ALLOWED_VALUES": [
|
729
|
-
false,
|
730
|
-
true
|
731
|
-
],
|
732
|
-
"FLEX_AUTO_DEFAULT": false
|
733
|
-
},
|
734
|
-
"Primer::HeadingComponent": {
|
735
|
-
},
|
736
670
|
"Primer::HellipButton": {
|
737
671
|
},
|
738
|
-
"Primer::HiddenTextExpander": {
|
739
|
-
},
|
740
672
|
"Primer::IconButton": {
|
741
673
|
"DEFAULT_SCHEME": "default",
|
742
674
|
"SCHEME_MAPPINGS": {
|
data/static/statuses.json
CHANGED
@@ -51,20 +51,14 @@
|
|
51
51
|
"Primer::BoxComponent": "deprecated",
|
52
52
|
"Primer::ButtonComponent": "beta",
|
53
53
|
"Primer::ClipboardCopy": "beta",
|
54
|
-
"Primer::CloseButton": "deprecated",
|
55
54
|
"Primer::ConditionalWrapper": "alpha",
|
56
55
|
"Primer::Content": "stable",
|
57
56
|
"Primer::CounterComponent": "deprecated",
|
58
|
-
"Primer::DetailsComponent": "deprecated",
|
59
57
|
"Primer::Dropdown": "alpha",
|
60
58
|
"Primer::Dropdown::Menu": "alpha",
|
61
59
|
"Primer::Dropdown::Menu::Item": "alpha",
|
62
60
|
"Primer::DropdownMenuComponent": "deprecated",
|
63
|
-
"Primer::FlexComponent": "deprecated",
|
64
|
-
"Primer::FlexItemComponent": "deprecated",
|
65
|
-
"Primer::HeadingComponent": "deprecated",
|
66
61
|
"Primer::HellipButton": "alpha",
|
67
|
-
"Primer::HiddenTextExpander": "deprecated",
|
68
62
|
"Primer::IconButton": "deprecated",
|
69
63
|
"Primer::Image": "alpha",
|
70
64
|
"Primer::ImageCrop": "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.
|
4
|
+
version: 0.0.103
|
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: 2022-10-
|
11
|
+
date: 2022-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -508,12 +508,10 @@ files:
|
|
508
508
|
- app/components/primer/clipboard_copy.js
|
509
509
|
- app/components/primer/clipboard_copy.rb
|
510
510
|
- app/components/primer/clipboard_copy.ts
|
511
|
-
- app/components/primer/close_button.rb
|
512
511
|
- app/components/primer/component.rb
|
513
512
|
- app/components/primer/conditional_wrapper.rb
|
514
513
|
- app/components/primer/content.rb
|
515
514
|
- app/components/primer/counter_component.rb
|
516
|
-
- app/components/primer/details_component.rb
|
517
515
|
- app/components/primer/dropdown.d.ts
|
518
516
|
- app/components/primer/dropdown.html.erb
|
519
517
|
- app/components/primer/dropdown.js
|
@@ -526,11 +524,7 @@ files:
|
|
526
524
|
- app/components/primer/dropdown/menu.ts
|
527
525
|
- app/components/primer/dropdown_menu_component.html.erb
|
528
526
|
- app/components/primer/dropdown_menu_component.rb
|
529
|
-
- app/components/primer/flex_component.rb
|
530
|
-
- app/components/primer/flex_item_component.rb
|
531
|
-
- app/components/primer/heading_component.rb
|
532
527
|
- app/components/primer/hellip_button.rb
|
533
|
-
- app/components/primer/hidden_text_expander.rb
|
534
528
|
- app/components/primer/icon_button.html.erb
|
535
529
|
- app/components/primer/icon_button.rb
|
536
530
|
- app/components/primer/image.rb
|
@@ -581,6 +575,32 @@ files:
|
|
581
575
|
- app/components/primer/timeline_item_component.rb
|
582
576
|
- app/components/primer/tooltip.rb
|
583
577
|
- app/components/primer/truncate.rb
|
578
|
+
- app/forms/after_content_form.rb
|
579
|
+
- app/forms/after_content_form/after_content.html.erb
|
580
|
+
- app/forms/application_form.rb
|
581
|
+
- app/forms/array_check_box_group_form.rb
|
582
|
+
- app/forms/array_check_box_group_form/places_lopez_caption.html.erb
|
583
|
+
- app/forms/both_types_of_caption_form.rb
|
584
|
+
- app/forms/both_types_of_caption_form/first_name_caption.html.erb
|
585
|
+
- app/forms/caption_template_form.rb
|
586
|
+
- app/forms/caption_template_form/age_middle_aged_caption.html.erb
|
587
|
+
- app/forms/caption_template_form/age_young_caption.html.erb
|
588
|
+
- app/forms/caption_template_form/cool_caption.html.erb
|
589
|
+
- app/forms/caption_template_form/first_name_caption.html.erb
|
590
|
+
- app/forms/check_box_group_form.rb
|
591
|
+
- app/forms/composed_form.rb
|
592
|
+
- app/forms/first_name_form.rb
|
593
|
+
- app/forms/horizontal_form.rb
|
594
|
+
- app/forms/invalid_form.rb
|
595
|
+
- app/forms/last_name_form.rb
|
596
|
+
- app/forms/multi_input_form.rb
|
597
|
+
- app/forms/multi_text_field_form.rb
|
598
|
+
- app/forms/radio_button_group_form.rb
|
599
|
+
- app/forms/radio_button_with_nested_form.rb
|
600
|
+
- app/forms/select_list_form.rb
|
601
|
+
- app/forms/single_text_field_form.rb
|
602
|
+
- app/forms/submit_button_form.rb
|
603
|
+
- app/forms/text_field_and_checkbox_form.rb
|
584
604
|
- app/helpers/primer/form_helper.rb
|
585
605
|
- app/lib/primer/audited/dsl.rb
|
586
606
|
- app/lib/primer/class_name_helper.rb
|
@@ -725,6 +745,7 @@ files:
|
|
725
745
|
- previews/primer/alpha/button_marketing_preview.rb
|
726
746
|
- previews/primer/alpha/dialog_preview.rb
|
727
747
|
- previews/primer/alpha/dialog_preview/custom_header.html.erb
|
748
|
+
- previews/primer/alpha/dialog_preview/nested_dialog.html.erb
|
728
749
|
- previews/primer/alpha/dialog_preview/test.html.erb
|
729
750
|
- previews/primer/alpha/dialog_preview/with_footer.html.erb
|
730
751
|
- previews/primer/alpha/dialog_preview/with_form.html.erb
|
@@ -1,146 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# Use `Flex` to make an element lay out its content using the flexbox model.
|
5
|
-
# Before using these utilities, you should be familiar with CSS3 Flexible Box
|
6
|
-
# spec. If you are not, check out MDN's guide [Using CSS Flexible
|
7
|
-
# Boxes](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox).
|
8
|
-
#
|
9
|
-
# @deprecated
|
10
|
-
# Use <%= link_to_component(Primer::Box) %> instead.
|
11
|
-
#
|
12
|
-
# **Before**:
|
13
|
-
#
|
14
|
-
# ```erb
|
15
|
-
# <%%= render Primer::FlexComponent.new(justify_content: :center) %>
|
16
|
-
# <%%= render Primer::FlexComponent.new(inline: true) %>
|
17
|
-
# <%%= render Primer::FlexComponent.new(flex_wrap: true) %>
|
18
|
-
# <%%= render Primer::FlexComponent.new(align_items: :start) %>
|
19
|
-
# <%%= render Primer::FlexComponent.new(direction: :column) %>
|
20
|
-
# ```
|
21
|
-
#
|
22
|
-
# **After**:
|
23
|
-
#
|
24
|
-
# ```erb
|
25
|
-
# <%%= render Primer::Box.new(display: :flex, justify_content: :center) %>
|
26
|
-
# <%%= render Primer::Box.new(display: :inline_flex) %>
|
27
|
-
# <%%= render Primer::Box.new(display: :flex, flex_wrap: :wrap) %>
|
28
|
-
# <%%= render Primer::Box.new(display: :flex, align_items: :start) %>
|
29
|
-
# <%%= render Primer::Box.new(display: :flex, direction: :column) %>
|
30
|
-
# ```
|
31
|
-
class FlexComponent < Primer::Component
|
32
|
-
status :deprecated
|
33
|
-
|
34
|
-
JUSTIFY_CONTENT_DEFAULT = nil
|
35
|
-
JUSTIFY_CONTENT_MAPPINGS = {
|
36
|
-
flex_start: "flex-justify-start",
|
37
|
-
flex_end: "flex-justify-end",
|
38
|
-
center: "flex-justify-center",
|
39
|
-
space_between: "flex-justify-between",
|
40
|
-
space_around: "flex-justify-around"
|
41
|
-
}.freeze
|
42
|
-
JUSTIFY_CONTENT_OPTIONS = [JUSTIFY_CONTENT_DEFAULT, *JUSTIFY_CONTENT_MAPPINGS.keys].freeze
|
43
|
-
|
44
|
-
ALIGN_ITEMS_DEFAULT = nil
|
45
|
-
ALIGN_ITEMS_MAPPINGS = {
|
46
|
-
start: "flex-items-start",
|
47
|
-
end: "flex-items-end",
|
48
|
-
center: "flex-items-center",
|
49
|
-
baseline: "flex-items-baseline",
|
50
|
-
stretch: "flex-items-stretch"
|
51
|
-
}.freeze
|
52
|
-
ALIGN_ITEMS_OPTIONS = [ALIGN_ITEMS_DEFAULT, *ALIGN_ITEMS_MAPPINGS.keys].freeze
|
53
|
-
|
54
|
-
INLINE_DEFAULT = false
|
55
|
-
INLINE_OPTIONS = [INLINE_DEFAULT, true].freeze
|
56
|
-
|
57
|
-
FLEX_WRAP_DEFAULT = nil
|
58
|
-
FLEX_WRAP_OPTIONS = [FLEX_WRAP_DEFAULT, true, false].freeze
|
59
|
-
|
60
|
-
DEFAULT_DIRECTION = nil
|
61
|
-
ALLOWED_DIRECTIONS = [DEFAULT_DIRECTION, :column, :column_reverse, :row, :row_reverse].freeze
|
62
|
-
|
63
|
-
# @example Default
|
64
|
-
# <%= render(Primer::FlexComponent.new(bg: :subtle)) do %>
|
65
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
|
66
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
|
67
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
|
68
|
-
# <% end %>
|
69
|
-
#
|
70
|
-
# @example Justify center
|
71
|
-
# <%= render(Primer::FlexComponent.new(justify_content: :center, bg: :subtle)) do %>
|
72
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
|
73
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
|
74
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
|
75
|
-
# <% end %>
|
76
|
-
#
|
77
|
-
# @example Align end
|
78
|
-
# <%= render(Primer::FlexComponent.new(align_items: :end, bg: :subtle)) do %>
|
79
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
|
80
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
|
81
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
|
82
|
-
# <% end %>
|
83
|
-
#
|
84
|
-
# @example Direction column
|
85
|
-
# <%= render(Primer::FlexComponent.new(direction: :column, bg: :subtle)) do %>
|
86
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
|
87
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
|
88
|
-
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
|
89
|
-
# <% end %>
|
90
|
-
#
|
91
|
-
# @param justify_content [Symbol] Use this param to distribute space between and around flex items along the main axis of the container. <%= one_of(Primer::FlexComponent::JUSTIFY_CONTENT_OPTIONS) %>
|
92
|
-
# @param inline [Boolean] Defaults to false.
|
93
|
-
# @param flex_wrap [Boolean] Defaults to nil.
|
94
|
-
# @param align_items [Symbol] Use this param to align items on the cross axis. <%= one_of(Primer::FlexComponent::ALIGN_ITEMS_OPTIONS) %>
|
95
|
-
# @param direction [Symbol] Use this param to define the orientation of the main axis (row or column). By default, flex items will display in a row. <%= one_of(Primer::FlexComponent::ALLOWED_DIRECTIONS) %>
|
96
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
97
|
-
def initialize(
|
98
|
-
justify_content: JUSTIFY_CONTENT_DEFAULT,
|
99
|
-
inline: INLINE_DEFAULT,
|
100
|
-
flex_wrap: FLEX_WRAP_DEFAULT,
|
101
|
-
align_items: ALIGN_ITEMS_DEFAULT,
|
102
|
-
direction: nil,
|
103
|
-
**system_arguments
|
104
|
-
)
|
105
|
-
deprecated_component_warning(new_class: Primer::Box, version: "0.0.40")
|
106
|
-
|
107
|
-
@align_items = fetch_or_fallback(ALIGN_ITEMS_OPTIONS, align_items, ALIGN_ITEMS_DEFAULT)
|
108
|
-
@justify_content = fetch_or_fallback(JUSTIFY_CONTENT_OPTIONS, justify_content, JUSTIFY_CONTENT_DEFAULT)
|
109
|
-
@flex_wrap = fetch_or_fallback(FLEX_WRAP_OPTIONS, flex_wrap, FLEX_WRAP_DEFAULT)
|
110
|
-
|
111
|
-
# Support direction argument that is an array
|
112
|
-
@direction =
|
113
|
-
if (Array(direction) - ALLOWED_DIRECTIONS).empty?
|
114
|
-
direction
|
115
|
-
else
|
116
|
-
DEFAULT_DIRECTION
|
117
|
-
end
|
118
|
-
|
119
|
-
@system_arguments = system_arguments.merge({ direction: @direction }.compact)
|
120
|
-
@system_arguments[:classes] = class_names(@system_arguments[:classes], component_class_names)
|
121
|
-
@system_arguments[:display] = fetch_or_fallback(INLINE_OPTIONS, inline, INLINE_DEFAULT) ? :inline_flex : :flex
|
122
|
-
end
|
123
|
-
|
124
|
-
def call
|
125
|
-
render(Primer::Box.new(**@system_arguments)) { content }
|
126
|
-
end
|
127
|
-
|
128
|
-
private
|
129
|
-
|
130
|
-
def component_class_names
|
131
|
-
out = []
|
132
|
-
out << JUSTIFY_CONTENT_MAPPINGS[@justify_content]
|
133
|
-
out << ALIGN_ITEMS_MAPPINGS[@align_items]
|
134
|
-
|
135
|
-
out <<
|
136
|
-
case @flex_wrap
|
137
|
-
when true
|
138
|
-
"flex-wrap"
|
139
|
-
when false
|
140
|
-
"flex-nowrap"
|
141
|
-
end
|
142
|
-
|
143
|
-
out.compact.join(" ")
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# Use `FlexItem` to specify the ability of a flex item to alter its
|
5
|
-
# dimensions to fill available space.
|
6
|
-
#
|
7
|
-
# @deprecated
|
8
|
-
# Use <%= link_to_component(Primer::Box) %> instead.
|
9
|
-
#
|
10
|
-
# **Before**:
|
11
|
-
#
|
12
|
-
# ```erb
|
13
|
-
# <%%= render Primer::FlexItemComponent.new(flex_auto: :auto) %>
|
14
|
-
# ```
|
15
|
-
#
|
16
|
-
# **After**:
|
17
|
-
#
|
18
|
-
# ```erb
|
19
|
-
# <%%= render Primer::Box.new(flex: :auto) %>
|
20
|
-
# ```
|
21
|
-
class FlexItemComponent < Primer::Component
|
22
|
-
status :deprecated
|
23
|
-
|
24
|
-
FLEX_AUTO_DEFAULT = false
|
25
|
-
FLEX_AUTO_ALLOWED_VALUES = [FLEX_AUTO_DEFAULT, true].freeze
|
26
|
-
|
27
|
-
# @example Default
|
28
|
-
# <%= render(Primer::FlexComponent.new) do %>
|
29
|
-
# <%= render(Primer::FlexItemComponent.new) do %>
|
30
|
-
# Item 1
|
31
|
-
# <% end %>
|
32
|
-
#
|
33
|
-
# <%= render(Primer::FlexItemComponent.new(flex_auto: true)) do %>
|
34
|
-
# Item 2
|
35
|
-
# <% end %>
|
36
|
-
# <% end %>
|
37
|
-
#
|
38
|
-
# @param flex_auto [Boolean] Fills available space and auto-sizes based on the content. Defaults to <%= Primer::FlexItemComponent::FLEX_AUTO_DEFAULT %>
|
39
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
40
|
-
def initialize(flex_auto: FLEX_AUTO_DEFAULT, **system_arguments)
|
41
|
-
deprecated_component_warning(new_class: Primer::Box, version: "0.0.40")
|
42
|
-
|
43
|
-
@system_arguments = system_arguments
|
44
|
-
@system_arguments[:classes] =
|
45
|
-
class_names(
|
46
|
-
@system_arguments[:classes],
|
47
|
-
"flex-auto" => fetch_or_fallback(FLEX_AUTO_ALLOWED_VALUES, flex_auto, FLEX_AUTO_DEFAULT)
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
def call
|
52
|
-
render(Primer::Box.new(**@system_arguments)) { content }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|