primer_view_components 0.35.2 → 0.36.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -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_bar.rb +2 -2
- data/app/components/primer/alpha/action_bar_element.js +0 -7
- data/app/components/primer/alpha/action_bar_element.ts +0 -8
- data/app/components/primer/base_component.rb +4 -1
- data/app/components/primer/beta/auto_complete.rb +1 -0
- data/app/components/primer/beta/button.rb +0 -11
- data/app/components/primer/beta/link.css +1 -1
- data/app/components/primer/beta/link.css.json +2 -1
- data/app/components/primer/beta/link.css.map +1 -1
- data/app/components/primer/beta/link.html.erb +18 -0
- data/app/components/primer/beta/link.pcss +9 -0
- data/app/components/primer/beta/link.rb +26 -14
- data/app/components/primer/button_component.rb +0 -11
- data/app/components/primer/component.rb +7 -0
- data/app/components/primer/conditional_wrapper.rb +5 -2
- data/app/forms/horizontal_form.rb +2 -0
- data/app/lib/primer/forms/auto_complete.rb +2 -1
- data/app/lib/primer/forms/dsl/hidden_input.rb +4 -0
- data/app/lib/primer/forms/group.rb +4 -1
- data/lib/primer/classify/utilities.yml +63 -0
- data/lib/primer/classify.rb +1 -26
- data/lib/primer/static/generate_form_previews.rb +44 -0
- data/lib/primer/static.rb +8 -0
- data/lib/primer/view_components/version.rb +2 -2
- data/lib/rubocop/config/default.yml +0 -3
- data/lib/tasks/custom_utilities.yml +63 -0
- data/previews/primer/beta/link_preview.rb +24 -2
- data/previews/primer/forms_preview.rb +21 -0
- data/static/classes.json +3 -0
- data/static/form_previews.json +113 -0
- metadata +5 -3
- data/lib/rubocop/cop/primer/system_argument_instead_of_class.rb +0 -57
@@ -3,48 +3,69 @@
|
|
3
3
|
module Primer
|
4
4
|
# :nodoc:
|
5
5
|
class FormsPreview < ViewComponent::Preview
|
6
|
+
# @snapshot
|
6
7
|
def single_text_field_form; end
|
7
8
|
|
9
|
+
# @snapshot
|
8
10
|
def multi_text_field_form; end
|
9
11
|
|
12
|
+
# @snapshot
|
10
13
|
def text_field_and_checkbox_form; end
|
11
14
|
|
15
|
+
# @snapshot
|
12
16
|
def horizontal_form; end
|
13
17
|
|
18
|
+
# @snapshot
|
14
19
|
def composed_form; end
|
15
20
|
|
21
|
+
# @snapshot
|
16
22
|
def submit_button_form; end
|
17
23
|
|
24
|
+
# @snapshot
|
18
25
|
def radio_button_group_form; end
|
19
26
|
|
27
|
+
# @snapshot
|
20
28
|
def check_box_group_form; end
|
21
29
|
|
30
|
+
# @snapshot
|
22
31
|
def array_check_box_group_form; end
|
23
32
|
|
33
|
+
# @snapshot
|
24
34
|
def select_form; end
|
25
35
|
|
36
|
+
# @snapshot
|
26
37
|
def action_menu_form(route_format: :html)
|
27
38
|
render_with_template(locals: { route_format: route_format })
|
28
39
|
end
|
29
40
|
|
41
|
+
# @snapshot
|
30
42
|
def radio_button_with_nested_form; end
|
31
43
|
|
44
|
+
# @snapshot
|
32
45
|
def check_box_with_nested_form; end
|
33
46
|
|
47
|
+
# @snapshot
|
34
48
|
def caption_template_form; end
|
35
49
|
|
50
|
+
# @snapshot
|
36
51
|
def after_content_form; end
|
37
52
|
|
53
|
+
# @snapshot
|
38
54
|
def invalid_form; end
|
39
55
|
|
56
|
+
# @snapshot
|
40
57
|
def multi_input_form; end
|
41
58
|
|
59
|
+
# @snapshot
|
42
60
|
def name_with_question_mark_form; end
|
43
61
|
|
62
|
+
# @snapshot
|
44
63
|
def immediate_validation_form; end
|
45
64
|
|
65
|
+
# @snapshot
|
46
66
|
def example_toggle_switch_form; end
|
47
67
|
|
68
|
+
# @snapshot
|
48
69
|
def auto_complete_form; end
|
49
70
|
end
|
50
71
|
end
|
data/static/classes.json
CHANGED
@@ -0,0 +1,113 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "forms",
|
4
|
+
"lookup_path": "primer/forms",
|
5
|
+
"examples": [
|
6
|
+
{
|
7
|
+
"preview_path": "primer/forms/single_text_field_form",
|
8
|
+
"name": "single_text_field_form",
|
9
|
+
"snapshot": "true"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"preview_path": "primer/forms/multi_text_field_form",
|
13
|
+
"name": "multi_text_field_form",
|
14
|
+
"snapshot": "true"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"preview_path": "primer/forms/text_field_and_checkbox_form",
|
18
|
+
"name": "text_field_and_checkbox_form",
|
19
|
+
"snapshot": "true"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"preview_path": "primer/forms/horizontal_form",
|
23
|
+
"name": "horizontal_form",
|
24
|
+
"snapshot": "true"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"preview_path": "primer/forms/composed_form",
|
28
|
+
"name": "composed_form",
|
29
|
+
"snapshot": "true"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"preview_path": "primer/forms/submit_button_form",
|
33
|
+
"name": "submit_button_form",
|
34
|
+
"snapshot": "true"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"preview_path": "primer/forms/radio_button_group_form",
|
38
|
+
"name": "radio_button_group_form",
|
39
|
+
"snapshot": "true"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"preview_path": "primer/forms/check_box_group_form",
|
43
|
+
"name": "check_box_group_form",
|
44
|
+
"snapshot": "true"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"preview_path": "primer/forms/array_check_box_group_form",
|
48
|
+
"name": "array_check_box_group_form",
|
49
|
+
"snapshot": "true"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"preview_path": "primer/forms/select_form",
|
53
|
+
"name": "select_form",
|
54
|
+
"snapshot": "true"
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"preview_path": "primer/forms/action_menu_form",
|
58
|
+
"name": "action_menu_form",
|
59
|
+
"snapshot": "true"
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"preview_path": "primer/forms/radio_button_with_nested_form",
|
63
|
+
"name": "radio_button_with_nested_form",
|
64
|
+
"snapshot": "true"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"preview_path": "primer/forms/check_box_with_nested_form",
|
68
|
+
"name": "check_box_with_nested_form",
|
69
|
+
"snapshot": "true"
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"preview_path": "primer/forms/caption_template_form",
|
73
|
+
"name": "caption_template_form",
|
74
|
+
"snapshot": "true"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"preview_path": "primer/forms/after_content_form",
|
78
|
+
"name": "after_content_form",
|
79
|
+
"snapshot": "true"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"preview_path": "primer/forms/invalid_form",
|
83
|
+
"name": "invalid_form",
|
84
|
+
"snapshot": "true"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"preview_path": "primer/forms/multi_input_form",
|
88
|
+
"name": "multi_input_form",
|
89
|
+
"snapshot": "true"
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"preview_path": "primer/forms/name_with_question_mark_form",
|
93
|
+
"name": "name_with_question_mark_form",
|
94
|
+
"snapshot": "true"
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"preview_path": "primer/forms/immediate_validation_form",
|
98
|
+
"name": "immediate_validation_form",
|
99
|
+
"snapshot": "true"
|
100
|
+
},
|
101
|
+
{
|
102
|
+
"preview_path": "primer/forms/example_toggle_switch_form",
|
103
|
+
"name": "example_toggle_switch_form",
|
104
|
+
"snapshot": "true"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"preview_path": "primer/forms/auto_complete_form",
|
108
|
+
"name": "auto_complete_form",
|
109
|
+
"snapshot": "true"
|
110
|
+
}
|
111
|
+
]
|
112
|
+
}
|
113
|
+
]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: primer_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.36.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -398,6 +398,7 @@ files:
|
|
398
398
|
- app/components/primer/beta/link.css
|
399
399
|
- app/components/primer/beta/link.css.json
|
400
400
|
- app/components/primer/beta/link.css.map
|
401
|
+
- app/components/primer/beta/link.html.erb
|
401
402
|
- app/components/primer/beta/link.pcss
|
402
403
|
- app/components/primer/beta/link.rb
|
403
404
|
- app/components/primer/beta/markdown.rb
|
@@ -654,6 +655,7 @@ files:
|
|
654
655
|
- lib/primer/static/generate_arguments.rb
|
655
656
|
- lib/primer/static/generate_audited_at.rb
|
656
657
|
- lib/primer/static/generate_constants.rb
|
658
|
+
- lib/primer/static/generate_form_previews.rb
|
657
659
|
- lib/primer/static/generate_info_arch.rb
|
658
660
|
- lib/primer/static/generate_previews.rb
|
659
661
|
- lib/primer/static/generate_statuses.rb
|
@@ -724,7 +726,6 @@ files:
|
|
724
726
|
- lib/rubocop/cop/primer/deprecated_layout_component.rb
|
725
727
|
- lib/rubocop/cop/primer/no_tag_memoize.rb
|
726
728
|
- lib/rubocop/cop/primer/primer_octicon.rb
|
727
|
-
- lib/rubocop/cop/primer/system_argument_instead_of_class.rb
|
728
729
|
- lib/rubocop/cop/primer/test_selector.rb
|
729
730
|
- lib/tasks/custom_utilities.yml
|
730
731
|
- previews/pages/forms/01_introduction.md.erb
|
@@ -943,6 +944,7 @@ files:
|
|
943
944
|
- static/audited_at.json
|
944
945
|
- static/classes.json
|
945
946
|
- static/constants.json
|
947
|
+
- static/form_previews.json
|
946
948
|
- static/info_arch.json
|
947
949
|
- static/previews.json
|
948
950
|
- static/statuses.json
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rubocop"
|
4
|
-
require "primer/classify/utilities"
|
5
|
-
|
6
|
-
# :nocov:
|
7
|
-
module RuboCop
|
8
|
-
module Cop
|
9
|
-
module Primer
|
10
|
-
# This cop ensures that components use System Arguments instead of CSS classes.
|
11
|
-
#
|
12
|
-
# bad
|
13
|
-
# Component.new(classes: "mr-1")
|
14
|
-
#
|
15
|
-
# good
|
16
|
-
# Component.new(mr: 1)
|
17
|
-
class SystemArgumentInsteadOfClass < BaseCop
|
18
|
-
INVALID_MESSAGE = <<~STR
|
19
|
-
Avoid using CSS classes when you can use System Arguments: https://primer.style/view-components/system-arguments.
|
20
|
-
STR
|
21
|
-
|
22
|
-
def on_send(node)
|
23
|
-
return unless valid_node?(node)
|
24
|
-
return unless node.arguments?
|
25
|
-
|
26
|
-
# we are looking for hash arguments and they are always last
|
27
|
-
kwargs = node.arguments.last
|
28
|
-
|
29
|
-
return unless kwargs.type == :hash
|
30
|
-
|
31
|
-
# find classes pair
|
32
|
-
classes_arg = kwargs.pairs.find { |kwarg| kwarg.key.value == :classes }
|
33
|
-
|
34
|
-
return if classes_arg.nil?
|
35
|
-
return unless classes_arg.value.type == :str
|
36
|
-
|
37
|
-
# get actual classes
|
38
|
-
classes = classes_arg.value.value
|
39
|
-
|
40
|
-
system_arguments = ::Primer::Classify::Utilities.classes_to_hash(classes)
|
41
|
-
|
42
|
-
# no classes are fixable
|
43
|
-
return if system_arguments[:classes] == classes
|
44
|
-
|
45
|
-
add_offense(classes_arg, message: INVALID_MESSAGE)
|
46
|
-
end
|
47
|
-
|
48
|
-
def autocorrect(node)
|
49
|
-
lambda do |corrector|
|
50
|
-
args = ::Primer::Classify::Utilities.classes_to_args(node.value.value)
|
51
|
-
corrector.replace(node.loc.expression, args)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|