primer_view_components 0.0.104 → 0.0.105
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_list/item.rb +2 -2
- data/app/components/primer/alpha/action_list.rb +2 -0
- data/app/components/primer/alpha/image.rb +50 -0
- data/app/components/primer/{image_crop.d.ts → alpha/image_crop.d.ts} +0 -0
- data/app/components/primer/{image_crop.html.erb → alpha/image_crop.html.erb} +0 -0
- data/app/components/primer/{image_crop.js → alpha/image_crop.js} +0 -0
- data/app/components/primer/alpha/image_crop.rb +39 -0
- data/app/components/primer/{image_crop.ts → alpha/image_crop.ts} +0 -0
- data/app/components/primer/alpha/nav_list/item.rb +2 -0
- data/app/components/primer/alpha/nav_list/section.rb +2 -0
- data/app/components/primer/alpha/segmented_control/item.html.erb +13 -0
- data/app/components/primer/alpha/segmented_control/item.rb +29 -0
- data/app/components/primer/alpha/segmented_control.css +1 -0
- data/app/components/primer/alpha/segmented_control.css.map +1 -0
- data/app/components/primer/alpha/segmented_control.d.ts +11 -0
- data/app/components/primer/alpha/segmented_control.html.erb +7 -0
- data/app/components/primer/alpha/segmented_control.js +48 -0
- data/app/components/primer/alpha/segmented_control.pcss +121 -0
- data/app/components/primer/alpha/segmented_control.rb +92 -0
- data/app/components/primer/alpha/segmented_control.ts +41 -0
- data/app/components/primer/alpha/tooltip.rb +2 -2
- data/app/components/primer/beta/auto_complete/item.rb +2 -2
- data/app/components/primer/beta/avatar.rb +1 -1
- data/app/components/primer/beta/blankslate.rb +4 -4
- data/app/components/primer/beta/breadcrumbs.rb +1 -1
- data/app/components/primer/beta/button.rb +1 -1
- data/app/components/primer/beta/label.rb +100 -0
- data/app/components/primer/beta/link.rb +99 -0
- data/app/components/primer/component.rb +1 -0
- data/app/components/primer/image.rb +2 -41
- data/app/components/primer/image_crop.rb +2 -32
- data/app/components/primer/label_component.rb +2 -93
- data/app/components/primer/link_component.rb +2 -92
- data/app/components/primer/primer.d.ts +2 -1
- data/app/components/primer/primer.js +2 -1
- data/app/components/primer/primer.pcss +1 -0
- data/app/components/primer/primer.ts +2 -1
- data/app/components/primer/subhead_component.rb +1 -1
- data/app/components/primer/time_ago_component.rb +2 -0
- data/app/helpers/primer/form_helper.rb +1 -0
- data/app/lib/primer/view_helper.rb +1 -1
- data/lib/primer/deprecations.rb +4 -0
- data/lib/primer/form_components.rb +1 -0
- data/lib/primer/view_components/linters/argument_mappers/label.rb +4 -4
- data/lib/primer/view_components/linters/label_component_migration_counter.rb +3 -3
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/config/default.yml +0 -3
- data/lib/rubocop/cop/primer/deprecated_label_schemes.rb +3 -3
- data/lib/rubocop/cop/primer/deprecated_label_variants.rb +5 -5
- data/lib/tasks/docs.rake +12 -7
- data/lib/tasks/test.rake +23 -26
- data/previews/primer/alpha/action_list_preview.rb +29 -0
- data/previews/primer/alpha/auto_complete_preview.rb +10 -0
- data/previews/primer/alpha/button_marketing_preview.rb +9 -0
- data/previews/primer/alpha/dialog_preview.rb +18 -1
- data/previews/primer/alpha/hidden_text_expander_preview.rb +7 -0
- data/previews/primer/alpha/image_crop_preview.rb +31 -0
- data/previews/primer/alpha/layout_preview.rb +15 -0
- data/previews/primer/alpha/nav_list_preview.rb +29 -0
- data/previews/primer/alpha/segmented_control_preview.rb +75 -0
- data/previews/primer/alpha/tab_panels_preview.rb +15 -0
- data/previews/primer/alpha/text_field_preview.rb +58 -0
- data/previews/primer/alpha/toggle_switch_preview.rb +4 -0
- data/previews/primer/alpha/tooltip_preview.rb +13 -3
- data/previews/primer/alpha/underline_nav_preview/playground.html.erb +8 -0
- data/previews/primer/alpha/underline_nav_preview.rb +15 -0
- data/previews/primer/alpha/underline_panels_preview.rb +15 -0
- data/previews/primer/beta/auto_complete_item_preview/playground.html.erb +9 -0
- data/previews/primer/beta/auto_complete_item_preview.rb +14 -0
- data/previews/primer/beta/auto_complete_preview.rb +20 -0
- data/previews/primer/beta/avatar_preview.rb +9 -0
- data/previews/primer/beta/avatar_stack_preview.rb +15 -0
- data/previews/primer/beta/base_button_preview.rb +9 -0
- data/previews/primer/beta/blankslate_preview.rb +12 -0
- data/previews/primer/beta/border_box_preview.rb +14 -0
- data/previews/primer/beta/breadcrumbs_preview.rb +11 -0
- data/previews/primer/beta/button_group_preview.rb +12 -0
- data/previews/primer/beta/close_button_preview.rb +7 -0
- data/previews/primer/beta/counter_preview.rb +11 -0
- data/previews/primer/beta/details_preview.rb +15 -0
- data/previews/primer/beta/flash_preview.rb +12 -0
- data/previews/primer/beta/heading_preview.rb +8 -0
- data/previews/primer/beta/label_preview.rb +26 -0
- data/previews/primer/beta/link_preview.rb +41 -0
- data/previews/primer/beta/text_preview.rb +8 -0
- data/previews/primer/beta/truncate_preview.rb +7 -0
- data/previews/primer/clipboard_copy_preview.rb +8 -0
- data/previews/primer/dropdown_preview.rb +18 -0
- data/previews/primer/hellip_button_preview.rb +8 -0
- data/previews/primer/layout_component_preview.rb +13 -1
- data/previews/primer/local_time_component_preview.rb +13 -0
- data/previews/primer/markdown_preview.rb +277 -266
- data/previews/primer/menu_component_preview/playground.html.erb +17 -0
- data/previews/primer/menu_component_preview.rb +4 -1
- data/previews/primer/octicon_component_preview.rb +8 -0
- data/previews/primer/popover_component_preview.rb +15 -1
- data/previews/primer/progress_bar_component_preview.rb +12 -1
- data/previews/primer/spinner_component_preview.rb +7 -0
- data/previews/primer/state_component_preview.rb +11 -1
- data/previews/primer/subhead_component_preview.rb +17 -0
- data/previews/primer/time_ago_component_preview.rb +8 -0
- data/previews/primer/timeline_item_component_preview.rb +12 -1
- data/static/arguments.json +300 -138
- data/static/audited_at.json +6 -0
- data/static/constants.json +86 -71
- data/static/statuses.json +10 -4
- metadata +27 -9
- data/previews/primer/image_crop_preview.rb +0 -22
- data/previews/primer/label_component_preview.rb +0 -15
- data/previews/primer/link_component_preview.rb +0 -29
@@ -1,98 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
|
5
|
-
|
6
|
-
# @accessibility
|
7
|
-
# Use `aria-label` if the `Label` or the context around it don't explain the label.
|
8
|
-
class LabelComponent < Primer::Component
|
9
|
-
status :beta
|
10
|
-
|
11
|
-
DEFAULT_TAG = :span
|
12
|
-
TAG_OPTIONS = [DEFAULT_TAG, :summary, :a, :div].freeze
|
13
|
-
|
14
|
-
DEFAULT_SCHEME = :default
|
15
|
-
SCHEME_MAPPINGS = {
|
16
|
-
DEFAULT_SCHEME => "",
|
17
|
-
:primary => "Label--primary",
|
18
|
-
:secondary => "Label--secondary",
|
19
|
-
:accent => "Label--accent",
|
20
|
-
:success => "Label--success",
|
21
|
-
:attention => "Label--attention",
|
22
|
-
:danger => "Label--danger",
|
23
|
-
:severe => "Label--severe",
|
24
|
-
:done => "Label--done",
|
25
|
-
:sponsors => "Label--sponsors",
|
26
|
-
# deprecated
|
27
|
-
:info => "Label--info",
|
28
|
-
:warning => "Label--warning",
|
29
|
-
:orange => "Label--orange",
|
30
|
-
:purple => "Label--purple"
|
31
|
-
}.freeze
|
32
|
-
DEPRECATED_SCHEME_OPTIONS = [:info, :warning, :orange, :purple].freeze
|
33
|
-
SCHEME_OPTIONS = (SCHEME_MAPPINGS.keys - DEPRECATED_SCHEME_OPTIONS).freeze
|
34
|
-
|
35
|
-
DEFAULT_SIZE = :medium
|
36
|
-
SIZE_MAPPINGS = {
|
37
|
-
DEFAULT_SIZE => nil,
|
38
|
-
:large => "Label--large"
|
39
|
-
}.freeze
|
40
|
-
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
41
|
-
|
42
|
-
DEFAULT_VARIANT = :none
|
43
|
-
VARIANT_OPTIONS = [DEFAULT_VARIANT].freeze
|
44
|
-
DEPRECATED_VARIANT_OPTIONS = [:large, :inline].freeze
|
45
|
-
|
46
|
-
INLINE_CLASS = "Label--inline"
|
47
|
-
|
48
|
-
# @example Schemes
|
49
|
-
# <%= render(Primer::LabelComponent.new) { "Default" } %>
|
50
|
-
# <%= render(Primer::LabelComponent.new(scheme: :primary)) { "Primary" } %>
|
51
|
-
# <%= render(Primer::LabelComponent.new(scheme: :secondary)) { "Secondary" } %>
|
52
|
-
# <%= render(Primer::LabelComponent.new(scheme: :accent)) { "Accent" } %>
|
53
|
-
# <%= render(Primer::LabelComponent.new(scheme: :success)) { "Success" } %>
|
54
|
-
# <%= render(Primer::LabelComponent.new(scheme: :attention)) { "Attention" } %>
|
55
|
-
# <%= render(Primer::LabelComponent.new(scheme: :danger)) { "Danger" } %>
|
56
|
-
# <%= render(Primer::LabelComponent.new(scheme: :severe)) { "Severe" } %>
|
57
|
-
# <%= render(Primer::LabelComponent.new(scheme: :done)) { "Done" } %>
|
58
|
-
# <%= render(Primer::LabelComponent.new(scheme: :sponsors)) { "Sponsors" } %>
|
59
|
-
#
|
60
|
-
# @example Sizes
|
61
|
-
# <%= render(Primer::LabelComponent.new) { "Medium" } %>
|
62
|
-
# <%= render(Primer::LabelComponent.new(size: :large)) { "Large" } %>
|
63
|
-
#
|
64
|
-
# @example Inline
|
65
|
-
# <%= render(Primer::LabelComponent.new) { "Default" } %>
|
66
|
-
# <%= render(Primer::LabelComponent.new(inline: true)) { "Inline" } %>
|
67
|
-
#
|
68
|
-
# @param tag [Symbol] <%= one_of(Primer::LabelComponent::TAG_OPTIONS) %>
|
69
|
-
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_MAPPINGS.keys) %>
|
70
|
-
# @param size [Symbol] <%= one_of(Primer::LabelComponent::SIZE_OPTIONS) %>
|
71
|
-
# @param inline [Boolean] Whether or not to render this label inline.
|
72
|
-
# @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS + Primer::LabelComponent::DEPRECATED_VARIANT_OPTIONS) %>
|
73
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
74
|
-
|
75
|
-
def initialize(tag: DEFAULT_TAG, scheme: DEFAULT_SCHEME, size: DEFAULT_SIZE, inline: false, variant: DEFAULT_VARIANT, **system_arguments)
|
76
|
-
@system_arguments = system_arguments
|
77
|
-
|
78
|
-
@variant = fetch_or_fallback(VARIANT_OPTIONS, variant, nil, deprecated_values: DEPRECATED_VARIANT_OPTIONS)
|
79
|
-
@scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME, deprecated_values: DEPRECATED_SCHEME_OPTIONS)
|
80
|
-
@size = fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)
|
81
|
-
@size = :large if @variant == :large
|
82
|
-
@inline = inline || @variant == :inline
|
83
|
-
|
84
|
-
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
85
|
-
@system_arguments[:classes] = class_names(
|
86
|
-
"Label",
|
87
|
-
system_arguments[:classes],
|
88
|
-
SCHEME_MAPPINGS[@scheme],
|
89
|
-
SIZE_MAPPINGS[@size],
|
90
|
-
@inline ? INLINE_CLASS : nil
|
91
|
-
)
|
92
|
-
end
|
93
|
-
|
94
|
-
def call
|
95
|
-
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
96
|
-
end
|
4
|
+
class LabelComponent < Primer::Beta::Label
|
5
|
+
status :deprecated
|
97
6
|
end
|
98
7
|
end
|
@@ -1,97 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
|
5
|
-
|
6
|
-
status :beta
|
7
|
-
|
8
|
-
DEFAULT_SCHEME = :default
|
9
|
-
SCHEME_MAPPINGS = {
|
10
|
-
DEFAULT_SCHEME => "",
|
11
|
-
:primary => "Link--primary",
|
12
|
-
:secondary => "Link--secondary"
|
13
|
-
}.freeze
|
14
|
-
|
15
|
-
DEFAULT_TAG = :a
|
16
|
-
TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
|
17
|
-
|
18
|
-
# `Tooltip` that appears on mouse hover or keyboard focus over the link. Use tooltips sparingly and as a last resort.
|
19
|
-
# **Important:** This tooltip defaults to `type: :description`. In a few scenarios, `type: :label` may be more appropriate.
|
20
|
-
# The tooltip will appear adjacent to the anchor element. Both the tooltip and the anchor will be nested
|
21
|
-
# under a positioning wrapper.
|
22
|
-
# Consult the <%= link_to_component(Primer::Alpha::Tooltip) %> documentation for more information.
|
23
|
-
#
|
24
|
-
# @param type [Symbol] (:description) <%= one_of(Primer::Alpha::Tooltip::TYPE_OPTIONS) %>
|
25
|
-
# @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Alpha::Tooltip) %>.
|
26
|
-
renders_one :tooltip, lambda { |**system_arguments|
|
27
|
-
raise ArgumentError, "Links with a tooltip must have a unique `id` set on the `LinkComponent`." if @id.blank? && !Rails.env.production?
|
28
|
-
|
29
|
-
system_arguments[:for_id] = @id
|
30
|
-
system_arguments[:type] ||= :description
|
31
|
-
|
32
|
-
Primer::Alpha::Tooltip.new(**system_arguments)
|
33
|
-
}
|
34
|
-
|
35
|
-
# @example Default
|
36
|
-
# <%= render(Primer::LinkComponent.new(href: "#")) { "Link" } %>
|
37
|
-
#
|
38
|
-
# @example Muted
|
39
|
-
# <%= render(Primer::LinkComponent.new(href: "#", muted: true)) { "Link" } %>
|
40
|
-
#
|
41
|
-
# @example Schemes
|
42
|
-
# <%= render(Primer::LinkComponent.new(href: "#", scheme: :primary)) { "Primary" } %>
|
43
|
-
# <%= render(Primer::LinkComponent.new(href: "#", scheme: :secondary)) { "Secondary" } %>
|
44
|
-
#
|
45
|
-
# @example Without underline
|
46
|
-
# <%= render(Primer::LinkComponent.new(href: "#", underline: false)) { "Link" } %>
|
47
|
-
#
|
48
|
-
# @example With tooltip
|
49
|
-
# @description
|
50
|
-
# Use tooltips sparingly and as a last resort. Consult the <%= link_to_component(Primer::Alpha::Tooltip) %> documentation for more information.
|
51
|
-
# @code
|
52
|
-
# <%= render(Primer::LinkComponent.new(href: "#", id: "link-with-tooltip")) do |c| %>
|
53
|
-
# <% c.with_tooltip(text: "Tooltip text") %>
|
54
|
-
# Link
|
55
|
-
# <% end %>
|
56
|
-
#
|
57
|
-
# @param tag [String] <%= one_of(Primer::LinkComponent::TAG_OPTIONS) %>
|
58
|
-
# @param href [String] URL to be used for the Link. Required if tag is `:a`. If the requirements are not met an error will be raised in non production environments. In production, an empty link element will be rendered.
|
59
|
-
# @param scheme [Symbol] <%= one_of(Primer::LinkComponent::SCHEME_MAPPINGS.keys) %>
|
60
|
-
# @param muted [Boolean] Uses light gray for Link color, and blue on hover.
|
61
|
-
# @param underline [Boolean] Whether or not to underline the link.
|
62
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
63
|
-
def initialize(href: nil, tag: DEFAULT_TAG, scheme: DEFAULT_SCHEME, muted: false, underline: true, **system_arguments)
|
64
|
-
@system_arguments = system_arguments
|
65
|
-
|
66
|
-
@id = @system_arguments[:id]
|
67
|
-
|
68
|
-
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
69
|
-
@system_arguments[:href] = href
|
70
|
-
@system_arguments[:classes] = class_names(
|
71
|
-
@system_arguments[:classes],
|
72
|
-
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)],
|
73
|
-
"Link" => tag == :span,
|
74
|
-
"Link--muted" => muted,
|
75
|
-
"no-underline" => !underline
|
76
|
-
)
|
77
|
-
end
|
78
|
-
|
79
|
-
def before_render
|
80
|
-
raise ArgumentError, "href is required when using <a> tag" if @system_arguments[:tag] == :a && @system_arguments[:href].nil? && !Rails.env.production?
|
81
|
-
end
|
82
|
-
|
83
|
-
def call
|
84
|
-
if tooltip.present?
|
85
|
-
render Primer::BaseComponent.new(tag: :span, position: :relative) do
|
86
|
-
render(Primer::BaseComponent.new(**@system_arguments)) do
|
87
|
-
content
|
88
|
-
end.to_s + tooltip.to_s
|
89
|
-
end
|
90
|
-
else
|
91
|
-
render(Primer::BaseComponent.new(**@system_arguments)) do
|
92
|
-
content
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
4
|
+
class LinkComponent < Primer::Beta::Link
|
5
|
+
status :deprecated
|
96
6
|
end
|
97
7
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
+
import './alpha/image_crop';
|
1
2
|
import './alpha/modal_dialog';
|
2
3
|
import './alpha/nav_list';
|
4
|
+
import './alpha/segmented_control';
|
3
5
|
import './alpha/toggle_switch';
|
4
6
|
import './alpha/tool_tip';
|
5
7
|
import './beta/auto_complete/auto_complete';
|
6
8
|
import './clipboard_copy';
|
7
9
|
import './dropdown';
|
8
|
-
import './image_crop';
|
9
10
|
import './local_time';
|
10
11
|
import './tab_container_component';
|
11
12
|
import './time_ago_component';
|
@@ -1,11 +1,12 @@
|
|
1
|
+
import './alpha/image_crop';
|
1
2
|
import './alpha/modal_dialog';
|
2
3
|
import './alpha/nav_list';
|
4
|
+
import './alpha/segmented_control';
|
3
5
|
import './alpha/toggle_switch';
|
4
6
|
import './alpha/tool_tip';
|
5
7
|
import './beta/auto_complete/auto_complete';
|
6
8
|
import './clipboard_copy';
|
7
9
|
import './dropdown';
|
8
|
-
import './image_crop';
|
9
10
|
import './local_time';
|
10
11
|
import './tab_container_component';
|
11
12
|
import './time_ago_component';
|
@@ -1,11 +1,12 @@
|
|
1
|
+
import './alpha/image_crop'
|
1
2
|
import './alpha/modal_dialog'
|
2
3
|
import './alpha/nav_list'
|
4
|
+
import './alpha/segmented_control'
|
3
5
|
import './alpha/toggle_switch'
|
4
6
|
import './alpha/tool_tip'
|
5
7
|
import './beta/auto_complete/auto_complete'
|
6
8
|
import './clipboard_copy'
|
7
9
|
import './dropdown'
|
8
|
-
import './image_crop'
|
9
10
|
import './local_time'
|
10
11
|
import './tab_container_component'
|
11
12
|
import './time_ago_component'
|
@@ -5,7 +5,7 @@ module Primer
|
|
5
5
|
#
|
6
6
|
# - Optionally set the `:description` slot to render a short description and the `:actions` slot for a related action.
|
7
7
|
# - Use a succinct, 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::
|
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::Beta::Link) %>.
|
9
9
|
#
|
10
10
|
# @accessibility
|
11
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.
|
@@ -33,7 +33,9 @@ module Primer
|
|
33
33
|
seconds_ago = Time.current - @time
|
34
34
|
|
35
35
|
if seconds_ago < 1.minute
|
36
|
+
# :nocov:
|
36
37
|
"1m"
|
38
|
+
# :nocov:
|
37
39
|
elsif seconds_ago >= 1.minute && seconds_ago < 1.hour
|
38
40
|
"#{(seconds_ago / 60).floor}m"
|
39
41
|
elsif seconds_ago >= 1.hour && seconds_ago < 1.day
|
data/lib/primer/deprecations.rb
CHANGED
@@ -5,6 +5,10 @@ module Primer
|
|
5
5
|
module Deprecations
|
6
6
|
# If there is no alternative to suggest, set the value to nil
|
7
7
|
DEPRECATED_COMPONENTS = {
|
8
|
+
"Primer::LabelComponent" => "Primer::Beta::Label",
|
9
|
+
"Primer::LinkComponent" => "Primer::Beta::Link",
|
10
|
+
"Primer::ImageCrop" => "Primer::Alpha::ImageCrop",
|
11
|
+
"Primer::Image" => "Primer::Alpha::Image",
|
8
12
|
"Primer::Alpha::AutoComplete" => "Primer::Beta::AutoComplete",
|
9
13
|
"Primer::Alpha::AutoComplete::Item" => "Primer::Beta::AutoComplete::Item",
|
10
14
|
"Primer::BlankslateComponent" => "Primer::Beta::Blankslate",
|
@@ -8,24 +8,24 @@ module ERBLint
|
|
8
8
|
# Maps classes in a label element to arguments for the Label component.
|
9
9
|
class Label < Base
|
10
10
|
SCHEME_MAPPINGS = Primer::ViewComponents::Constants.get(
|
11
|
-
component: "Primer::
|
11
|
+
component: "Primer::Beta::Label",
|
12
12
|
constant: "SCHEME_MAPPINGS",
|
13
13
|
symbolize: true
|
14
14
|
).freeze
|
15
15
|
|
16
16
|
SIZE_MAPPINGS = Primer::ViewComponents::Constants.get(
|
17
|
-
component: "Primer::
|
17
|
+
component: "Primer::Beta::Label",
|
18
18
|
constant: "SIZE_MAPPINGS",
|
19
19
|
symbolize: true
|
20
20
|
).freeze
|
21
21
|
|
22
22
|
DEFAULT_TAG = Primer::ViewComponents::Constants.get(
|
23
|
-
component: "Primer::
|
23
|
+
component: "Primer::Beta::Label",
|
24
24
|
constant: "DEFAULT_TAG"
|
25
25
|
).freeze
|
26
26
|
|
27
27
|
INLINE_CLASS = Primer::ViewComponents::Constants.get(
|
28
|
-
component: "Primer::
|
28
|
+
component: "Primer::Beta::Label",
|
29
29
|
constant: "INLINE_CLASS"
|
30
30
|
).freeze
|
31
31
|
|
@@ -11,14 +11,14 @@ module ERBLint
|
|
11
11
|
include Autocorrectable
|
12
12
|
|
13
13
|
TAGS = Primer::ViewComponents::Constants.get(
|
14
|
-
component: "Primer::
|
14
|
+
component: "Primer::Beta::Label",
|
15
15
|
constant: "TAG_OPTIONS"
|
16
16
|
).freeze
|
17
17
|
|
18
18
|
CLASSES = %w[Label].freeze
|
19
|
-
MESSAGE = "We are migrating labels to use [Primer::
|
19
|
+
MESSAGE = "We are migrating labels to use [Primer::Beta::Label](https://primer.style/view-components/components/label), please try to use that instead of raw HTML."
|
20
20
|
ARGUMENT_MAPPER = ArgumentMappers::Label
|
21
|
-
COMPONENT = "Primer::
|
21
|
+
COMPONENT = "Primer::Beta::Label"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -9,10 +9,10 @@ module RuboCop
|
|
9
9
|
# This cop ensures that components don't use deprecated `Label` schemes.
|
10
10
|
#
|
11
11
|
# bad
|
12
|
-
# Primer::
|
12
|
+
# Primer::Beta::Label.new(scheme: :info)
|
13
13
|
#
|
14
14
|
# good
|
15
|
-
# Primer::
|
15
|
+
# Primer::Beta::Label.new(scheme: :accent)
|
16
16
|
class DeprecatedLabelSchemes < BaseCop
|
17
17
|
INVALID_MESSAGE = <<~STR
|
18
18
|
Avoid using deprecated schemes: https://primer.style/view-components/deprecated#labelcomponent.
|
@@ -60,7 +60,7 @@ module RuboCop
|
|
60
60
|
def label_node?(node)
|
61
61
|
return if node.nil?
|
62
62
|
|
63
|
-
node.method_name == :new && !node.receiver.nil? && node.receiver.const_name == "Primer::
|
63
|
+
node.method_name == :new && !node.receiver.nil? && node.receiver.const_name == "Primer::Beta::Label"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -9,16 +9,16 @@ module RuboCop
|
|
9
9
|
# This cop ensures that `LabelComponent`s don't use the old `variant` argument.
|
10
10
|
#
|
11
11
|
# bad
|
12
|
-
# Primer::
|
12
|
+
# Primer::Beta::Label.new(variant: :large)
|
13
13
|
#
|
14
14
|
# good
|
15
|
-
# Primer::
|
15
|
+
# Primer::Beta::Label.new(size: :large)
|
16
16
|
#
|
17
17
|
# bad
|
18
|
-
# Primer::
|
18
|
+
# Primer::Beta::Label.new(variant: :inline)
|
19
19
|
#
|
20
20
|
# good
|
21
|
-
# Primer::
|
21
|
+
# Primer::Beta::Label.new(inline: true)
|
22
22
|
class DeprecatedLabelVariants < BaseCop
|
23
23
|
def on_send(node)
|
24
24
|
return unless label_node?(node)
|
@@ -63,7 +63,7 @@ module RuboCop
|
|
63
63
|
def label_node?(node)
|
64
64
|
return if node.nil?
|
65
65
|
|
66
|
-
node.method_name == :new && !node.receiver.nil? && node.receiver.const_name == "Primer::
|
66
|
+
node.method_name == :new && !node.receiver.nil? && node.receiver.const_name == "Primer::Beta::Label"
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
data/lib/tasks/docs.rake
CHANGED
@@ -31,12 +31,13 @@ namespace :docs do
|
|
31
31
|
components = [
|
32
32
|
Primer::Beta::IconButton,
|
33
33
|
Primer::Beta::Button,
|
34
|
+
Primer::Alpha::SegmentedControl,
|
34
35
|
Primer::Alpha::Layout,
|
35
36
|
Primer::HellipButton,
|
36
|
-
Primer::Image,
|
37
|
+
Primer::Alpha::Image,
|
37
38
|
Primer::LocalTime,
|
38
39
|
Primer::OcticonSymbolsComponent,
|
39
|
-
Primer::ImageCrop,
|
40
|
+
Primer::Alpha::ImageCrop,
|
40
41
|
Primer::IconButton,
|
41
42
|
Primer::Beta::AutoComplete,
|
42
43
|
Primer::Beta::AutoComplete::Item,
|
@@ -61,9 +62,9 @@ namespace :docs do
|
|
61
62
|
Primer::Beta::Flash,
|
62
63
|
Primer::Beta::Heading,
|
63
64
|
Primer::Alpha::HiddenTextExpander,
|
64
|
-
Primer::
|
65
|
+
Primer::Beta::Label,
|
65
66
|
Primer::LayoutComponent,
|
66
|
-
Primer::
|
67
|
+
Primer::Beta::Link,
|
67
68
|
Primer::Markdown,
|
68
69
|
Primer::MenuComponent,
|
69
70
|
Primer::Navigation::TabComponent,
|
@@ -99,7 +100,7 @@ namespace :docs do
|
|
99
100
|
js_components = [
|
100
101
|
Primer::Dropdown,
|
101
102
|
Primer::LocalTime,
|
102
|
-
Primer::ImageCrop,
|
103
|
+
Primer::Alpha::ImageCrop,
|
103
104
|
Primer::Beta::AutoComplete,
|
104
105
|
Primer::ClipboardCopy,
|
105
106
|
Primer::TabContainerComponent,
|
@@ -109,7 +110,7 @@ namespace :docs do
|
|
109
110
|
Primer::Alpha::Tooltip,
|
110
111
|
Primer::ButtonComponent,
|
111
112
|
Primer::IconButton,
|
112
|
-
Primer::
|
113
|
+
Primer::Beta::Link,
|
113
114
|
Primer::Alpha::ToggleSwitch,
|
114
115
|
Primer::Alpha::ActionList,
|
115
116
|
Primer::Alpha::NavList,
|
@@ -152,7 +153,7 @@ namespace :docs do
|
|
152
153
|
f.puts("componentId: #{data[:component_id]}")
|
153
154
|
f.puts("status: #{data[:status]}")
|
154
155
|
f.puts("source: #{data[:source]}")
|
155
|
-
f.puts("a11yReviewed:
|
156
|
+
f.puts("a11yReviewed: #{data[:a11y_reviewed]}")
|
156
157
|
f.puts("lookbook: #{data[:lookbook]}") if preview_exists?(component)
|
157
158
|
f.puts("---")
|
158
159
|
f.puts
|
@@ -227,7 +228,9 @@ namespace :docs do
|
|
227
228
|
|
228
229
|
component_args = {
|
229
230
|
"component" => data[:title],
|
231
|
+
"status" => component.status.to_s,
|
230
232
|
"source" => data[:source],
|
233
|
+
"lookbook" => data[:lookbook],
|
231
234
|
"parameters" => args
|
232
235
|
}
|
233
236
|
|
@@ -485,11 +488,13 @@ namespace :docs do
|
|
485
488
|
status_module, short_name, class_name = status_module_and_short_name(component)
|
486
489
|
status_path = status_module.nil? ? "" : "#{status_module}/"
|
487
490
|
status = component.status.to_s
|
491
|
+
a11y_reviewed = component.audited_at.nil? ? "false" : "true"
|
488
492
|
|
489
493
|
{
|
490
494
|
title: class_name,
|
491
495
|
component_id: short_name.underscore,
|
492
496
|
status: status.capitalize,
|
497
|
+
a11y_reviewed: a11y_reviewed,
|
493
498
|
source: source_url(component),
|
494
499
|
lookbook: lookbook_url(component),
|
495
500
|
path: "docs/content/components/#{status_path}#{short_name.downcase}.md",
|
data/lib/tasks/test.rake
CHANGED
@@ -4,73 +4,70 @@ require "rake/testtask"
|
|
4
4
|
|
5
5
|
namespace :test do
|
6
6
|
desc "Run all tests"
|
7
|
-
task all: [
|
7
|
+
task all: [
|
8
|
+
:components,
|
9
|
+
:lib,
|
10
|
+
:system,
|
11
|
+
:accessibility,
|
12
|
+
:performance
|
13
|
+
]
|
8
14
|
|
9
15
|
Rake::TestTask.new(:single) do |t|
|
10
|
-
ENV["TZ"] = "Asia/Taipei"
|
11
|
-
|
12
16
|
t.warning = false
|
13
17
|
t.libs << "test"
|
14
18
|
t.libs << "lib"
|
15
19
|
t.test_files = FileList[ENV["TEST"]]
|
16
20
|
end
|
17
21
|
|
18
|
-
Rake::TestTask.new(:
|
19
|
-
|
20
|
-
|
22
|
+
Rake::TestTask.new(:components) do |t|
|
23
|
+
t.warning = false
|
24
|
+
t.libs << "test"
|
25
|
+
t.test_files = FileList[
|
26
|
+
"test/components/**/*_test.rb"
|
27
|
+
]
|
28
|
+
end
|
21
29
|
|
30
|
+
Rake::TestTask.new(:lib) do |t|
|
22
31
|
t.warning = false
|
23
32
|
t.libs << "test"
|
24
33
|
t.libs << "lib"
|
25
34
|
t.test_files = FileList[
|
26
|
-
"test/
|
27
|
-
"test/lib/**/*_test.rb",
|
28
|
-
"test/primer/**/*_test.rb",
|
29
|
-
"test/linters/**/*_test.rb",
|
30
|
-
"test/rubocop/**/*_test.rb"
|
35
|
+
"test/lib/**/*_test.rb"
|
31
36
|
]
|
32
37
|
end
|
33
38
|
|
34
39
|
Rake::TestTask.new(:system) do |t|
|
35
|
-
ENV["TZ"] = "Asia/Taipei"
|
36
|
-
|
37
40
|
t.warning = false
|
38
41
|
t.libs << "test"
|
39
|
-
t.libs << "lib"
|
40
42
|
t.test_files = FileList["test/system/**/*_test.rb"]
|
41
43
|
end
|
42
44
|
|
43
45
|
Rake::TestTask.new(:performance) do |t|
|
44
|
-
|
45
|
-
|
46
|
-
t.libs << "test"
|
47
|
-
t.test_files = FileList["test/performance/**/*_test.rb", "test/performance/**/bench_*.rb"]
|
46
|
+
t.warning = false
|
48
47
|
t.verbose = true
|
48
|
+
t.libs << "test"
|
49
|
+
t.test_files = FileList[
|
50
|
+
"test/performance/**/*_test.rb",
|
51
|
+
"test/performance/**/bench_*.rb"
|
52
|
+
]
|
49
53
|
end
|
50
54
|
|
51
55
|
Rake::TestTask.new(:accessibility) do |t|
|
52
|
-
ENV["TZ"] = "Asia/Taipei"
|
53
|
-
|
54
56
|
t.warning = false
|
55
57
|
t.libs << "test"
|
56
|
-
t.libs << "lib"
|
57
58
|
t.test_files = FileList["test/accessibility_test.rb"]
|
58
59
|
end
|
59
60
|
|
60
61
|
Rake::TestTask.new(:snapshots) do |t|
|
61
|
-
ENV["TZ"] = "Asia/Taipei"
|
62
|
-
|
63
62
|
t.warning = false
|
64
63
|
t.libs << "test"
|
65
|
-
t.libs << "lib"
|
66
64
|
t.test_files = FileList["test/snapshots_test.rb"]
|
67
65
|
end
|
68
66
|
|
69
67
|
task :coverage do
|
70
68
|
require "simplecov"
|
71
69
|
|
72
|
-
|
73
|
-
SimpleCov.minimum_coverage 99
|
70
|
+
SimpleCov.minimum_coverage 100
|
74
71
|
SimpleCov.collate Dir["coverage/.resultset.json"], "rails"
|
75
72
|
end
|
76
73
|
end
|
@@ -4,6 +4,35 @@ module Primer
|
|
4
4
|
module Alpha
|
5
5
|
# @label ActionList
|
6
6
|
class ActionListPreview < ViewComponent::Preview
|
7
|
+
# @label Playground
|
8
|
+
#
|
9
|
+
# @param role text
|
10
|
+
# @param scheme [Symbol] select [full, inset]
|
11
|
+
# @param show_dividers toggle
|
12
|
+
def playground(
|
13
|
+
role: Primer::Alpha::ActionList::DEFAULT_ROLE,
|
14
|
+
scheme: Primer::Alpha::ActionList::DEFAULT_SCHEME,
|
15
|
+
show_dividers: false
|
16
|
+
)
|
17
|
+
render(Primer::Alpha::ActionList.new(
|
18
|
+
role: role,
|
19
|
+
scheme: scheme,
|
20
|
+
show_dividers: show_dividers,
|
21
|
+
aria: { label: "Action List" }
|
22
|
+
)) do |c|
|
23
|
+
c.with_heading(title: "Action List")
|
24
|
+
c.with_item(label: "Item one", href: "/") do |item|
|
25
|
+
item.with_leading_visual_icon(icon: :gear)
|
26
|
+
end
|
27
|
+
c.with_item(label: "Item two", href: "/") do |item|
|
28
|
+
item.with_leading_visual_icon(icon: :star)
|
29
|
+
end
|
30
|
+
c.with_item(label: "Item three", href: "/") do |item|
|
31
|
+
item.with_leading_visual_icon(icon: :heart)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
7
36
|
# @label Default
|
8
37
|
#
|
9
38
|
# @param role text
|
@@ -4,6 +4,16 @@ module Primer
|
|
4
4
|
module Alpha
|
5
5
|
# @label AutoComplete
|
6
6
|
class AutoCompletePreview < ViewComponent::Preview
|
7
|
+
# @label Playground
|
8
|
+
# @param label_text text
|
9
|
+
# @param is_label_visible toggle
|
10
|
+
# @param is_label_inline toggle
|
11
|
+
# @param with_icon toggle
|
12
|
+
# @param is_clearable toggle
|
13
|
+
def playground(label_text: "Select a fruit", is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false)
|
14
|
+
render(Primer::Alpha::AutoComplete.new(label_text: label_text, input_id: "input-id", list_id: "test-id", src: "/auto_complete?version=alpha", is_label_visible: is_label_visible, is_label_inline: is_label_inline, with_icon: with_icon, is_clearable: is_clearable))
|
15
|
+
end
|
16
|
+
|
7
17
|
# @label Default Options
|
8
18
|
# @param label_text text
|
9
19
|
# @param is_label_visible toggle
|