primer_view_components 0.0.31 → 0.0.36
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 +94 -0
- data/README.md +2 -2
- data/app/components/primer/{auto_complete_component.rb → auto_complete.rb} +12 -12
- data/app/components/primer/{auto_complete_component.d.ts → auto_complete/auto_complete.d.ts} +0 -0
- data/app/components/primer/{auto_complete_component.html.erb → auto_complete/auto_complete.html.erb} +0 -0
- data/app/components/primer/{auto_complete_component.js → auto_complete/auto_complete.js} +0 -0
- data/app/components/primer/{auto_complete_component.ts → auto_complete/auto_complete.ts} +0 -0
- data/app/components/primer/auto_complete/auto_component.d.ts +1 -0
- data/app/components/primer/auto_complete/auto_component.js +1 -0
- data/app/components/primer/auto_complete/item.rb +42 -0
- data/app/components/primer/avatar_stack_component.rb +1 -1
- data/app/components/primer/base_component.rb +115 -85
- data/app/components/primer/blankslate_component.html.erb +1 -1
- data/app/components/primer/blankslate_component.rb +0 -2
- data/app/components/primer/border_box_component.rb +0 -2
- data/app/components/primer/breadcrumb_component.rb +0 -1
- data/app/components/primer/button_component.rb +37 -16
- data/app/components/primer/button_group_component.rb +3 -5
- data/app/components/primer/button_marketing_component.rb +12 -12
- data/app/components/primer/close_button.rb +30 -0
- data/app/components/primer/component.rb +3 -0
- data/app/components/primer/details_component.rb +0 -1
- data/app/components/primer/dropdown/menu_component.rb +0 -2
- data/app/components/primer/dropdown_component.rb +1 -3
- data/app/components/primer/dropdown_menu_component.rb +1 -1
- data/app/components/primer/flash_component.html.erb +2 -2
- data/app/components/primer/flash_component.rb +10 -12
- data/app/components/primer/foo_bar.d.ts +1 -0
- data/app/components/primer/foo_bar.js +1 -0
- data/app/components/primer/hidden_text_expander.rb +43 -0
- data/app/components/primer/layout_component.rb +0 -2
- data/app/components/primer/link_component.rb +9 -9
- data/app/components/primer/menu_component.rb +2 -4
- data/app/components/primer/navigation/tab_component.html.erb +11 -0
- data/app/components/primer/navigation/tab_component.rb +126 -0
- data/app/components/primer/octicon_component.rb +5 -8
- data/app/components/primer/popover_component.rb +0 -1
- data/app/components/primer/primer.d.ts +1 -1
- data/app/components/primer/primer.js +1 -1
- data/app/components/primer/primer.ts +1 -1
- data/app/components/primer/progress_bar_component.rb +0 -1
- data/app/components/primer/spinner_component.html.erb +1 -3
- data/app/components/primer/spinner_component.rb +1 -0
- data/app/components/primer/state_component.rb +13 -13
- data/app/components/primer/subhead_component.rb +1 -3
- data/app/components/primer/tab_nav_component.html.erb +8 -10
- data/app/components/primer/tab_nav_component.rb +63 -76
- data/app/components/primer/time_ago_component.rb +2 -1
- data/app/components/primer/timeline_item_component.rb +1 -2
- data/app/components/primer/{truncate_component.rb → truncate.rb} +8 -6
- data/app/components/primer/underline_nav_component.html.erb +19 -7
- data/app/components/primer/underline_nav_component.rb +114 -16
- data/app/lib/primer/classify.rb +5 -14
- data/app/lib/primer/classify/cache.rb +14 -4
- data/app/lib/primer/classify/spacing.rb +63 -0
- data/app/lib/primer/tabbed_component_helper.rb +39 -0
- data/app/lib/primer/view_helper.rb +2 -2
- data/lib/primer/view_components/version.rb +1 -1
- data/static/statuses.json +1 -1
- metadata +110 -31
- data/app/assets/javascripts/primer_view_components.js.map.orig +0 -5
- data/app/assets/javascripts/primer_view_components.js.orig +0 -6
- data/app/components/primer/auto_complete_item_component.rb +0 -40
- data/app/components/primer/slot.rb +0 -10
@@ -2,7 +2,7 @@
|
|
2
2
|
<% if spinner.present? %>
|
3
3
|
<%= spinner %>
|
4
4
|
<% elsif @icon.present? %>
|
5
|
-
<%= primer_octicon
|
5
|
+
<%= primer_octicon @icon, size: @icon_size, classes: "blankslate-icon" %>
|
6
6
|
<% elsif @image_src.present? && @image_alt.present? %>
|
7
7
|
<%= image_tag "#{@image_src}", class: "mb-3", size: "56x56", alt: "#{@image_alt}" %>
|
8
8
|
<% end %>
|
@@ -3,7 +3,6 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use breadcrumbs 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
5
|
class BreadcrumbComponent < Primer::Component
|
6
|
-
include ViewComponent::SlotableV2
|
7
6
|
status :beta
|
8
7
|
|
9
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._
|
@@ -3,14 +3,19 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use buttons for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
|
5
5
|
class ButtonComponent < Primer::Component
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
status :beta
|
7
|
+
|
8
|
+
DEFAULT_SCHEME = :default
|
9
|
+
LINK_SCHEME = :link
|
10
|
+
SCHEME_MAPPINGS = {
|
11
|
+
DEFAULT_SCHEME => "",
|
9
12
|
:primary => "btn-primary",
|
10
13
|
:danger => "btn-danger",
|
11
|
-
:outline => "btn-outline"
|
14
|
+
:outline => "btn-outline",
|
15
|
+
:invisible => "btn-invisible",
|
16
|
+
LINK_SCHEME => "btn-link"
|
12
17
|
}.freeze
|
13
|
-
|
18
|
+
SCHEME_OPTIONS = SCHEME_MAPPINGS.keys
|
14
19
|
|
15
20
|
DEFAULT_VARIANT = :medium
|
16
21
|
VARIANT_MAPPINGS = {
|
@@ -26,44 +31,54 @@ module Primer
|
|
26
31
|
DEFAULT_TYPE = :button
|
27
32
|
TYPE_OPTIONS = [DEFAULT_TYPE, :reset, :submit].freeze
|
28
33
|
|
29
|
-
# @example
|
34
|
+
# @example Schemes
|
30
35
|
# <%= render(Primer::ButtonComponent.new) { "Default" } %>
|
31
|
-
# <%= render(Primer::ButtonComponent.new(
|
32
|
-
# <%= render(Primer::ButtonComponent.new(
|
33
|
-
# <%= render(Primer::ButtonComponent.new(
|
36
|
+
# <%= render(Primer::ButtonComponent.new(scheme: :primary)) { "Primary" } %>
|
37
|
+
# <%= render(Primer::ButtonComponent.new(scheme: :danger)) { "Danger" } %>
|
38
|
+
# <%= render(Primer::ButtonComponent.new(scheme: :outline)) { "Outline" } %>
|
39
|
+
# <%= render(Primer::ButtonComponent.new(scheme: :invisible)) { "Invisible" } %>
|
40
|
+
# <%= render(Primer::ButtonComponent.new(scheme: :link)) { "Link" } %>
|
34
41
|
#
|
35
42
|
# @example Variants
|
36
43
|
# <%= render(Primer::ButtonComponent.new(variant: :small)) { "Small" } %>
|
37
44
|
# <%= render(Primer::ButtonComponent.new(variant: :medium)) { "Medium" } %>
|
38
45
|
# <%= render(Primer::ButtonComponent.new(variant: :large)) { "Large" } %>
|
39
46
|
#
|
40
|
-
# @
|
47
|
+
# @example Block
|
48
|
+
# <%= render(Primer::ButtonComponent.new(block: :true)) { "Block" } %>
|
49
|
+
# <%= render(Primer::ButtonComponent.new(block: :true, scheme: :primary)) { "Primary block" } %>
|
50
|
+
#
|
51
|
+
# @param scheme [Symbol] <%= one_of(Primer::ButtonComponent::SCHEME_OPTIONS) %>
|
41
52
|
# @param variant [Symbol] <%= one_of(Primer::ButtonComponent::VARIANT_OPTIONS) %>
|
42
53
|
# @param tag [Symbol] <%= one_of(Primer::ButtonComponent::TAG_OPTIONS) %>
|
43
54
|
# @param type [Symbol] <%= one_of(Primer::ButtonComponent::TYPE_OPTIONS) %>
|
44
55
|
# @param group_item [Boolean] Whether button is part of a ButtonGroup.
|
56
|
+
# @param block [Boolean] Whether button is full-width with `display: block`.
|
45
57
|
def initialize(
|
46
|
-
|
58
|
+
scheme: DEFAULT_SCHEME,
|
47
59
|
variant: DEFAULT_VARIANT,
|
48
60
|
tag: DEFAULT_TAG,
|
49
61
|
type: DEFAULT_TYPE,
|
50
62
|
group_item: false,
|
63
|
+
block: false,
|
51
64
|
**system_arguments
|
52
65
|
)
|
66
|
+
@scheme = scheme
|
53
67
|
@system_arguments = system_arguments
|
54
68
|
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
55
69
|
|
56
|
-
if @system_arguments[:tag] == :
|
57
|
-
@system_arguments[:role] = :button
|
58
|
-
else
|
70
|
+
if @system_arguments[:tag] == :button
|
59
71
|
@system_arguments[:type] = type
|
72
|
+
else
|
73
|
+
@system_arguments[:role] = :button
|
60
74
|
end
|
61
75
|
|
62
76
|
@system_arguments[:classes] = class_names(
|
63
|
-
"btn",
|
64
77
|
system_arguments[:classes],
|
65
|
-
|
78
|
+
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)],
|
66
79
|
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
|
80
|
+
"btn" => !link?,
|
81
|
+
"btn-block" => block,
|
67
82
|
"BtnGroup-item" => group_item
|
68
83
|
)
|
69
84
|
end
|
@@ -71,5 +86,11 @@ module Primer
|
|
71
86
|
def call
|
72
87
|
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
73
88
|
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def link?
|
93
|
+
@scheme == LINK_SCHEME
|
94
|
+
end
|
74
95
|
end
|
75
96
|
end
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use ButtonGroupComponent to render a series of buttons.
|
5
5
|
class ButtonGroupComponent < Primer::Component
|
6
|
-
include ViewComponent::SlotableV2
|
7
|
-
|
8
6
|
# Required list of buttons to be rendered.
|
9
7
|
#
|
10
8
|
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::ButtonComponent) %>.
|
@@ -13,9 +11,9 @@ module Primer
|
|
13
11
|
# @example Default
|
14
12
|
# <%= render(Primer::ButtonGroupComponent.new) do |component|
|
15
13
|
# component.button { "Default" }
|
16
|
-
# component.button(
|
17
|
-
# component.button(
|
18
|
-
# component.button(
|
14
|
+
# component.button(scheme: :primary) { "Primary" }
|
15
|
+
# component.button(scheme: :danger) { "Danger" }
|
16
|
+
# component.button(scheme: :outline) { "Outline" }
|
19
17
|
# component.button(classes: "my-class") { "Custom class" }
|
20
18
|
# end %>
|
21
19
|
#
|
@@ -3,14 +3,14 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use buttons for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
|
5
5
|
class ButtonMarketingComponent < Primer::Component
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
DEFAULT_SCHEME = :default
|
7
|
+
SCHEME_MAPPINGS = {
|
8
|
+
DEFAULT_SCHEME => "",
|
9
9
|
:primary => "btn-primary-mktg",
|
10
10
|
:outline => "btn-outline-mktg",
|
11
11
|
:transparent => "btn-transparent"
|
12
12
|
}.freeze
|
13
|
-
|
13
|
+
SCHEME_OPTIONS = SCHEME_MAPPINGS.keys
|
14
14
|
|
15
15
|
DEFAULT_VARIANT = :default
|
16
16
|
VARIANT_MAPPINGS = {
|
@@ -25,25 +25,25 @@ module Primer
|
|
25
25
|
DEFAULT_TYPE = :button
|
26
26
|
TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze
|
27
27
|
|
28
|
-
# @example
|
28
|
+
# @example Schemes
|
29
29
|
# <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
|
30
|
-
# <%= render(Primer::ButtonMarketingComponent.new(
|
31
|
-
# <%= render(Primer::ButtonMarketingComponent.new(
|
32
|
-
# <div class="bg-
|
33
|
-
# <%= render(Primer::ButtonMarketingComponent.new(
|
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
34
|
# </div>
|
35
35
|
#
|
36
36
|
# @example Sizes
|
37
37
|
# <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
|
38
38
|
# <%= render(Primer::ButtonMarketingComponent.new(variant: :large)) { "Large" } %>
|
39
39
|
#
|
40
|
-
# @param
|
40
|
+
# @param scheme [Symbol] <%= one_of(Primer::ButtonMarketingComponent::SCHEME_OPTIONS) %>
|
41
41
|
# @param variant [Symbol] <%= one_of(Primer::ButtonMarketingComponent::VARIANT_OPTIONS) %>
|
42
42
|
# @param tag [Symbol] <%= one_of(Primer::ButtonMarketingComponent::TAG_OPTIONS) %>
|
43
43
|
# @param type [Symbol] <%= one_of(Primer::ButtonMarketingComponent::TYPE_OPTIONS) %>
|
44
44
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
45
45
|
def initialize(
|
46
|
-
|
46
|
+
scheme: DEFAULT_SCHEME,
|
47
47
|
variant: DEFAULT_VARIANT,
|
48
48
|
tag: DEFAULT_TAG,
|
49
49
|
type: DEFAULT_TYPE,
|
@@ -60,7 +60,7 @@ module Primer
|
|
60
60
|
|
61
61
|
@system_arguments[:classes] = class_names(
|
62
62
|
"btn-mktg",
|
63
|
-
|
63
|
+
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)],
|
64
64
|
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
|
65
65
|
system_arguments[:classes]
|
66
66
|
)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
# Use CloseButton to render an `×` without default button styles.
|
5
|
+
class CloseButton < Primer::Component
|
6
|
+
DEFAULT_TYPE = :button
|
7
|
+
TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze
|
8
|
+
|
9
|
+
# @example Default
|
10
|
+
# <%= render(Primer::CloseButton.new) %>
|
11
|
+
#
|
12
|
+
# @param type [Symbol] <%= one_of(Primer::CloseButton::TYPE_OPTIONS) %>
|
13
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
14
|
+
def initialize(type: DEFAULT_TYPE, **system_arguments)
|
15
|
+
@system_arguments = system_arguments
|
16
|
+
@system_arguments[:tag] = :button
|
17
|
+
@system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
|
18
|
+
@system_arguments[:classes] = class_names(
|
19
|
+
"close-button",
|
20
|
+
system_arguments[:classes]
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def call
|
25
|
+
render(Primer::BaseComponent.new(**@system_arguments)) do
|
26
|
+
render(Primer::OcticonComponent.new("x"))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,13 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "octicons_helper/helper"
|
4
|
+
require "view_component/version"
|
4
5
|
|
5
6
|
module Primer
|
6
7
|
# @private
|
7
8
|
class Component < ViewComponent::Base
|
9
|
+
include ViewComponent::SlotableV2 unless ViewComponent::VERSION::STRING.to_f >= 2.28
|
8
10
|
include ClassNameHelper
|
9
11
|
include FetchOrFallbackHelper
|
10
12
|
include OcticonsHelper
|
13
|
+
include TestSelectorHelper
|
11
14
|
include JoinStyleArgumentsHelper
|
12
15
|
include ViewHelper
|
13
16
|
include Status::Dsl
|
@@ -5,8 +5,6 @@ module Primer
|
|
5
5
|
# This component is part of `Primer::DropdownComponent` and should not be
|
6
6
|
# used as a standalone component.
|
7
7
|
class MenuComponent < Primer::Component
|
8
|
-
include ViewComponent::SlotableV2
|
9
|
-
|
10
8
|
SCHEME_DEFAULT = :default
|
11
9
|
SCHEME_MAPPINGS = {
|
12
10
|
SCHEME_DEFAULT => "",
|
@@ -4,8 +4,6 @@ module Primer
|
|
4
4
|
# Dropdowns are lightweight context menus for housing navigation and actions.
|
5
5
|
# They're great for instances where you don't need the full power (and code) of the select menu.
|
6
6
|
class DropdownComponent < Primer::Component
|
7
|
-
include ViewComponent::SlotableV2
|
8
|
-
|
9
7
|
# Required trigger for the dropdown. Only accepts a content.
|
10
8
|
# Its classes can be customized by the `summary_classes` param in the parent component
|
11
9
|
renders_one :button
|
@@ -13,7 +11,7 @@ module Primer
|
|
13
11
|
# Required context menu for the dropdown
|
14
12
|
#
|
15
13
|
# @param direction [Symbol] <%= one_of(Primer::Dropdown::MenuComponent::DIRECTION_OPTIONS) %>
|
16
|
-
# @param scheme [Symbol] Pass
|
14
|
+
# @param scheme [Symbol] Pass `:dark` for dark mode theming
|
17
15
|
# @param header [String] Optional string to display as the header
|
18
16
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
19
17
|
renders_one :menu, Primer::Dropdown::MenuComponent
|
@@ -36,7 +36,7 @@ module Primer
|
|
36
36
|
# </div>
|
37
37
|
#
|
38
38
|
# @param direction [Symbol] <%= one_of(Primer::DropdownMenuComponent::DIRECTION_OPTIONS) %>
|
39
|
-
# @param scheme [Symbol] Pass
|
39
|
+
# @param scheme [Symbol] Pass `:dark` for dark mode theming
|
40
40
|
# @param header [String] Optional string to display as the header
|
41
41
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
42
42
|
def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
2
|
-
<%= primer_octicon
|
2
|
+
<%= primer_octicon @icon if @icon %>
|
3
3
|
<%= content %>
|
4
4
|
<% if @dismissible %>
|
5
5
|
<button class="flash-close js-flash-close" type="button" aria-label="Close">
|
6
|
-
<%= primer_octicon
|
6
|
+
<%= primer_octicon "x" %>
|
7
7
|
</button>
|
8
8
|
<% end %>
|
9
9
|
|
@@ -5,8 +5,6 @@ module Primer
|
|
5
5
|
class FlashComponent < Primer::Component
|
6
6
|
status :beta
|
7
7
|
|
8
|
-
include ViewComponent::SlotableV2
|
9
|
-
|
10
8
|
# Optional action content showed on the right side of the component.
|
11
9
|
#
|
12
10
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
@@ -17,18 +15,18 @@ module Primer
|
|
17
15
|
Primer::BaseComponent.new(**system_arguments)
|
18
16
|
}
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
DEFAULT_SCHEME = :default
|
19
|
+
SCHEME_MAPPINGS = {
|
20
|
+
DEFAULT_SCHEME => "",
|
23
21
|
:warning => "flash-warn",
|
24
22
|
:danger => "flash-error",
|
25
23
|
:success => "flash-success"
|
26
24
|
}.freeze
|
27
|
-
# @example
|
25
|
+
# @example Schemes
|
28
26
|
# <%= render(Primer::FlashComponent.new) { "This is a flash message!" } %>
|
29
|
-
# <%= render(Primer::FlashComponent.new(
|
30
|
-
# <%= render(Primer::FlashComponent.new(
|
31
|
-
# <%= render(Primer::FlashComponent.new(
|
27
|
+
# <%= render(Primer::FlashComponent.new(scheme: :warning)) { "This is a warning flash message!" } %>
|
28
|
+
# <%= render(Primer::FlashComponent.new(scheme: :danger)) { "This is a danger flash message!" } %>
|
29
|
+
# <%= render(Primer::FlashComponent.new(scheme: :success)) { "This is a success flash message!" } %>
|
32
30
|
#
|
33
31
|
# @example Full width
|
34
32
|
# <%= render(Primer::FlashComponent.new(full: true)) { "This is a full width flash message!" } %>
|
@@ -51,9 +49,9 @@ module Primer
|
|
51
49
|
# @param spacious [Boolean] Whether to add margin to the bottom of the component.
|
52
50
|
# @param dismissible [Boolean] Whether the component can be dismissed with an X button.
|
53
51
|
# @param icon [String] Name of Octicon icon to use.
|
54
|
-
# @param
|
52
|
+
# @param scheme [Symbol] <%= one_of(Primer::FlashComponent::SCHEME_MAPPINGS.keys) %>
|
55
53
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
56
|
-
def initialize(full: false, spacious: false, dismissible: false, icon: nil,
|
54
|
+
def initialize(full: false, spacious: false, dismissible: false, icon: nil, scheme: DEFAULT_SCHEME, **system_arguments)
|
57
55
|
@icon = icon
|
58
56
|
@dismissible = dismissible
|
59
57
|
@system_arguments = system_arguments
|
@@ -61,7 +59,7 @@ module Primer
|
|
61
59
|
@system_arguments[:classes] = class_names(
|
62
60
|
@system_arguments[:classes],
|
63
61
|
"flash",
|
64
|
-
|
62
|
+
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)],
|
65
63
|
"flash-full": full
|
66
64
|
)
|
67
65
|
@system_arguments[:mb] ||= spacious ? 4 : nil
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@github/details-menu-element';
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@github/details-menu-element';
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
# Use HiddenTextExpander to indicate and toggle hidden text.
|
5
|
+
class HiddenTextExpander < Primer::Component
|
6
|
+
# @example Default
|
7
|
+
# <%= render(Primer::HiddenTextExpander.new) %>
|
8
|
+
#
|
9
|
+
# @example Inline
|
10
|
+
# <%= render(Primer::HiddenTextExpander.new(inline: true)) %>
|
11
|
+
#
|
12
|
+
# @example Styling the button
|
13
|
+
# <%= render(Primer::HiddenTextExpander.new(button_arguments: { p: 1, classes: "my-custom-class" })) %>
|
14
|
+
#
|
15
|
+
# @param inline [Boolean] Whether or not the expander is inline.
|
16
|
+
# @param button_arguments [Hash] <%= link_to_system_arguments_docs %> for the button element.
|
17
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
18
|
+
def initialize(inline: false, button_arguments: {}, **system_arguments)
|
19
|
+
@system_arguments = system_arguments
|
20
|
+
@system_arguments[:tag] ||= :span
|
21
|
+
@system_arguments[:classes] = class_names(
|
22
|
+
"hidden-text-expander",
|
23
|
+
@system_arguments[:classes],
|
24
|
+
"inline" => inline
|
25
|
+
)
|
26
|
+
|
27
|
+
@button_arguments = button_arguments
|
28
|
+
@button_arguments[:tag] = :button
|
29
|
+
@button_arguments[:type] = :button
|
30
|
+
@button_arguments[:"aria-expanded"] = false
|
31
|
+
@button_arguments[:classes] = class_names(
|
32
|
+
"ellipsis-expander",
|
33
|
+
button_arguments[:classes]
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def call
|
38
|
+
render(Primer::BaseComponent.new(**@system_arguments)) do
|
39
|
+
render(Primer::BaseComponent.new(**@button_arguments)) { "…" }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|