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
@@ -27,10 +27,12 @@ module Primer
|
|
27
27
|
# <%= render(Primer::SpinnerComponent.new(size: :large)) %>
|
28
28
|
#
|
29
29
|
# @param size [Symbol] <%= one_of(Primer::SpinnerComponent::SIZE_MAPPINGS) %>
|
30
|
-
|
30
|
+
# @param style [String] Custom element styles.
|
31
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
32
|
+
def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **system_arguments)
|
31
33
|
@system_arguments = system_arguments
|
32
34
|
@system_arguments[:tag] = :svg
|
33
|
-
@system_arguments[:style] ||=
|
35
|
+
@system_arguments[:style] ||= style
|
34
36
|
@system_arguments[:animation] = :rotate
|
35
37
|
@system_arguments[:width] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
|
36
38
|
@system_arguments[:height] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
|
@@ -1,16 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
# Use `Subhead`
|
4
|
+
# Use `Subhead` as the start of a section. The `:heading` slot will render an `<h2>` font-sized text.
|
5
|
+
#
|
6
|
+
# - Optionally set the `:description` slot to render a short description and the `:actions` slot for a related action.
|
7
|
+
# - Use a succint, one-line description for the `:description` slot. For longer descriptions, omit the description slot and render a paragraph below the `Subhead`.
|
8
|
+
# - Use the actions slot to render a related action to the right of the heading. Use <%= link_to_component(Primer::ButtonComponent) %> or <%= link_to_component(Primer::LinkComponent) %>.
|
9
|
+
#
|
10
|
+
# @accessibility
|
11
|
+
# The `:heading` slot defaults to rendering a `<div>`. Update the tag to a heading element with the appropriate level to improve page navigation for assistive technologies.
|
12
|
+
# <%= link_to_heading_practices %>
|
5
13
|
class SubheadComponent < Primer::Component
|
6
14
|
status :beta
|
7
15
|
|
16
|
+
DEFAULT_HEADING_TAG = :div
|
17
|
+
HEADING_TAG_OPTIONS = [DEFAULT_HEADING_TAG, :h1, :h2, :h3, :h4, :h5, :h6].freeze
|
18
|
+
|
8
19
|
# The heading
|
9
20
|
#
|
21
|
+
# @param tag [Symbol] <%= one_of(Primer::SubheadComponent::HEADING_TAG_OPTIONS)%>
|
10
22
|
# @param danger [Boolean] Whether to style the heading as dangerous.
|
11
23
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
12
|
-
renders_one :heading, lambda { |danger: false, **system_arguments|
|
13
|
-
system_arguments[:tag]
|
24
|
+
renders_one :heading, lambda { |tag: DEFAULT_HEADING_TAG, danger: false, **system_arguments|
|
25
|
+
system_arguments[:tag] = fetch_or_fallback(HEADING_TAG_OPTIONS, tag, DEFAULT_HEADING_TAG)
|
14
26
|
system_arguments[:classes] = class_names(
|
15
27
|
system_arguments[:classes],
|
16
28
|
"Subhead-heading",
|
@@ -42,7 +54,7 @@ module Primer
|
|
42
54
|
|
43
55
|
# @example Default
|
44
56
|
# <%= render(Primer::SubheadComponent.new) do |component| %>
|
45
|
-
# <% component.heading do %>
|
57
|
+
# <% component.heading(tag: :h3) do %>
|
46
58
|
# My Heading
|
47
59
|
# <% end %>
|
48
60
|
# <% component.description do %>
|
@@ -50,6 +62,24 @@ module Primer
|
|
50
62
|
# <% end %>
|
51
63
|
# <% end %>
|
52
64
|
#
|
65
|
+
# @example With dangerous heading
|
66
|
+
# <%= render(Primer::SubheadComponent.new) do |component| %>
|
67
|
+
# <% component.heading(tag: :h3, danger: true) do %>
|
68
|
+
# My Heading
|
69
|
+
# <% end %>
|
70
|
+
# <% component.description do %>
|
71
|
+
# My Description
|
72
|
+
# <% end %>
|
73
|
+
# <% end %>
|
74
|
+
#
|
75
|
+
# @example With long description
|
76
|
+
# <%= render(Primer::SubheadComponent.new) do |component| %>
|
77
|
+
# <% component.heading(tag: :h3) do %>
|
78
|
+
# My Heading
|
79
|
+
# <% end %>
|
80
|
+
# <% end %>
|
81
|
+
# <p> This is a longer description that is sitting below the Subhead. It's much longer than a description that could sit comfortably in the Subhead. </p>
|
82
|
+
#
|
53
83
|
# @example Without border
|
54
84
|
# <%= render(Primer::SubheadComponent.new(hide_border: true)) do |component| %>
|
55
85
|
# <% component.heading do %>
|
@@ -1,10 +1,14 @@
|
|
1
|
-
<%= wrapper do %>
|
1
|
+
<%= wrapper(**@wrapper_arguments) do %>
|
2
2
|
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
3
|
+
<%= extra if @align == :left %>
|
4
|
+
|
3
5
|
<%= render Primer::BaseComponent.new(**@body_arguments) do %>
|
4
6
|
<% tabs.each do |tab| %>
|
5
7
|
<%= tab %>
|
6
8
|
<% end %>
|
7
9
|
<% end %>
|
10
|
+
|
11
|
+
<%= extra if @align == :right %>
|
8
12
|
<% end %>
|
9
13
|
|
10
14
|
<% if @with_panel %>
|
@@ -5,6 +5,11 @@ module Primer
|
|
5
5
|
class TabNavComponent < Primer::Component
|
6
6
|
include Primer::TabbedComponentHelper
|
7
7
|
|
8
|
+
status :beta
|
9
|
+
|
10
|
+
DEFAULT_EXTRA_ALIGN = :left
|
11
|
+
EXTRA_ALIGN_OPTIONS = [DEFAULT_EXTRA_ALIGN, :right].freeze
|
12
|
+
|
8
13
|
# Tabs to be rendered. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
|
9
14
|
#
|
10
15
|
# @param selected [Boolean] Whether the tab is selected.
|
@@ -22,6 +27,15 @@ module Primer
|
|
22
27
|
)
|
23
28
|
}
|
24
29
|
|
30
|
+
# Renders extra content to the `TabNav`. This will be rendered after the tabs.
|
31
|
+
#
|
32
|
+
# @param align [Symbol] <%= one_of(Primer::TabNavComponent::EXTRA_ALIGN_OPTIONS) %>
|
33
|
+
renders_one :extra, lambda { |align: DEFAULT_EXTRA_ALIGN, &block|
|
34
|
+
@align = fetch_or_fallback(EXTRA_ALIGN_OPTIONS, align, DEFAULT_EXTRA_ALIGN)
|
35
|
+
|
36
|
+
view_context.capture { block&.call }
|
37
|
+
}
|
38
|
+
|
25
39
|
# @example Default
|
26
40
|
# <%= render(Primer::TabNavComponent.new(label: "Default")) do |c| %>
|
27
41
|
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
@@ -68,12 +82,53 @@ module Primer
|
|
68
82
|
# <% end %>
|
69
83
|
# <% end %>
|
70
84
|
#
|
85
|
+
# @example With extra content
|
86
|
+
# <%= render(Primer::TabNavComponent.new(label: "With extra content")) do |c| %>
|
87
|
+
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
88
|
+
# <% c.tab(href: "#") { "Tab 2" } %>
|
89
|
+
# <% c.tab(href: "#") { "Tab 3" } %>
|
90
|
+
# <% c.extra do %>
|
91
|
+
# <%= render(Primer::ButtonComponent.new(float: :right)) { "Button" } %>
|
92
|
+
# <% end %>
|
93
|
+
# <% end %>
|
94
|
+
#
|
95
|
+
# @example Adding extra content after the tabs
|
96
|
+
# <%= render(Primer::TabNavComponent.new(label: "Adding extra content after the tabs", display: :flex, body_arguments: { flex: 1 })) do |c| %>
|
97
|
+
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
98
|
+
# <% c.tab(href: "#") { "Tab 2" } %>
|
99
|
+
# <% c.tab(href: "#") { "Tab 3" } %>
|
100
|
+
# <% c.extra(align: :right) do %>
|
101
|
+
# <div>
|
102
|
+
# <%= render(Primer::ButtonComponent.new) { "Button" } %>
|
103
|
+
# </div>
|
104
|
+
# <% end %>
|
105
|
+
# <% end %>
|
106
|
+
#
|
107
|
+
# @example Customizing the body
|
108
|
+
# <%= render(Primer::TabNavComponent.new(label: "Default", body_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
|
109
|
+
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
110
|
+
# <% c.tab(href: "#") { "Tab 2" } %>
|
111
|
+
# <% c.tab(href: "#") { "Tab 3" } %>
|
112
|
+
# <% end %>
|
113
|
+
#
|
114
|
+
# @example Customizing the wrapper
|
115
|
+
# <%= render(Primer::TabNavComponent.new(label: "Default", wrapper_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
|
116
|
+
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
117
|
+
# <% c.tab(href: "#") { "Tab 2" } %>
|
118
|
+
# <% c.tab(href: "#") { "Tab 3" } %>
|
119
|
+
# <% end %>
|
120
|
+
#
|
71
121
|
# @param label [String] Used to set the `aria-label` on the top level `<nav>` element.
|
72
122
|
# @param with_panel [Boolean] Whether the TabNav should navigate through pages or panels.
|
123
|
+
# @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
|
124
|
+
# @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper. Only applies if `with_panel` is `true`.
|
73
125
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
74
|
-
def initialize(label:, with_panel: false, **system_arguments)
|
126
|
+
def initialize(label:, with_panel: false, body_arguments: {}, wrapper_arguments: {}, **system_arguments)
|
127
|
+
@align = DEFAULT_EXTRA_ALIGN
|
75
128
|
@with_panel = with_panel
|
76
129
|
@system_arguments = system_arguments
|
130
|
+
@body_arguments = body_arguments
|
131
|
+
@wrapper_arguments = wrapper_arguments
|
77
132
|
|
78
133
|
@system_arguments[:tag] ||= :div
|
79
134
|
@system_arguments[:classes] = class_names(
|
@@ -81,15 +136,13 @@ module Primer
|
|
81
136
|
system_arguments[:classes]
|
82
137
|
)
|
83
138
|
|
84
|
-
@body_arguments =
|
85
|
-
|
86
|
-
classes: "tabnav-tabs",
|
87
|
-
aria: {
|
88
|
-
label: label
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
139
|
+
@body_arguments[:tag] = navigation_tag(with_panel)
|
140
|
+
@body_arguments[:"aria-label"] = label
|
92
141
|
@body_arguments[:role] = :tablist if @with_panel
|
142
|
+
@body_arguments[:classes] = class_names(
|
143
|
+
"tabnav-tabs",
|
144
|
+
body_arguments[:classes]
|
145
|
+
)
|
93
146
|
end
|
94
147
|
end
|
95
148
|
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
|
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::
|
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::
|
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::
|
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::
|
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::
|
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::
|
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::
|
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 %>
|
@@ -5,6 +5,9 @@ module Primer
|
|
5
5
|
class Truncate < Primer::Component
|
6
6
|
status :beta
|
7
7
|
|
8
|
+
DEFAULT_TAG = :div
|
9
|
+
TAG_OPTIONS = [DEFAULT_TAG, :span, :p].freeze
|
10
|
+
|
8
11
|
# @example Default
|
9
12
|
# <div class="col-2">
|
10
13
|
# <%= render(Primer::Truncate.new(tag: :p)) { "branch-name-that-is-really-long" } %>
|
@@ -19,13 +22,14 @@ module Primer
|
|
19
22
|
# @example Custom size
|
20
23
|
# <%= render(Primer::Truncate.new(tag: :span, inline: true, expandable: true, max_width: 100)) { "branch-name-that-is-really-long" } %>
|
21
24
|
#
|
25
|
+
# @param tag [Symbol] <%= one_of(Primer::Truncate::TAG_OPTIONS) %>
|
22
26
|
# @param inline [Boolean] Whether the element is inline (or inline-block).
|
23
27
|
# @param expandable [Boolean] Whether the entire string should be revealed on hover. Can only be used in conjunction with `inline`.
|
24
28
|
# @param max_width [Integer] Sets the max-width of the text.
|
25
29
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
26
|
-
def initialize(inline: false, expandable: false, max_width: nil, **system_arguments)
|
30
|
+
def initialize(tag: DEFAULT_TAG, inline: false, expandable: false, max_width: nil, **system_arguments)
|
27
31
|
@system_arguments = system_arguments
|
28
|
-
@system_arguments[:tag]
|
32
|
+
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
29
33
|
@system_arguments[:classes] = class_names(
|
30
34
|
@system_arguments[:classes],
|
31
35
|
"css-truncate",
|
@@ -116,14 +116,30 @@ module Primer
|
|
116
116
|
# <% end %>
|
117
117
|
# <% end %>
|
118
118
|
#
|
119
|
+
# @example Customizing the body
|
120
|
+
# <%= render(Primer::UnderlineNavComponent.new(label: "Default", body_arguments: { tag: :ul, classes: "custom-class", border: true, border_color: :info })) do |c| %>
|
121
|
+
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
122
|
+
# <% c.tab(href: "#") { "Tab 2" } %>
|
123
|
+
# <% c.tab(href: "#") { "Tab 3" } %>
|
124
|
+
# <% end %>
|
125
|
+
#
|
126
|
+
# @example Customizing the wrapper
|
127
|
+
# <%= render(Primer::UnderlineNavComponent.new(label: "Default", wrapper_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
|
128
|
+
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
129
|
+
# <% c.tab(href: "#") { "Tab 2" } %>
|
130
|
+
# <% c.tab(href: "#") { "Tab 3" } %>
|
131
|
+
# <% end %>
|
132
|
+
#
|
119
133
|
# @param label [String] The `aria-label` on top level `<nav>` element.
|
120
134
|
# @param with_panel [Boolean] Whether the TabNav should navigate through pages or panels.
|
121
135
|
# @param align [Symbol] <%= one_of(Primer::UnderlineNavComponent::ALIGN_OPTIONS) %> - Defaults to <%= Primer::UnderlineNavComponent::ALIGN_DEFAULT %>
|
122
136
|
# @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
|
137
|
+
# @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper. Only applies if `with_panel` is `true`.
|
123
138
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
124
|
-
def initialize(label:, with_panel: false, align: ALIGN_DEFAULT, body_arguments: { tag: BODY_TAG_DEFAULT }, **system_arguments)
|
139
|
+
def initialize(label:, with_panel: false, align: ALIGN_DEFAULT, body_arguments: { tag: BODY_TAG_DEFAULT }, wrapper_arguments: {}, **system_arguments)
|
125
140
|
@with_panel = with_panel
|
126
141
|
@align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
|
142
|
+
@wrapper_arguments = wrapper_arguments
|
127
143
|
|
128
144
|
@system_arguments = system_arguments
|
129
145
|
@system_arguments[:tag] = navigation_tag(with_panel)
|
data/app/lib/primer/classify.rb
CHANGED
@@ -7,7 +7,7 @@ module Primer
|
|
7
7
|
SPACING_KEYS = Primer::Classify::Spacing::KEYS
|
8
8
|
|
9
9
|
# Keys where we can simply translate { key: value } into ".key-value"
|
10
|
-
CONCAT_KEYS = SPACING_KEYS + %i[hide position v float
|
10
|
+
CONCAT_KEYS = SPACING_KEYS + %i[hide position v float text box_shadow].freeze
|
11
11
|
|
12
12
|
INVALID_CLASS_NAME_PREFIXES =
|
13
13
|
(["bg-", "color-", "text-", "d-", "v-align-", "wb-", "box-shadow-"] + CONCAT_KEYS.map { |k| "#{k}-" }).freeze
|
@@ -16,15 +16,16 @@ module Primer
|
|
16
16
|
BG_KEY = :bg
|
17
17
|
VERTICAL_ALIGN_KEY = :vertical_align
|
18
18
|
WORD_BREAK_KEY = :word_break
|
19
|
-
TEXT_KEYS = %i[text_align
|
19
|
+
TEXT_KEYS = %i[font_family font_style font_weight text_align text_transform].freeze
|
20
20
|
WIDTH_KEY = :width
|
21
21
|
HEIGHT_KEY = :height
|
22
22
|
BOX_SHADOW_KEY = :box_shadow
|
23
23
|
VISIBILITY_KEY = :visibility
|
24
24
|
ANIMATION_KEY = :animation
|
25
|
+
CONTAINER_KEY = :container
|
25
26
|
|
26
27
|
BREAKPOINTS = ["", "-sm", "-md", "-lg", "-xl"].freeze
|
27
|
-
RESPONSIVE_KEYS = ([DISPLAY_KEY, :
|
28
|
+
RESPONSIVE_KEYS = ([DISPLAY_KEY, :float, Primer::Classify::Grid::COL_KEY] + SPACING_KEYS + Primer::Classify::Flex::RESPONSIVE_KEYS).freeze
|
28
29
|
|
29
30
|
BOOLEAN_MAPPINGS = {
|
30
31
|
underline: {
|
@@ -84,6 +85,7 @@ module Primer
|
|
84
85
|
TYPOGRAPHY_KEYS +
|
85
86
|
TEXT_KEYS +
|
86
87
|
Primer::Classify::Flex::KEYS +
|
88
|
+
Primer::Classify::Grid::KEYS +
|
87
89
|
[
|
88
90
|
BORDER_KEY,
|
89
91
|
BORDER_COLOR_KEY,
|
@@ -97,7 +99,8 @@ module Primer
|
|
97
99
|
HEIGHT_KEY,
|
98
100
|
BOX_SHADOW_KEY,
|
99
101
|
VISIBILITY_KEY,
|
100
|
-
ANIMATION_KEY
|
102
|
+
ANIMATION_KEY,
|
103
|
+
CONTAINER_KEY
|
101
104
|
]
|
102
105
|
).freeze
|
103
106
|
|
@@ -123,13 +126,13 @@ module Primer
|
|
123
126
|
def validated_class_names(classes)
|
124
127
|
return if classes.blank?
|
125
128
|
|
126
|
-
if ENV["
|
129
|
+
if force_system_arguments? && !ENV["PRIMER_WARNINGS_DISABLED"]
|
127
130
|
invalid_class_names =
|
128
131
|
classes.split(" ").each_with_object([]) do |class_name, memo|
|
129
132
|
memo << class_name if INVALID_CLASS_NAME_PREFIXES.any? { |prefix| class_name.start_with?(prefix) }
|
130
133
|
end
|
131
134
|
|
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?
|
135
|
+
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
136
|
end
|
134
137
|
|
135
138
|
classes
|
@@ -206,8 +209,10 @@ module Primer
|
|
206
209
|
memo[:classes] << "rounded-#{val}"
|
207
210
|
elsif Primer::Classify::Flex::KEYS.include?(key)
|
208
211
|
memo[:classes] << Primer::Classify::Flex.classes(key, val, breakpoint)
|
212
|
+
elsif Primer::Classify::Grid::KEYS.include?(key)
|
213
|
+
memo[:classes] << Primer::Classify::Grid.classes(key, val, breakpoint)
|
209
214
|
elsif key == WIDTH_KEY || key == HEIGHT_KEY
|
210
|
-
if val == :fit
|
215
|
+
if val == :fit
|
211
216
|
memo[:classes] << "#{key}-#{val}"
|
212
217
|
else
|
213
218
|
memo[key] = val
|
@@ -215,7 +220,11 @@ module Primer
|
|
215
220
|
elsif TEXT_KEYS.include?(key)
|
216
221
|
memo[:classes] << "text-#{val.to_s.dasherize}"
|
217
222
|
elsif TYPOGRAPHY_KEYS.include?(key)
|
218
|
-
memo[:classes] <<
|
223
|
+
memo[:classes] << if val == :small || val == :normal
|
224
|
+
"text-#{val.to_s.dasherize}"
|
225
|
+
else
|
226
|
+
"f#{val.to_s.dasherize}"
|
227
|
+
end
|
219
228
|
elsif key == BOX_SHADOW_KEY
|
220
229
|
memo[:classes] << if val == true
|
221
230
|
"color-shadow-small"
|
@@ -236,6 +245,10 @@ module Primer
|
|
236
245
|
memo[:classes] << "#{key.to_s.dasherize}#{breakpoint}-#{val.to_s.dasherize}"
|
237
246
|
end
|
238
247
|
end
|
248
|
+
|
249
|
+
def force_system_arguments?
|
250
|
+
Rails.application.config.primer_view_components.force_system_arguments
|
251
|
+
end
|
239
252
|
end
|
240
253
|
|
241
254
|
Cache.preload!
|
@@ -54,6 +54,21 @@ module Primer
|
|
54
54
|
values: Primer::Classify::Flex::ALIGN_ITEMS_VALUES
|
55
55
|
)
|
56
56
|
|
57
|
+
preload(
|
58
|
+
keys: Primer::Classify::Grid::CONTAINER_KEY,
|
59
|
+
values: Primer::Classify::Grid::CONTAINER_VALUES
|
60
|
+
)
|
61
|
+
|
62
|
+
preload(
|
63
|
+
keys: Primer::Classify::Grid::CLEARFIX_KEY,
|
64
|
+
values: [true]
|
65
|
+
)
|
66
|
+
|
67
|
+
preload(
|
68
|
+
keys: Primer::Classify::Grid::COL_KEY,
|
69
|
+
values: Primer::Classify::Grid::COL_VALUES
|
70
|
+
)
|
71
|
+
|
57
72
|
preload(
|
58
73
|
keys: Primer::Classify::DISPLAY_KEY,
|
59
74
|
values: [:flex, :block, :inline_block, :inline_flex, :none, :table, :table_cell]
|
@@ -111,7 +126,7 @@ module Primer
|
|
111
126
|
|
112
127
|
preload(
|
113
128
|
keys: [Primer::Classify::WIDTH_KEY, Primer::Classify::HEIGHT_KEY],
|
114
|
-
values: [:fit
|
129
|
+
values: [:fit]
|
115
130
|
)
|
116
131
|
|
117
132
|
preload(
|