primer_view_components 0.0.48 → 0.0.52
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 +155 -0
- data/app/components/primer/base_component.rb +2 -2
- data/app/components/primer/beta/avatar.rb +1 -1
- data/app/components/primer/{avatar_stack_component.html.erb → beta/avatar_stack.html.erb} +0 -0
- data/app/components/primer/beta/avatar_stack.rb +92 -0
- data/app/components/primer/beta/truncate.html.erb +5 -0
- data/app/components/primer/beta/truncate.rb +110 -0
- data/app/components/primer/border_box_component.rb +27 -1
- data/app/components/primer/clipboard_copy.html.erb +2 -2
- data/app/components/primer/clipboard_copy.rb +1 -1
- data/app/components/primer/dropdown.rb +7 -7
- data/app/components/primer/icon_button.rb +1 -1
- data/app/components/primer/image_crop.html.erb +4 -4
- data/app/components/primer/label_component.rb +13 -12
- data/app/components/primer/navigation/tab_component.rb +16 -2
- data/app/components/primer/progress_bar_component.rb +0 -3
- data/app/components/primer/tab_nav_component.rb +4 -3
- data/app/components/primer/truncate.rb +1 -1
- data/app/components/primer/underline_nav_component.rb +3 -2
- data/app/lib/primer/fetch_or_fallback_helper.rb +2 -0
- data/app/lib/primer/octicon/cache.rb +1 -1
- data/app/lib/primer/tabbed_component_helper.rb +1 -1
- data/app/lib/primer/view_helper.rb +1 -0
- data/lib/primer/classify.rb +4 -16
- data/lib/primer/classify/cache.rb +0 -5
- data/lib/primer/classify/flex.rb +1 -1
- data/lib/primer/classify/functional_colors.rb +1 -1
- data/lib/primer/classify/utilities.rb +51 -13
- data/lib/primer/classify/utilities.yml +16 -0
- data/lib/primer/classify/validation.rb +18 -0
- data/lib/primer/view_components.rb +34 -6
- data/lib/primer/view_components/constants.rb +55 -0
- data/lib/primer/view_components/linters/argument_mappers/base.rb +100 -0
- data/lib/primer/view_components/linters/argument_mappers/button.rb +33 -46
- data/lib/primer/view_components/linters/argument_mappers/clipboard_copy.rb +19 -0
- data/lib/primer/view_components/linters/argument_mappers/helpers/erb_block.rb +67 -0
- data/lib/primer/view_components/linters/argument_mappers/label.rb +49 -0
- data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +6 -5
- data/lib/primer/view_components/linters/autocorrectable.rb +30 -0
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +9 -23
- data/lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb +21 -0
- data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +16 -0
- data/lib/primer/view_components/linters/helpers.rb +47 -42
- data/lib/primer/view_components/linters/label_component_migration_counter.rb +25 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/config/default.yml +5 -0
- data/lib/rubocop/cop/primer.rb +1 -2
- data/lib/rubocop/cop/primer/deprecated_arguments.rb +173 -0
- data/lib/rubocop/cop/primer/no_tag_memoize.rb +1 -0
- data/lib/rubocop/cop/primer/primer_octicon.rb +178 -0
- data/lib/rubocop/cop/primer/system_argument_instead_of_class.rb +12 -16
- data/lib/tasks/constants.rake +12 -0
- data/lib/tasks/coverage.rake +4 -0
- data/lib/tasks/docs.rake +27 -25
- data/lib/tasks/utilities.rake +9 -13
- data/lib/yard/docs_helper.rb +15 -5
- data/static/arguments.yml +980 -0
- data/static/assets/view-components.svg +18 -0
- data/static/classes.yml +182 -0
- data/static/constants.json +640 -0
- data/static/statuses.json +4 -2
- metadata +29 -10
- data/app/components/primer/avatar_stack_component.rb +0 -90
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad52227798e79cb0259c00e61d24a3e72854dfb4fa4ffb4901fb30a2fa7f3370
|
4
|
+
data.tar.gz: 5f2e4decc740b1e9712744819d655091a2a45e9ac8b403beed54c8c9e6a6e332
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7cac3105837c025730e7c6e01395db680d1c750bf4d2240594f00c4758a7d404802d184dd3bd53a14c8a2e14e25776152792e97fceb2a686182aaf1474ae162
|
7
|
+
data.tar.gz: f296ae7b5e8f6217b05e719169db5f08b1d1d8d7fb9293e083ae9a836f12d98c73e88cc320df3522a902f4dada28ac10ce7c9f37a96f0b175aaa1e2940e1bec9
|
data/CHANGELOG.md
CHANGED
@@ -30,6 +30,161 @@ The category for changes related to documentation, testing and tooling. Also, fo
|
|
30
30
|
|
31
31
|
## main
|
32
32
|
|
33
|
+
## 0.0.52
|
34
|
+
|
35
|
+
### New
|
36
|
+
|
37
|
+
* Adding `Primer::Beta::Truncate` component to reflect changes in primer/css component [Truncate](https://primer.style/css/components/truncate).
|
38
|
+
|
39
|
+
*Jon Rohan*
|
40
|
+
|
41
|
+
* Add cop to look for deprecated system arguments and suggest replacements.
|
42
|
+
|
43
|
+
*Jon Rohan*
|
44
|
+
|
45
|
+
* Add cop to use `primer_octicon` in favor of `octicon`.
|
46
|
+
|
47
|
+
*Manuel Puyol*
|
48
|
+
|
49
|
+
* Fix release script so it doesn't loop continuously.
|
50
|
+
|
51
|
+
*Cameron Dutro*
|
52
|
+
|
53
|
+
### Updates
|
54
|
+
|
55
|
+
* Promote `ClipboardCopy` to beta.
|
56
|
+
|
57
|
+
*Manuel Puyol*
|
58
|
+
|
59
|
+
* PrimerOcticon linter supports `aria-` and `data-` attributes.
|
60
|
+
|
61
|
+
*Manuel Puyol*
|
62
|
+
|
63
|
+
* Linters can:
|
64
|
+
* convert values with ERB interpolations.
|
65
|
+
* autocorrect cases with custom classes.
|
66
|
+
|
67
|
+
*Manuel Puyol*
|
68
|
+
|
69
|
+
* Add a `scheme` option to `BorderBoxComponent` rows.
|
70
|
+
|
71
|
+
*Cameron Dutro*
|
72
|
+
|
73
|
+
* Upgrade rubocop and support Ruby 3.0.
|
74
|
+
|
75
|
+
*Cameron Dutro*
|
76
|
+
|
77
|
+
* Linters will not autocorrect cases where a required argument is missing.
|
78
|
+
|
79
|
+
*Manuel Puyol*
|
80
|
+
|
81
|
+
### Misc
|
82
|
+
|
83
|
+
* Update benchmarks to run in every supported Ruby version.
|
84
|
+
|
85
|
+
*Manuel Puyol*
|
86
|
+
|
87
|
+
## 0.0.51
|
88
|
+
|
89
|
+
### Breaking changes
|
90
|
+
|
91
|
+
* Rename `width` and `height` System Arguments to `w` and `h`, resolving conflict with HTML attribute names.
|
92
|
+
|
93
|
+
*Manuel Puyol*
|
94
|
+
|
95
|
+
### Updates
|
96
|
+
|
97
|
+
* `SystemArgumentInsteadOfClass` linter will check for arguments in ViewHelpers.
|
98
|
+
|
99
|
+
*Manuel Puyol*
|
100
|
+
|
101
|
+
## 0.0.50
|
102
|
+
|
103
|
+
### Updates
|
104
|
+
|
105
|
+
* Fix incorrect slots syntax in docs.
|
106
|
+
|
107
|
+
*Joel Hawksley*, *Blake Williams*
|
108
|
+
|
109
|
+
### New
|
110
|
+
|
111
|
+
* Add linter suggestions for `CloseButton` component.
|
112
|
+
|
113
|
+
*Manuel Puyol*
|
114
|
+
|
115
|
+
### Breaking changes
|
116
|
+
|
117
|
+
* Update to `octicons` `v15`, removing open-ended dependency. See [https://github.com/primer/octicons/releases/tag/v15.0.0] for icon name changes in release.
|
118
|
+
|
119
|
+
*Joel Hawksley*
|
120
|
+
|
121
|
+
### Updates
|
122
|
+
|
123
|
+
* Don't require `title` for `Label`.
|
124
|
+
|
125
|
+
*Manuel Puyol*
|
126
|
+
|
127
|
+
* Improve autocorrectable linters to convert known SystemArgument classes.
|
128
|
+
|
129
|
+
*Manuel Puyol*
|
130
|
+
|
131
|
+
* Add support for `width: :full` and `height: :full` to System Arguments.
|
132
|
+
|
133
|
+
*Joel Hawksley*
|
134
|
+
|
135
|
+
### Bug fixes
|
136
|
+
|
137
|
+
* Update linters to not autocorrect attributes with ERB blocks.
|
138
|
+
|
139
|
+
*Manuel Puyol*
|
140
|
+
|
141
|
+
* Fix `:height` and `:width` docs to pull from Utilities
|
142
|
+
|
143
|
+
*Jon Rohan*
|
144
|
+
|
145
|
+
## 0.0.49
|
146
|
+
|
147
|
+
### New
|
148
|
+
|
149
|
+
* Add linter suggestions for `Label` component.
|
150
|
+
|
151
|
+
*Manuel Puyol*
|
152
|
+
|
153
|
+
* Add linter suggestions for `ClipboardCopy` component.
|
154
|
+
|
155
|
+
*Manuel Puyol*
|
156
|
+
|
157
|
+
### Updates
|
158
|
+
|
159
|
+
* Update the `Truncate` component to accept `:strong` as a tag.
|
160
|
+
|
161
|
+
*Amélia Chavot*
|
162
|
+
|
163
|
+
* Improve `Primer::Classify::Utilities.classes_to_hash` performance.
|
164
|
+
|
165
|
+
*Manuel Puyol*
|
166
|
+
|
167
|
+
### Breaking changes
|
168
|
+
|
169
|
+
* Require tab with panels to have `panel_id` so `aria-controls` can be set.
|
170
|
+
|
171
|
+
*Kate Higa*
|
172
|
+
|
173
|
+
* Renames:
|
174
|
+
* `Primer::AvatarStackComponent` to `Primer::Beta::AvatarStack`.
|
175
|
+
|
176
|
+
*Manuel Puyol*
|
177
|
+
|
178
|
+
### Misc
|
179
|
+
|
180
|
+
* Extract example tag parsing into helper.
|
181
|
+
|
182
|
+
*Kate Higa*
|
183
|
+
|
184
|
+
* Generate a static constant JSON and use it when defining linters.
|
185
|
+
|
186
|
+
*Manuel Puyol*
|
187
|
+
|
33
188
|
## 0.0.48
|
34
189
|
|
35
190
|
### Breaking changes
|
@@ -79,7 +79,6 @@ module Primer
|
|
79
79
|
# | `flex_shrink` | Integer | To enable, set to `0`. |
|
80
80
|
# | `flex_wrap` | Symbol | <%= one_of(Primer::Classify::Flex::WRAP_MAPPINGS.keys) %> |
|
81
81
|
# | `justify_content` | Symbol | <%= one_of(Primer::Classify::Flex::JUSTIFY_CONTENT_VALUES) %> |
|
82
|
-
# | `width` | Symbol | <%= one_of([:fit]) %> |
|
83
82
|
#
|
84
83
|
# ## Grid
|
85
84
|
#
|
@@ -94,7 +93,8 @@ module Primer
|
|
94
93
|
# | Name | Type | Description |
|
95
94
|
# | :- | :- | :- |
|
96
95
|
# | `display` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:display)) %> |
|
97
|
-
# | `
|
96
|
+
# | `w` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:w)) %> Also supports integer values. |
|
97
|
+
# | `h` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:h)) %> Also supports integer values. |
|
98
98
|
# | `hide` | Symbol | Hide the element at a specific breakpoint. <%= one_of(Primer::Classify::Utilities.mappings(:hide)) %> |
|
99
99
|
# | `visibility` | Symbol | Visibility. <%= one_of(Primer::Classify::Utilities.mappings(:visibility)) %> |
|
100
100
|
# | `vertical_align` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:vertical_align)) %> |
|
@@ -8,7 +8,7 @@ module Primer
|
|
8
8
|
# for organizations or any other non-human avatars.
|
9
9
|
# - By default, `Avatar` will render a static `<img>`. To have `Avatar` function as a link, set the `href` which will wrap the `<img>` in a `<a>`.
|
10
10
|
# - Set `size` to update the height and width of the `Avatar` in pixels.
|
11
|
-
# - To stack multiple avatars together, use <%= link_to_component(Primer::
|
11
|
+
# - To stack multiple avatars together, use <%= link_to_component(Primer::Beta::AvatarStack) %>.
|
12
12
|
#
|
13
13
|
# @accessibility
|
14
14
|
# Images should have text alternatives that describe the information or function represented.
|
File without changes
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Beta
|
5
|
+
# Use `AvatarStack` to stack multiple avatars together.
|
6
|
+
class AvatarStack < Primer::Component
|
7
|
+
status :beta
|
8
|
+
|
9
|
+
ALIGN_DEFAULT = :left
|
10
|
+
ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
|
11
|
+
|
12
|
+
DEFAULT_TAG = :div
|
13
|
+
TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
|
14
|
+
|
15
|
+
DEFAULT_BODY_TAG = :div
|
16
|
+
BODY_TAG_OPTIONS = [DEFAULT_BODY_TAG, :span].freeze
|
17
|
+
# Required list of stacked avatars.
|
18
|
+
#
|
19
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Avatar) %>.
|
20
|
+
renders_many :avatars, "Primer::Beta::Avatar"
|
21
|
+
|
22
|
+
# @example Default
|
23
|
+
# <%= render(Primer::Beta::AvatarStack.new) do |c| %>
|
24
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
25
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
26
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
27
|
+
# <% end %>
|
28
|
+
#
|
29
|
+
# @example Align right
|
30
|
+
# <%= render(Primer::Beta::AvatarStack.new(align: :right)) do |c| %>
|
31
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
32
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
33
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
34
|
+
# <% end %>
|
35
|
+
#
|
36
|
+
# @example With tooltip
|
37
|
+
# <%= render(Primer::Beta::AvatarStack.new(tooltipped: true, body_arguments: { label: 'This is a tooltip!' })) do |c| %>
|
38
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
39
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
40
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
41
|
+
# <% end %>
|
42
|
+
#
|
43
|
+
# @param tag [Symbol] <%= one_of(Primer::Beta::AvatarStack::TAG_OPTIONS) %>
|
44
|
+
# @param align [Symbol] <%= one_of(Primer::Beta::AvatarStack::ALIGN_OPTIONS) %>
|
45
|
+
# @param tooltipped [Boolean] Whether to add a tooltip to the stack or not.
|
46
|
+
# @param body_arguments [Hash] Parameters to add to the Body. If `tooltipped` is set, has the same arguments as <%= link_to_component(Primer::Tooltip) %>.
|
47
|
+
# The default tag is <%= pretty_value(Primer::Beta::AvatarStack::DEFAULT_BODY_TAG) %> but can be changed using `tag:`
|
48
|
+
# to <%= one_of(Primer::Beta::AvatarStack::BODY_TAG_OPTIONS, lower: true) %>
|
49
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
50
|
+
def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, tooltipped: false, body_arguments: {}, **system_arguments)
|
51
|
+
@align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
|
52
|
+
@system_arguments = system_arguments
|
53
|
+
@tooltipped = tooltipped
|
54
|
+
@body_arguments = body_arguments
|
55
|
+
|
56
|
+
body_tag = @body_arguments[:tag] || DEFAULT_BODY_TAG
|
57
|
+
@body_arguments[:tag] = fetch_or_fallback(BODY_TAG_OPTIONS, body_tag, DEFAULT_BODY_TAG)
|
58
|
+
@body_arguments[:classes] = class_names(
|
59
|
+
"AvatarStack-body",
|
60
|
+
@body_arguments[:classes]
|
61
|
+
)
|
62
|
+
|
63
|
+
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
64
|
+
@system_arguments[:classes] = class_names(
|
65
|
+
"AvatarStack",
|
66
|
+
system_arguments[:classes],
|
67
|
+
"AvatarStack--right" => @align == :right
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
def body_component
|
72
|
+
if @tooltipped
|
73
|
+
Primer::Tooltip.new(**@body_arguments)
|
74
|
+
else
|
75
|
+
Primer::BaseComponent.new(**@body_arguments)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def before_render
|
80
|
+
@system_arguments[:classes] = class_names(
|
81
|
+
@system_arguments[:classes],
|
82
|
+
"AvatarStack--two" => avatars.size == 2,
|
83
|
+
"AvatarStack--three-plus" => avatars.size > 2
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
def render?
|
88
|
+
avatars.any?
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Beta
|
5
|
+
# Use `Truncate` to shorten overflowing text with an ellipsis.
|
6
|
+
class Truncate < Primer::Component
|
7
|
+
status :beta
|
8
|
+
|
9
|
+
# Text slot used for the truncated text.
|
10
|
+
#
|
11
|
+
# @param priority [Boolean] if true, the text will be given priority
|
12
|
+
# @param expandable [Boolean] if true, the text will expand on hover or focus
|
13
|
+
# @param max_width [Integer] if provided, the text will be truncated at a maximum width
|
14
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
15
|
+
renders_many :items, "TruncateText"
|
16
|
+
|
17
|
+
# @example Default
|
18
|
+
# <%= render(Primer::Beta::Truncate.new) { "branch-name-that-is-really-long" } %>
|
19
|
+
#
|
20
|
+
# @example Multiple items
|
21
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
22
|
+
# <% component.item do %>really-long-repository-owner-name<% end %>
|
23
|
+
# <% component.item(font_weight: :bold) do %>
|
24
|
+
# <%= render(Primer::BaseComponent.new(tag: :span, font_weight: :normal)) { "/" } %> really-long-repository-name
|
25
|
+
# <% end %>
|
26
|
+
# <% end %>
|
27
|
+
#
|
28
|
+
# @example Advanced multiple items
|
29
|
+
# <%= render(Primer::Beta::Truncate.new(tag: :ol)) do |component| %>
|
30
|
+
# <% component.item(tag: :li) do %>primer<% end %>
|
31
|
+
# <% component.item(tag: :li, priority: true) do %>/ css<% end %>
|
32
|
+
# <% component.item(tag: :li) do %>/ Issues<% end %>
|
33
|
+
# <% component.item(tag: :li) do %>/ #123 —<% end %>
|
34
|
+
# <% component.item(tag: :li, priority: true) do %>
|
35
|
+
# Visual bug on primer.style found in lists
|
36
|
+
# <% end %>
|
37
|
+
# <% end %>
|
38
|
+
#
|
39
|
+
# @example Expand on hover or focus
|
40
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
41
|
+
# <% component.item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
|
42
|
+
# <% component.item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
|
43
|
+
# <% component.item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
|
44
|
+
# <% component.item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
|
45
|
+
# <% end %>
|
46
|
+
#
|
47
|
+
# @example Max widths
|
48
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
49
|
+
# <% component.item(max_width: 300, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
50
|
+
# <% component.item(max_width: 200, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
51
|
+
# <% component.item(max_width: 100, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
52
|
+
# <% end %>
|
53
|
+
#
|
54
|
+
# @example Max widths on new lines
|
55
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
56
|
+
# <% component.item(max_width: 300, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
57
|
+
# <% end %>
|
58
|
+
# <br/>
|
59
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
60
|
+
# <% component.item(max_width: 200, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
61
|
+
# <% end %>
|
62
|
+
# <br/>
|
63
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
64
|
+
# <% component.item(max_width: 100, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
65
|
+
# <% end %>
|
66
|
+
#
|
67
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
68
|
+
def initialize(**system_arguments)
|
69
|
+
@system_arguments = system_arguments
|
70
|
+
@system_arguments[:tag] = system_arguments[:tag] || :span
|
71
|
+
@system_arguments[:classes] = class_names(
|
72
|
+
"Truncate",
|
73
|
+
system_arguments[:classes]
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def before_render
|
78
|
+
return unless content.present? && items.empty?
|
79
|
+
|
80
|
+
item { content }
|
81
|
+
end
|
82
|
+
|
83
|
+
def render?
|
84
|
+
items.any?
|
85
|
+
end
|
86
|
+
|
87
|
+
# This component is part of `Primer::Beta::Truncate` and should not be
|
88
|
+
# used as a standalone component.
|
89
|
+
class TruncateText < Primer::Component
|
90
|
+
def initialize(priority: false, expandable: false, max_width: nil, **system_arguments)
|
91
|
+
@system_arguments = system_arguments
|
92
|
+
@system_arguments[:tag] = system_arguments[:tag] || :span
|
93
|
+
@system_arguments[:classes] = class_names(
|
94
|
+
"Truncate-text",
|
95
|
+
"Truncate-text--primary": priority,
|
96
|
+
"Truncate-text--expandable": expandable
|
97
|
+
)
|
98
|
+
|
99
|
+
@system_arguments[:style] = join_style_arguments(@system_arguments[:style], "max-width: #{max_width}px;") unless max_width.nil?
|
100
|
+
end
|
101
|
+
|
102
|
+
def call
|
103
|
+
render(Primer::BaseComponent.new(**@system_arguments)) do
|
104
|
+
content
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -13,6 +13,14 @@ module Primer
|
|
13
13
|
}.freeze
|
14
14
|
PADDING_SUGGESTION = "Perhaps you could consider using :padding options of #{PADDING_MAPPINGS.keys.to_sentence}?"
|
15
15
|
|
16
|
+
DEFAULT_ROW_SCHEME = :default
|
17
|
+
ROW_SCHEME_MAPPINGS = {
|
18
|
+
DEFAULT_ROW_SCHEME => "",
|
19
|
+
:neutral => "Box-row--gray",
|
20
|
+
:info => "Box-row--blue",
|
21
|
+
:warning => "Box-row--yellow"
|
22
|
+
}.freeze
|
23
|
+
|
16
24
|
# Optional Header.
|
17
25
|
#
|
18
26
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
@@ -54,11 +62,13 @@ module Primer
|
|
54
62
|
|
55
63
|
# Use Rows to add rows with borders and maintain the same padding.
|
56
64
|
#
|
65
|
+
# @param scheme [Symbol] Color scheme. <%= one_of(Primer::BorderBoxComponent::ROW_SCHEME_MAPPINGS.keys) %>
|
57
66
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
58
|
-
renders_many :rows, lambda {
|
67
|
+
renders_many :rows, lambda { |scheme: DEFAULT_ROW_SCHEME, **system_arguments|
|
59
68
|
system_arguments[:tag] = :li
|
60
69
|
system_arguments[:classes] = class_names(
|
61
70
|
"Box-row",
|
71
|
+
ROW_SCHEME_MAPPINGS[fetch_or_fallback(ROW_SCHEME_MAPPINGS.keys, scheme, DEFAULT_ROW_SCHEME)],
|
62
72
|
system_arguments[:classes]
|
63
73
|
)
|
64
74
|
|
@@ -102,6 +112,22 @@ module Primer
|
|
102
112
|
# <% end %>
|
103
113
|
# <% end %>
|
104
114
|
#
|
115
|
+
# @example Row colors
|
116
|
+
# <%= render(Primer::BorderBoxComponent.new) do |component| %>
|
117
|
+
# <% component.row do %>
|
118
|
+
# Default
|
119
|
+
# <% end %>
|
120
|
+
# <% component.row(scheme: :neutral) do %>
|
121
|
+
# Neutral
|
122
|
+
# <% end %>
|
123
|
+
# <% component.row(scheme: :info) do %>
|
124
|
+
# Info
|
125
|
+
# <% end %>
|
126
|
+
# <% component.row(scheme: :warning) do %>
|
127
|
+
# Warning
|
128
|
+
# <% end %>
|
129
|
+
# <% end %>
|
130
|
+
#
|
105
131
|
# @param padding [Symbol] <%= one_of(Primer::BorderBoxComponent::PADDING_MAPPINGS.keys) %>
|
106
132
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
107
133
|
def initialize(padding: DEFAULT_PADDING, **system_arguments)
|