primer_view_components 0.0.36 → 0.0.41
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 +220 -24
- 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/auto_complete.rb +3 -1
- data/app/components/primer/auto_complete/item.rb +1 -1
- data/app/components/primer/avatar_component.rb +22 -3
- data/app/components/primer/avatar_stack_component.rb +8 -5
- data/app/components/primer/base_button.rb +47 -0
- data/app/components/primer/base_component.rb +14 -10
- data/app/components/primer/blankslate_component.rb +10 -7
- data/app/components/primer/border_box_component.rb +1 -1
- data/app/components/primer/box_component.rb +1 -1
- data/app/components/primer/breadcrumb_component.rb +1 -1
- data/app/components/primer/button_component.html.erb +9 -0
- data/app/components/primer/button_component.rb +39 -21
- data/app/components/primer/{button_group_component.html.erb → button_group.html.erb} +0 -0
- data/app/components/primer/button_group.rb +61 -0
- data/app/components/primer/button_marketing_component.rb +4 -9
- data/app/components/primer/clipboard_copy.html.erb +8 -0
- data/app/components/primer/clipboard_copy.rb +26 -0
- data/app/components/primer/clipboard_copy_component.d.ts +1 -0
- data/app/components/primer/clipboard_copy_component.js +34 -0
- data/app/components/primer/clipboard_copy_component.ts +39 -0
- data/app/components/primer/close_button.rb +11 -2
- data/app/components/primer/component.rb +21 -2
- data/app/components/primer/counter_component.rb +6 -1
- data/app/components/primer/details_component.rb +1 -1
- data/app/components/primer/dropdown/menu_component.rb +1 -1
- data/app/components/primer/dropdown_component.rb +1 -1
- data/app/components/primer/flash_component.rb +3 -3
- data/app/components/primer/flex_component.rb +28 -1
- data/app/components/primer/flex_item_component.rb +20 -1
- data/app/components/primer/heading_component.rb +25 -4
- data/app/components/primer/hidden_text_expander.rb +2 -4
- data/app/components/primer/icon_button.rb +65 -0
- 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 +7 -3
- data/app/components/primer/layout_component.rb +1 -1
- data/app/components/primer/link_component.rb +1 -1
- 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} +6 -5
- data/app/components/primer/menu_component.rb +1 -1
- data/app/components/primer/navigation/tab_component.rb +8 -1
- data/app/components/primer/octicon_component.html.erb +7 -0
- data/app/components/primer/octicon_component.rb +53 -19
- 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/popover_component.rb +1 -1
- 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/progress_bar_component.rb +1 -1
- data/app/components/primer/spinner_component.rb +3 -3
- data/app/components/primer/state_component.rb +2 -2
- data/app/components/primer/subhead_component.rb +34 -4
- data/app/components/primer/tab_container_component.rb +1 -1
- data/app/components/primer/tab_nav_component.html.erb +2 -0
- data/app/components/primer/tab_nav_component.rb +23 -10
- data/app/components/primer/text_component.rb +6 -3
- data/app/components/primer/time_ago_component.rb +1 -1
- data/app/components/primer/timeline_item_component.rb +1 -1
- data/app/components/primer/{tooltip_component.rb → tooltip.rb} +11 -9
- data/app/components/primer/truncate.rb +1 -1
- data/app/components/primer/underline_nav_component.rb +1 -1
- data/app/lib/primer/classify.rb +11 -36
- data/app/lib/primer/classify/cache.rb +20 -15
- data/app/lib/primer/classify/flex.rb +111 -0
- data/app/lib/primer/classify/functional_border_colors.rb +1 -2
- data/app/lib/primer/fetch_or_fallback_helper.rb +2 -2
- data/app/lib/primer/octicon/cache.rb +42 -0
- data/app/lib/primer/view_helper.rb +2 -1
- data/lib/primer/view_components.rb +1 -1
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/coverage.rake +14 -0
- data/lib/tasks/docs.rake +315 -0
- data/lib/tasks/statuses.rake +12 -0
- data/lib/yard/docs_helper.rb +57 -0
- data/static/statuses.json +54 -1
- metadata +50 -11
- data/app/components/primer/button_group_component.rb +0 -35
- data/app/components/primer/foo_bar.d.ts +0 -1
- data/app/components/primer/foo_bar.js +0 -1
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
# Use `BaseButton` to render an unstyled `<button>` tag that can be customized.
|
5
|
+
class BaseButton < Primer::Component
|
6
|
+
status :beta
|
7
|
+
|
8
|
+
DEFAULT_TAG = :button
|
9
|
+
TAG_OPTIONS = [DEFAULT_TAG, :a, :summary].freeze
|
10
|
+
|
11
|
+
DEFAULT_TYPE = :button
|
12
|
+
TYPE_OPTIONS = [DEFAULT_TYPE, :reset, :submit].freeze
|
13
|
+
|
14
|
+
# @example Block
|
15
|
+
# <%= render(Primer::BaseButton.new(block: :true)) { "Block" } %>
|
16
|
+
# <%= render(Primer::BaseButton.new(block: :true, scheme: :primary)) { "Primary block" } %>
|
17
|
+
#
|
18
|
+
# @param tag [Symbol] <%= one_of(Primer::BaseButton::TAG_OPTIONS) %>
|
19
|
+
# @param type [Symbol] <%= one_of(Primer::BaseButton::TYPE_OPTIONS) %>
|
20
|
+
# @param block [Boolean] Whether button is full-width with `display: block`.
|
21
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
22
|
+
def initialize(
|
23
|
+
tag: DEFAULT_TAG,
|
24
|
+
type: DEFAULT_TYPE,
|
25
|
+
block: false,
|
26
|
+
**system_arguments
|
27
|
+
)
|
28
|
+
@system_arguments = system_arguments
|
29
|
+
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
30
|
+
|
31
|
+
if @system_arguments[:tag] == :button
|
32
|
+
@system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
|
33
|
+
else
|
34
|
+
@system_arguments[:role] = :button
|
35
|
+
end
|
36
|
+
|
37
|
+
@system_arguments[:classes] = class_names(
|
38
|
+
system_arguments[:classes],
|
39
|
+
"btn-block" => block
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def call
|
44
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -69,13 +69,15 @@ module Primer
|
|
69
69
|
#
|
70
70
|
# | Name | Type | Description |
|
71
71
|
# | :- | :- | :- |
|
72
|
-
# | `align_items` | Symbol | <%= one_of(
|
73
|
-
# | `align_self` | Symbol | <%= one_of(
|
72
|
+
# | `align_items` | Symbol | <%= one_of(Primer::Classify::Flex::ALIGN_ITEMS_VALUES) %> |
|
73
|
+
# | `align_self` | Symbol | <%= one_of(Primer::Classify::Flex::ALIGN_SELF_VALUES) %> |
|
74
|
+
# | `direction` | Symbol | <%= one_of(Primer::Classify::Flex::DIRECTION_VALUES) %> |
|
75
|
+
# | `flex` | Integer, Symbol | <%= one_of(Primer::Classify::Flex::FLEX_VALUES) %> |
|
74
76
|
# | `flex_grow` | Integer | To enable, set to `0`. |
|
75
77
|
# | `flex_shrink` | Integer | To enable, set to `0`. |
|
76
|
-
# | `
|
77
|
-
# | `justify_content` | Symbol | <%= one_of(
|
78
|
-
# | `width` | Symbol | <%= one_of([:fit
|
78
|
+
# | `flex_wrap` | Symbol | <%= one_of(Primer::Classify::Flex::WRAP_MAPPINGS.keys) %> |
|
79
|
+
# | `justify_content` | Symbol | <%= one_of(Primer::Classify::Flex::JUSTIFY_CONTENT_VALUES) %> |
|
80
|
+
# | `width` | Symbol | <%= one_of([:fit]) %> |
|
79
81
|
#
|
80
82
|
# ## Grid
|
81
83
|
#
|
@@ -87,8 +89,8 @@ module Primer
|
|
87
89
|
#
|
88
90
|
# | Name | Type | Description |
|
89
91
|
# | :- | :- | :- |
|
90
|
-
# | `display` | Symbol | <%= one_of([:none, :block, :flex, :inline, :inline_block, :table, :table_cell]) %> |
|
91
|
-
# | `height` | Symbol | <%= one_of([:fit
|
92
|
+
# | `display` | Symbol | <%= one_of([:none, :block, :flex, :inline, :inline_block, :inline_flex, :table, :table_cell]) %> |
|
93
|
+
# | `height` | Symbol | <%= one_of([:fit]) %> |
|
92
94
|
# | `hide` | Symbol | Hide the element at a specific breakpoint. <%= one_of([:sm, :md, :lg, :xl]) %> |
|
93
95
|
# | `v` | Symbol | Visibility. <%= one_of([:hidden, :visible]) %> |
|
94
96
|
# | `vertical_align` | Symbol | <%= one_of([:baseline, :top, :middle, :bottom, :text_top, :text_bottom]) %> |
|
@@ -138,14 +140,16 @@ module Primer
|
|
138
140
|
# | Name | Type | Description |
|
139
141
|
# | :- | :- | :- |
|
140
142
|
# | classes | String | CSS class name value to be concatenated with generated Primer CSS classes. |
|
141
|
-
# | tag | Symbol | HTML tag name to be passed to `content_tag`. |
|
142
143
|
# | test_selector | String | Adds `data-test-selector='given value'` in non-Production environments for testing purposes. |
|
143
144
|
def initialize(tag:, classes: nil, **system_arguments)
|
144
145
|
@tag = tag
|
145
|
-
@
|
146
|
+
@system_arguments = system_arguments
|
146
147
|
|
148
|
+
@result = Primer::Classify.call(**@system_arguments.merge(classes: classes))
|
149
|
+
|
150
|
+
@system_arguments[:"data-view-component"] = true
|
147
151
|
# Filter out Primer keys so they don't get assigned as HTML attributes
|
148
|
-
@content_tag_args = add_test_selector(system_arguments).except(*Primer::Classify::VALID_KEYS)
|
152
|
+
@content_tag_args = add_test_selector(@system_arguments).except(*Primer::Classify::VALID_KEYS)
|
149
153
|
end
|
150
154
|
|
151
155
|
def call
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
# Use
|
4
|
+
# Use `Blankslate` when there is a lack of content within a page or section. Use as placeholder to tell users why something isn't there.
|
5
|
+
# @accessibility
|
6
|
+
# `Blankslate` renders an `<h3>` element for the title by default. Update the heading level based on what is appropriate for your page hierarchy by setting `title_tag`.
|
7
|
+
# <%= link_to_heading_practices %>
|
5
8
|
class BlankslateComponent < Primer::Component
|
6
9
|
status :beta
|
7
10
|
|
@@ -22,7 +25,7 @@ module Primer
|
|
22
25
|
#
|
23
26
|
# @example Icon|Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
|
24
27
|
# <%= render Primer::BlankslateComponent.new(
|
25
|
-
# icon:
|
28
|
+
# icon: :globe,
|
26
29
|
# title: "Title",
|
27
30
|
# description: "Description",
|
28
31
|
# ) %>
|
@@ -44,7 +47,7 @@ module Primer
|
|
44
47
|
#
|
45
48
|
# @example Action button|Provide a button to guide users to take action from the blankslate. The button appears below the description and custom content.
|
46
49
|
# <%= render Primer::BlankslateComponent.new(
|
47
|
-
# icon:
|
50
|
+
# icon: :book,
|
48
51
|
# title: "Welcome to the mona wiki!",
|
49
52
|
# description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
|
50
53
|
#
|
@@ -54,7 +57,7 @@ module Primer
|
|
54
57
|
#
|
55
58
|
# @example Link|Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
|
56
59
|
# <%= render Primer::BlankslateComponent.new(
|
57
|
-
# icon:
|
60
|
+
# icon: :book,
|
58
61
|
# title: "Welcome to the mona wiki!",
|
59
62
|
# description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
|
60
63
|
# link_text: "Learn more about wikis",
|
@@ -63,7 +66,7 @@ module Primer
|
|
63
66
|
#
|
64
67
|
# @example Variations|There are a few variations of how the Blankslate appears: `narrow` adds a maximum width, `large` increases the font size, and `spacious` adds extra padding.
|
65
68
|
# <%= render Primer::BlankslateComponent.new(
|
66
|
-
# icon:
|
69
|
+
# icon: :book,
|
67
70
|
# title: "Welcome to the mona wiki!",
|
68
71
|
# description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
|
69
72
|
# narrow: true,
|
@@ -73,7 +76,7 @@ module Primer
|
|
73
76
|
#
|
74
77
|
# @param title [String] Text that appears in a larger bold font.
|
75
78
|
# @param title_tag [Symbol] HTML tag to use for title.
|
76
|
-
# @param icon [
|
79
|
+
# @param icon [Symbol] Octicon icon to use at top of component.
|
77
80
|
# @param icon_size [Symbol] <%= one_of(Primer::OcticonComponent::SIZE_MAPPINGS) %>
|
78
81
|
# @param image_src [String] Image to display.
|
79
82
|
# @param image_alt [String] Alt text for image.
|
@@ -108,7 +111,7 @@ module Primer
|
|
108
111
|
**system_arguments
|
109
112
|
)
|
110
113
|
@system_arguments = system_arguments
|
111
|
-
@system_arguments[:tag]
|
114
|
+
@system_arguments[:tag] = :div
|
112
115
|
@system_arguments[:classes] = class_names(
|
113
116
|
@system_arguments[:classes],
|
114
117
|
"blankslate",
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
# Use
|
4
|
+
# Use `Breadcrumb` to display page hierarchy within a section of the site. All of the items in the breadcrumb "trail" are links except for the final item, which is a plain string indicating the current page.
|
5
5
|
class BreadcrumbComponent < Primer::Component
|
6
6
|
status :beta
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
# Use
|
4
|
+
# Use `Button` for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
|
5
5
|
class ButtonComponent < Primer::Component
|
6
6
|
status :beta
|
7
7
|
|
@@ -25,11 +25,15 @@ module Primer
|
|
25
25
|
}.freeze
|
26
26
|
VARIANT_OPTIONS = VARIANT_MAPPINGS.keys
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
# Icon to be rendered in the button.
|
29
|
+
#
|
30
|
+
# @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
|
31
|
+
renders_one :icon, Primer::OcticonComponent
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
# Counter to be rendered in the button.
|
34
|
+
#
|
35
|
+
# @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::CounterComponent) %>.
|
36
|
+
renders_one :counter, Primer::CounterComponent
|
33
37
|
|
34
38
|
# @example Schemes
|
35
39
|
# <%= render(Primer::ButtonComponent.new) { "Default" } %>
|
@@ -48,31 +52,49 @@ module Primer
|
|
48
52
|
# <%= render(Primer::ButtonComponent.new(block: :true)) { "Block" } %>
|
49
53
|
# <%= render(Primer::ButtonComponent.new(block: :true, scheme: :primary)) { "Primary block" } %>
|
50
54
|
#
|
55
|
+
# @example With icons
|
56
|
+
# <%= render(Primer::ButtonComponent.new) do |c| %>
|
57
|
+
# <% c.icon(icon: :star) %>
|
58
|
+
# Button
|
59
|
+
# <% end %>
|
60
|
+
#
|
61
|
+
# @example With counter
|
62
|
+
# <%= render(Primer::ButtonComponent.new) do |c| %>
|
63
|
+
# <% c.counter(count: 15) %>
|
64
|
+
# Button
|
65
|
+
# <% end %>
|
66
|
+
#
|
67
|
+
# @example With icons and counter
|
68
|
+
# <%= render(Primer::ButtonComponent.new) do |c| %>
|
69
|
+
# <% c.icon(icon: :star) %>
|
70
|
+
# <% c.counter(count: 15) %>
|
71
|
+
# Button
|
72
|
+
# <% end %>
|
73
|
+
#
|
74
|
+
# @example With caret
|
75
|
+
# <%= render(Primer::ButtonComponent.new(caret: true)) do %>
|
76
|
+
# Button
|
77
|
+
# <% end %>
|
78
|
+
#
|
51
79
|
# @param scheme [Symbol] <%= one_of(Primer::ButtonComponent::SCHEME_OPTIONS) %>
|
52
80
|
# @param variant [Symbol] <%= one_of(Primer::ButtonComponent::VARIANT_OPTIONS) %>
|
53
|
-
# @param tag [Symbol] <%= one_of(Primer::
|
54
|
-
# @param type [Symbol] <%= one_of(Primer::
|
81
|
+
# @param tag [Symbol] <%= one_of(Primer::BaseButton::TAG_OPTIONS) %>
|
82
|
+
# @param type [Symbol] <%= one_of(Primer::BaseButton::TYPE_OPTIONS) %>
|
55
83
|
# @param group_item [Boolean] Whether button is part of a ButtonGroup.
|
56
84
|
# @param block [Boolean] Whether button is full-width with `display: block`.
|
85
|
+
# @param caret [Boolean] Whether or not to render a caret.
|
57
86
|
def initialize(
|
58
87
|
scheme: DEFAULT_SCHEME,
|
59
88
|
variant: DEFAULT_VARIANT,
|
60
|
-
tag: DEFAULT_TAG,
|
61
|
-
type: DEFAULT_TYPE,
|
62
89
|
group_item: false,
|
63
90
|
block: false,
|
91
|
+
caret: false,
|
64
92
|
**system_arguments
|
65
93
|
)
|
66
94
|
@scheme = scheme
|
67
|
-
@
|
68
|
-
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
69
|
-
|
70
|
-
if @system_arguments[:tag] == :button
|
71
|
-
@system_arguments[:type] = type
|
72
|
-
else
|
73
|
-
@system_arguments[:role] = :button
|
74
|
-
end
|
95
|
+
@caret = caret
|
75
96
|
|
97
|
+
@system_arguments = system_arguments
|
76
98
|
@system_arguments[:classes] = class_names(
|
77
99
|
system_arguments[:classes],
|
78
100
|
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)],
|
@@ -83,10 +105,6 @@ module Primer
|
|
83
105
|
)
|
84
106
|
end
|
85
107
|
|
86
|
-
def call
|
87
|
-
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
88
|
-
end
|
89
|
-
|
90
108
|
private
|
91
109
|
|
92
110
|
def link?
|
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
# Use `ButtonGroup` to render a series of buttons.
|
5
|
+
class ButtonGroup < Primer::Component
|
6
|
+
status :beta
|
7
|
+
|
8
|
+
# Required list of buttons to be rendered.
|
9
|
+
#
|
10
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::ButtonComponent) %> except for `variant` and `group_item`.
|
11
|
+
renders_many :buttons, lambda { |**kwargs|
|
12
|
+
kwargs[:group_item] = true
|
13
|
+
kwargs[:variant] = @variant
|
14
|
+
|
15
|
+
Primer::ButtonComponent.new(**kwargs)
|
16
|
+
}
|
17
|
+
|
18
|
+
# @example Default
|
19
|
+
#
|
20
|
+
# <%= render(Primer::ButtonGroup.new) do |component| %>
|
21
|
+
# <% component.button { "Default" } %>
|
22
|
+
# <% component.button(scheme: :primary) { "Primary" } %>
|
23
|
+
# <% component.button(scheme: :danger) { "Danger" } %>
|
24
|
+
# <% component.button(scheme: :outline) { "Outline" } %>
|
25
|
+
# <% component.button(classes: "my-class") { "Custom class" } %>
|
26
|
+
# <% end %>
|
27
|
+
#
|
28
|
+
# @example Variants
|
29
|
+
#
|
30
|
+
# <%= render(Primer::ButtonGroup.new(variant: :small)) do |component| %>
|
31
|
+
# <% component.button { "Default" } %>
|
32
|
+
# <% component.button(scheme: :primary) { "Primary" } %>
|
33
|
+
# <% component.button(scheme: :danger) { "Danger" } %>
|
34
|
+
# <% component.button(scheme: :outline) { "Outline" } %>
|
35
|
+
# <% end %>
|
36
|
+
#
|
37
|
+
# <%= render(Primer::ButtonGroup.new(variant: :large)) do |component| %>
|
38
|
+
# <% component.button { "Default" } %>
|
39
|
+
# <% component.button(scheme: :primary) { "Primary" } %>
|
40
|
+
# <% component.button(scheme: :danger) { "Danger" } %>
|
41
|
+
# <% component.button(scheme: :outline) { "Outline" } %>
|
42
|
+
# <% end %>
|
43
|
+
#
|
44
|
+
# @param variant [Symbol] <%= one_of(Primer::ButtonComponent::VARIANT_OPTIONS) %>
|
45
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
46
|
+
def initialize(variant: Primer::ButtonComponent::DEFAULT_VARIANT, **system_arguments)
|
47
|
+
@variant = variant
|
48
|
+
@system_arguments = system_arguments
|
49
|
+
@system_arguments[:tag] = :div
|
50
|
+
|
51
|
+
@system_arguments[:classes] = class_names(
|
52
|
+
"BtnGroup",
|
53
|
+
system_arguments[:classes]
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def render?
|
58
|
+
buttons.any?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
# Use
|
4
|
+
# Use `ButtonMarketing` for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
|
5
5
|
class ButtonMarketingComponent < Primer::Component
|
6
6
|
DEFAULT_SCHEME = :default
|
7
7
|
SCHEME_MAPPINGS = {
|
@@ -50,14 +50,9 @@ module Primer
|
|
50
50
|
**system_arguments
|
51
51
|
)
|
52
52
|
@system_arguments = system_arguments
|
53
|
+
@system_arguments[:block] = false
|
53
54
|
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
54
|
-
|
55
|
-
if @system_arguments[:tag] == :a
|
56
|
-
@system_arguments[:role] = :button
|
57
|
-
else
|
58
|
-
@system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
|
59
|
-
end
|
60
|
-
|
55
|
+
@system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
|
61
56
|
@system_arguments[:classes] = class_names(
|
62
57
|
"btn-mktg",
|
63
58
|
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)],
|
@@ -67,7 +62,7 @@ module Primer
|
|
67
62
|
end
|
68
63
|
|
69
64
|
def call
|
70
|
-
render(Primer::
|
65
|
+
render(Primer::BaseButton.new(**@system_arguments)) { content }
|
71
66
|
end
|
72
67
|
end
|
73
68
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
2
|
+
<% if content.present? %>
|
3
|
+
<%= content %>
|
4
|
+
<% else %>
|
5
|
+
<%= render Primer::OcticonComponent.new("clippy") %>
|
6
|
+
<%= render Primer::OcticonComponent.new("check", color: :icon_success, style: "display: none;") %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
# Use `ClipboardCopy` to copy element text content or input values to the clipboard.
|
5
|
+
class ClipboardCopy < Primer::Component
|
6
|
+
status :alpha
|
7
|
+
|
8
|
+
# @example Default
|
9
|
+
# <%= render(Primer::ClipboardCopy.new(value: "Text to copy", label: "Copy text to the system clipboard")) %>
|
10
|
+
#
|
11
|
+
# @example With text instead of icons
|
12
|
+
# <%= render(Primer::ClipboardCopy.new(value: "Text to copy", label: "Copy text to the system clipboard")) do %>
|
13
|
+
# Click to copy!
|
14
|
+
# <% end %>
|
15
|
+
#
|
16
|
+
# @param label [String] String that will be read to screenreaders when the component is focused
|
17
|
+
# @param value [String] Text to copy into the users clipboard when they click the component
|
18
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
19
|
+
def initialize(label:, value:, **system_arguments)
|
20
|
+
@system_arguments = system_arguments
|
21
|
+
@system_arguments[:tag] = "clipboard-copy"
|
22
|
+
@system_arguments[:value] = value
|
23
|
+
@system_arguments[:"aria-label"] = label
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@github/clipboard-copy-element';
|