primer_view_components 0.0.121 → 0.0.122

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/app/assets/styles/primer_view_components.css +2 -2
  4. data/app/assets/styles/primer_view_components.css.map +1 -1
  5. data/app/components/primer/alpha/action_list.css.json +123 -1
  6. data/app/components/primer/alpha/auto_complete.css.json +23 -1
  7. data/app/components/primer/alpha/banner.css.json +24 -1
  8. data/app/components/primer/alpha/button_marketing.css.json +33 -1
  9. data/app/components/primer/alpha/check_box.rb +74 -0
  10. data/app/components/primer/alpha/check_box_group.rb +36 -0
  11. data/app/components/primer/alpha/dialog.css.json +82 -1
  12. data/app/components/primer/alpha/dialog.rb +1 -1
  13. data/app/components/primer/alpha/dropdown.css.json +40 -1
  14. data/app/components/primer/alpha/form_button.rb +32 -0
  15. data/app/components/primer/alpha/form_control.html.erb +26 -0
  16. data/app/components/primer/alpha/form_control.rb +105 -0
  17. data/app/components/primer/alpha/layout.css.json +80 -1
  18. data/app/components/primer/alpha/menu.css.json +28 -1
  19. data/app/components/primer/alpha/multi_input.rb +81 -0
  20. data/app/components/primer/alpha/radio_button.rb +25 -0
  21. data/app/components/primer/alpha/radio_button_group.rb +36 -0
  22. data/app/components/primer/alpha/segmented_control.css +1 -1
  23. data/app/components/primer/alpha/segmented_control.css.json +31 -1
  24. data/app/components/primer/alpha/segmented_control.css.map +1 -1
  25. data/app/components/primer/alpha/segmented_control.pcss +43 -12
  26. data/app/components/primer/alpha/select.rb +37 -0
  27. data/app/components/primer/alpha/submit_button.rb +32 -0
  28. data/app/components/primer/alpha/tab_nav.css.json +24 -1
  29. data/app/components/primer/alpha/tab_panels.rb +7 -0
  30. data/app/components/primer/alpha/text_area.rb +24 -0
  31. data/app/components/primer/alpha/text_field.css +2 -2
  32. data/app/components/primer/alpha/text_field.css.json +134 -1
  33. data/app/components/primer/alpha/text_field.css.map +1 -1
  34. data/app/components/primer/alpha/text_field.pcss +27 -0
  35. data/app/components/primer/alpha/text_field.rb +15 -20
  36. data/app/components/primer/alpha/toggle_switch.css +1 -1
  37. data/app/components/primer/alpha/toggle_switch.css.json +40 -1
  38. data/app/components/primer/alpha/toggle_switch.css.map +1 -1
  39. data/app/components/primer/alpha/toggle_switch.pcss +31 -61
  40. data/app/components/primer/alpha/underline_nav.css.json +28 -1
  41. data/app/components/primer/beta/avatar.css.json +17 -1
  42. data/app/components/primer/beta/avatar_stack.css.json +28 -1
  43. data/app/components/primer/beta/blankslate.css.json +22 -1
  44. data/app/components/primer/beta/border_box.css.json +54 -1
  45. data/app/components/primer/beta/breadcrumbs.css.json +11 -1
  46. data/app/components/primer/beta/button.css.json +71 -1
  47. data/app/components/primer/beta/counter.css.json +10 -1
  48. data/app/components/primer/beta/flash.css.json +27 -1
  49. data/app/components/primer/beta/label.css.json +25 -1
  50. data/app/components/primer/beta/link.css.json +19 -1
  51. data/app/components/primer/beta/popover.css.json +39 -1
  52. data/app/components/primer/beta/progress_bar.css.json +10 -1
  53. data/app/components/primer/beta/state.css.json +13 -1
  54. data/app/components/primer/beta/subhead.css.json +12 -1
  55. data/app/components/primer/beta/timeline_item.css.json +16 -1
  56. data/app/components/primer/beta/truncate.css.json +12 -1
  57. data/app/components/primer/component.rb +10 -2
  58. data/app/components/primer/truncate.css.json +13 -1
  59. data/app/forms/{select_list_form.rb → select_form.rb} +1 -1
  60. data/app/lib/primer/css/layout.css.json +316 -1
  61. data/app/lib/primer/css/utilities.css.json +1659 -1
  62. data/lib/primer/form_components.rb +26 -6
  63. data/lib/primer/forms/builder.rb +1 -17
  64. data/lib/primer/forms/button.rb +4 -1
  65. data/lib/primer/forms/check_box_group.html.erb +14 -9
  66. data/lib/primer/forms/check_box_group.rb +5 -0
  67. data/lib/primer/forms/dsl/check_box_group_input.rb +3 -4
  68. data/lib/primer/forms/dsl/input.rb +33 -2
  69. data/lib/primer/forms/dsl/input_methods.rb +49 -1
  70. data/lib/primer/forms/dsl/radio_button_group_input.rb +2 -3
  71. data/lib/primer/forms/dsl/{select_list_input.rb → select_input.rb} +2 -2
  72. data/lib/primer/forms/dsl/text_field_input.rb +7 -5
  73. data/lib/primer/forms/form_control.rb +0 -1
  74. data/lib/primer/forms/group.html.erb +1 -1
  75. data/lib/primer/forms/multi.html.erb +8 -6
  76. data/lib/primer/forms/multi.rb +2 -0
  77. data/lib/primer/forms/radio_button_group.html.erb +14 -9
  78. data/lib/primer/forms/radio_button_group.rb +5 -0
  79. data/lib/primer/forms/{select_list.html.erb → select.html.erb} +0 -0
  80. data/lib/primer/forms/{select_list.rb → select.rb} +2 -2
  81. data/lib/primer/forms/spacing_wrapper.html.erb +1 -1
  82. data/lib/primer/forms/text_area.rb +1 -1
  83. data/lib/primer/forms/text_field.rb +5 -1
  84. data/lib/primer/forms/utils.rb +20 -0
  85. data/lib/primer/view_components/engine.rb +1 -1
  86. data/lib/primer/view_components/version.rb +1 -1
  87. data/lib/primer/yard/backend.rb +1 -15
  88. data/lib/primer/yard/component_manifest.rb +44 -25
  89. data/lib/primer/yard/component_ref.rb +40 -0
  90. data/lib/primer/yard/docs_helper.rb +16 -2
  91. data/lib/primer/yard/legacy_gatsby_backend.rb +9 -15
  92. data/lib/primer/yard/lookbook_docs_helper.rb +32 -0
  93. data/lib/primer/yard/lookbook_pages_backend.rb +194 -0
  94. data/lib/primer/yard/registry.rb +6 -21
  95. data/lib/primer/yard/renders_many_handler.rb +1 -1
  96. data/lib/primer/yard/renders_one_handler.rb +1 -1
  97. data/lib/primer/yard.rb +14 -0
  98. data/lib/tasks/docs.rake +26 -13
  99. data/previews/pages/forms/01_introduction.md.erb +44 -0
  100. data/previews/pages/forms/02_getting_started.md.erb +125 -0
  101. data/previews/pages/forms/03_caption_templates.md.erb +30 -0
  102. data/previews/pages/forms/04_after_content.md.erb +39 -0
  103. data/previews/pages/forms/05_groups_layouts.md.erb +22 -0
  104. data/previews/pages/forms/06_miscellaneous_inputs.md.erb +43 -0
  105. data/previews/pages/forms/07_toggle_switch_forms.md.erb +58 -0
  106. data/previews/pages/forms/08_validations.md.erb +28 -0
  107. data/previews/pages/forms/09_compound_forms.md.erb +97 -0
  108. data/previews/primer/alpha/check_box_group_preview.rb +89 -0
  109. data/previews/primer/alpha/check_box_preview.rb +62 -0
  110. data/previews/primer/alpha/form_control_preview/playground.html.erb +9 -0
  111. data/previews/primer/alpha/form_control_preview.rb +106 -0
  112. data/previews/primer/alpha/multi_input_preview/playground.html.erb +41 -0
  113. data/previews/primer/alpha/multi_input_preview.rb +80 -0
  114. data/previews/primer/alpha/radio_button_group_preview.rb +83 -0
  115. data/previews/primer/alpha/radio_button_preview.rb +62 -0
  116. data/previews/primer/alpha/select_preview.rb +130 -0
  117. data/previews/primer/alpha/text_area_preview.rb +87 -0
  118. data/previews/primer/alpha/text_field_preview.rb +10 -1
  119. data/previews/primer/forms/forms_preview/example_toggle_switch_form.html.erb +2 -2
  120. data/previews/primer/forms/forms_preview/{select_list_form.html.erb → select_form.html.erb} +1 -1
  121. data/previews/primer/forms/forms_preview.rb +3 -1
  122. data/static/arguments.json +1358 -1328
  123. data/static/audited_at.json +10 -0
  124. data/static/constants.json +20 -0
  125. data/static/previews.json +218 -40
  126. data/static/statuses.json +10 -0
  127. metadata +41 -7
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # @label FormControl
6
+ class FormControlPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param label text
10
+ # @param caption text
11
+ # @param validation_message text
12
+ # @param required toggle
13
+ # @param visually_hide_label toggle
14
+ # @param full_width toggle
15
+ def playground(
16
+ label: "Best character",
17
+ caption: "May the force be with you",
18
+ validation_message: "Something went wrong",
19
+ required: false,
20
+ visually_hide_label: false,
21
+ full_width: false
22
+ )
23
+ render_with_template(
24
+ locals: {
25
+ system_arguments: {
26
+ label: label,
27
+ caption: caption,
28
+ validation_message: validation_message,
29
+ required: required,
30
+ visually_hide_label: visually_hide_label,
31
+ full_width: full_width
32
+ }
33
+ }
34
+ )
35
+ end
36
+
37
+ # @label Default
38
+ def default
39
+ render_with_template(
40
+ template: "primer/alpha/form_control_preview/playground",
41
+ locals: {
42
+ system_arguments: {
43
+ label: "Best character"
44
+ }
45
+ }
46
+ )
47
+ end
48
+
49
+ # @!group Options
50
+ #
51
+ # @label With caption
52
+ def with_caption
53
+ render_with_template(
54
+ template: "primer/alpha/form_control_preview/playground",
55
+ locals: {
56
+ system_arguments: {
57
+ label: "Best character",
58
+ caption: "May the force be with you"
59
+ }
60
+ }
61
+ )
62
+ end
63
+
64
+ # @label With validation message
65
+ def with_validation_message
66
+ render_with_template(
67
+ template: "primer/alpha/form_control_preview/playground",
68
+ locals: {
69
+ system_arguments: {
70
+ label: "Best character",
71
+ validation_message: "Something went wrong"
72
+ }
73
+ }
74
+ )
75
+ end
76
+
77
+ # @label Required
78
+ def required
79
+ render_with_template(
80
+ template: "primer/alpha/form_control_preview/playground",
81
+ locals: {
82
+ system_arguments: {
83
+ label: "Best character",
84
+ required: true
85
+ }
86
+ }
87
+ )
88
+ end
89
+
90
+ # @label With visually hidden label
91
+ def with_visually_hidden_label
92
+ render_with_template(
93
+ template: "primer/alpha/form_control_preview/playground",
94
+ locals: {
95
+ system_arguments: {
96
+ label: "Best character",
97
+ visually_hide_label: true
98
+ }
99
+ }
100
+ )
101
+ end
102
+ #
103
+ # @!endgroup
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,41 @@
1
+ <em>
2
+ <p class="color-fg-accent">This select list controls which field is visible.</p>
3
+ </em>
4
+
5
+ <%= render(Primer::Alpha::Select.new(name: :dietary_pref, label: "Dietary preference")) do |c| %>
6
+ <% c.option(label: "Meatatarian", value: "meatatarian") %>
7
+ <% c.option(label: "Vegetarian", value: "vegetarian") %>
8
+ <% end %>
9
+
10
+ <hr>
11
+
12
+ <em>
13
+ <p class="color-fg-accent">This is the multi input.</p>
14
+ </em>
15
+
16
+ <%= render(Primer::Alpha::MultiInput.new(name: :dish, **system_arguments)) do |c| %>
17
+ <% c.select_list(name: :meatatarian) do |list| %>
18
+ <% list.option(label: "Steak", value: "steak") %>
19
+ <% list.option(label: "Salmon", value: "salmon") %>
20
+ <% end %>
21
+ <% c.select_list(name: :vegetarian, hidden: true) do |list| %>
22
+ <% list.option(label: "Portobello mushroom", value: "portobello") %>
23
+ <% list.option(label: "Tofu curry", value: "tofu") %>
24
+ <% end %>
25
+ <% end %>
26
+
27
+ <script type="text/javascript" data-eval="true">
28
+ const dietaryPrefList = document.querySelector("[name=dietary_pref]");
29
+ const dishMulti = document.querySelector("[data-name=dish]");
30
+
31
+ dietaryPrefList.onchange = (evt) => {
32
+ switch (evt.target.value) {
33
+ case 'meatatarian':
34
+ dishMulti.activateField('meatatarian');
35
+ break;
36
+ case 'vegetarian':
37
+ dishMulti.activateField('vegetarian');
38
+ break;
39
+ }
40
+ };
41
+ </script>
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # @label MultiInput
6
+ class MultiInputPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param label text
10
+ # @param caption text
11
+ # @param disabled toggle
12
+ def playground(
13
+ label: "Dietary preference",
14
+ caption: "What'll ya have?",
15
+ disabled: false
16
+ )
17
+ render_with_template(
18
+ locals: {
19
+ system_arguments: {
20
+ label: label,
21
+ caption: caption,
22
+ disabled: disabled
23
+ }
24
+ }
25
+ )
26
+ end
27
+
28
+ # @label Default
29
+ def default
30
+ render_with_template(
31
+ template: "primer/alpha/multi_input_preview/playground",
32
+ locals: {
33
+ system_arguments: {
34
+ label: "Dietary preference"
35
+ }
36
+ }
37
+ )
38
+ end
39
+
40
+ # @label With caption
41
+ def with_caption
42
+ render_with_template(
43
+ template: "primer/alpha/multi_input_preview/playground",
44
+ locals: {
45
+ system_arguments: {
46
+ label: "Dietary preference",
47
+ caption: "What'll ya have?"
48
+ }
49
+ }
50
+ )
51
+ end
52
+
53
+ # @label Visually hidden label
54
+ def visually_hide_label
55
+ render_with_template(
56
+ template: "primer/alpha/multi_input_preview/playground",
57
+ locals: {
58
+ system_arguments: {
59
+ label: "Dietary preference",
60
+ visually_hide_label: true
61
+ }
62
+ }
63
+ )
64
+ end
65
+
66
+ # @label Disabled
67
+ def disabled
68
+ render_with_template(
69
+ template: "primer/alpha/multi_input_preview/playground",
70
+ locals: {
71
+ system_arguments: {
72
+ label: "Dietary preference",
73
+ disabled: true
74
+ }
75
+ }
76
+ )
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # @label RadioButtonGroup
6
+ class RadioButtonGroupPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param name text
10
+ # @param label text
11
+ # @param caption text
12
+ # @param disabled toggle
13
+ def playground(
14
+ name: "my-radio-group",
15
+ label: "Question: what kind of bear is best?",
16
+ caption: "There are basically two schools of thought",
17
+ disabled: false
18
+ )
19
+ system_arguments = {
20
+ name: name,
21
+ label: label,
22
+ caption: caption,
23
+ disabled: disabled
24
+ }
25
+
26
+ render(Primer::Alpha::RadioButtonGroup.new(**system_arguments)) do |component|
27
+ component.radio_button(label: "Bears", value: "bears")
28
+ component.radio_button(label: "Beets", value: "beets")
29
+ component.radio_button(label: "Battlestar Galactica", value: "bsg")
30
+ end
31
+ end
32
+
33
+ # @label Default
34
+ def default
35
+ render(Primer::Alpha::RadioButtonGroup.new(name: "my-radio-group", label: "Question: what kind of bear is best?")) do |component|
36
+ component.radio_button(label: "Bears", value: "bears")
37
+ component.radio_button(label: "Beets", value: "beets")
38
+ component.radio_button(label: "Battlestar Galactica", value: "bsg")
39
+ end
40
+ end
41
+
42
+ # @!group Options
43
+ #
44
+ # @label With caption
45
+ def with_caption
46
+ render(Primer::Alpha::RadioButtonGroup.new(caption: "With a caption", name: "my-radio-group", label: "Question: what kind of bear is best?")) do |component|
47
+ component.radio_button(label: "Bears", value: "bears1")
48
+ component.radio_button(label: "Beets", value: "beets1")
49
+ component.radio_button(label: "Battlestar Galactica", value: "bsg1")
50
+ end
51
+ end
52
+
53
+ # @label Visually hidden label
54
+ def visually_hide_label
55
+ render(Primer::Alpha::RadioButtonGroup.new(visually_hide_label: true, name: "my-radio-group", label: "Question: what kind of bear is best?")) do |component|
56
+ component.radio_button(label: "Bears", value: "bears2")
57
+ component.radio_button(label: "Beets", value: "beets2")
58
+ component.radio_button(label: "Battlestar Galactica", value: "bsg2")
59
+ end
60
+ end
61
+
62
+ # @label Full width
63
+ def full_width
64
+ render(Primer::Alpha::RadioButtonGroup.new(full_width: true, name: "my-radio-group", label: "Question: what kind of bear is best?")) do |component|
65
+ component.radio_button(label: "Bears", value: "bears3")
66
+ component.radio_button(label: "Beets", value: "beets3")
67
+ component.radio_button(label: "Battlestar Galactica", value: "bsg3")
68
+ end
69
+ end
70
+
71
+ # @label Disabled
72
+ def disabled
73
+ render(Primer::Alpha::RadioButtonGroup.new(disabled: true, name: "my-radio-group", label: "Question: what kind of bear is best?")) do |component|
74
+ component.radio_button(label: "Bears", value: "bears4")
75
+ component.radio_button(label: "Beets", value: "beets4")
76
+ component.radio_button(label: "Battlestar Galactica", value: "bsg4")
77
+ end
78
+ end
79
+ #
80
+ # @!endgroup
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # @label RadioButton
6
+ class RadioButtonPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param name text
10
+ # @param id text
11
+ # @param value text
12
+ # @param label text
13
+ # @param caption text
14
+ # @param visually_hide_label toggle
15
+ # @param disabled toggle
16
+ def playground(
17
+ name: "my-radio-button",
18
+ id: nil,
19
+ value: "bsg",
20
+ label: "Battlestar Galactica",
21
+ caption: "A pretty good show",
22
+ visually_hide_label: false,
23
+ disabled: false
24
+ )
25
+ system_arguments = {
26
+ name: name,
27
+ value: value,
28
+ label: label,
29
+ caption: caption,
30
+ visually_hide_label: visually_hide_label,
31
+ disabled: disabled
32
+ }
33
+
34
+ render(Primer::Alpha::RadioButton.new(**system_arguments))
35
+ end
36
+
37
+ # @label Default
38
+ def default
39
+ render(Primer::Alpha::RadioButton.new(name: "my-radio-button", label: "Battlestar Galactica", value: "bsg"))
40
+ end
41
+
42
+ # @!group Options
43
+ #
44
+ # @label With caption
45
+ def with_caption
46
+ render(Primer::Alpha::RadioButton.new(caption: "With a caption", name: "my-radio-button", label: "Battlestar Galactica", value: "bsg1"))
47
+ end
48
+
49
+ # @label Visually hidden label
50
+ def visually_hide_label
51
+ render(Primer::Alpha::RadioButton.new(visually_hide_label: true, name: "my-radio-button", label: "Battlestar Galactica", value: "bsg2"))
52
+ end
53
+
54
+ # @label Disabled
55
+ def disabled
56
+ render(Primer::Alpha::RadioButton.new(disabled: true, name: "my-radio-button", label: "Battlestar Galactica", value: "bsg4"))
57
+ end
58
+ #
59
+ # @!endgroup
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # @label Select
6
+ class SelectPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param name text
10
+ # @param id text
11
+ # @param label text
12
+ # @param caption text
13
+ # @param required toggle
14
+ # @param visually_hide_label toggle
15
+ # @param size [Symbol] select [small, medium, large]
16
+ # @param full_width toggle
17
+ # @param disabled toggle
18
+ # @param invalid toggle
19
+ # @param validation_message text
20
+ def playground(
21
+ name: "my-select-list",
22
+ id: "my-select-list",
23
+ label: "Favorite place to visit",
24
+ caption: "They're all good",
25
+ required: false,
26
+ visually_hide_label: false,
27
+ size: Primer::Forms::Dsl::Input::DEFAULT_SIZE.to_s,
28
+ full_width: false,
29
+ disabled: false,
30
+ invalid: false,
31
+ validation_message: nil
32
+ )
33
+ system_arguments = {
34
+ name: name,
35
+ id: id,
36
+ label: label,
37
+ caption: caption,
38
+ required: required,
39
+ visually_hide_label: visually_hide_label,
40
+ size: size,
41
+ full_width: full_width,
42
+ disabled: disabled,
43
+ invalid: invalid,
44
+ validation_message: validation_message
45
+ }
46
+
47
+ render(Primer::Alpha::Select.new(**system_arguments)) do |component|
48
+ component.option(label: "Lopez Island", value: "lopez")
49
+ component.option(label: "Shaw Island", value: "shaw")
50
+ component.option(label: "Orcas Island", value: "orcas")
51
+ component.option(label: "San Juan Island", value: "san_juan")
52
+ end
53
+ end
54
+
55
+ # @label Default
56
+ def default
57
+ render(Primer::Alpha::Select.new(name: "my-select-list", label: "Favorite place to visit")) do |component|
58
+ component.option(label: "Lopez Island", value: "lopez")
59
+ component.option(label: "Shaw Island", value: "shaw")
60
+ component.option(label: "Orcas Island", value: "orcas")
61
+ component.option(label: "San Juan Island", value: "san_juan")
62
+ end
63
+ end
64
+
65
+ # @!group Options
66
+ #
67
+ # @label With caption
68
+ def with_caption
69
+ render(Primer::Alpha::Select.new(caption: "With a caption", name: "my-select-list", label: "Favorite place to visit")) do |component|
70
+ component.option(label: "Lopez Island", value: "lopez")
71
+ component.option(label: "Shaw Island", value: "shaw")
72
+ component.option(label: "Orcas Island", value: "orcas")
73
+ component.option(label: "San Juan Island", value: "san_juan")
74
+ end
75
+ end
76
+
77
+ # @label Visually hidden label
78
+ def visually_hide_label
79
+ render(Primer::Alpha::Select.new(visually_hide_label: true, name: "my-select-list", label: "Favorite place to visit")) do |component|
80
+ component.option(label: "Lopez Island", value: "lopez")
81
+ component.option(label: "Shaw Island", value: "shaw")
82
+ component.option(label: "Orcas Island", value: "orcas")
83
+ component.option(label: "San Juan Island", value: "san_juan")
84
+ end
85
+ end
86
+
87
+ # @label Full width
88
+ def full_width
89
+ render(Primer::Alpha::Select.new(full_width: true, name: "my-select-list", label: "Favorite place to visit")) do |component|
90
+ component.option(label: "Lopez Island", value: "lopez")
91
+ component.option(label: "Shaw Island", value: "shaw")
92
+ component.option(label: "Orcas Island", value: "orcas")
93
+ component.option(label: "San Juan Island", value: "san_juan")
94
+ end
95
+ end
96
+
97
+ # @label Disabled
98
+ def disabled
99
+ render(Primer::Alpha::Select.new(disabled: true, name: "my-select-list", label: "Favorite place to visit")) do |component|
100
+ component.option(label: "Lopez Island", value: "lopez")
101
+ component.option(label: "Shaw Island", value: "shaw")
102
+ component.option(label: "Orcas Island", value: "orcas")
103
+ component.option(label: "San Juan Island", value: "san_juan")
104
+ end
105
+ end
106
+
107
+ # @label Invalid
108
+ def invalid
109
+ render(Primer::Alpha::Select.new(invalid: true, name: "my-select-list", label: "Favorite place to visit")) do |component|
110
+ component.option(label: "Lopez Island", value: "lopez")
111
+ component.option(label: "Shaw Island", value: "shaw")
112
+ component.option(label: "Orcas Island", value: "orcas")
113
+ component.option(label: "San Juan Island", value: "san_juan")
114
+ end
115
+ end
116
+
117
+ # @label With validation message
118
+ def with_validation_message
119
+ render(Primer::Alpha::Select.new(validation_message: "An error occurred!", name: "my-select-list", label: "Favorite place to visit")) do |component|
120
+ component.option(label: "Lopez Island", value: "lopez")
121
+ component.option(label: "Shaw Island", value: "shaw")
122
+ component.option(label: "Orcas Island", value: "orcas")
123
+ component.option(label: "San Juan Island", value: "san_juan")
124
+ end
125
+ end
126
+ #
127
+ # @!endgroup
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # @label TextArea
6
+ class TextAreaPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param name text
10
+ # @param id text
11
+ # @param label text
12
+ # @param caption text
13
+ # @param required toggle
14
+ # @param visually_hide_label toggle
15
+ # @param full_width toggle
16
+ # @param disabled toggle
17
+ # @param invalid toggle
18
+ # @param validation_message text
19
+ def playground(
20
+ name: "my-text-area",
21
+ id: "my-text-area",
22
+ label: "Tell me about yourself",
23
+ caption: "You can trust me, I'm a website",
24
+ required: false,
25
+ visually_hide_label: false,
26
+ full_width: false,
27
+ disabled: false,
28
+ invalid: false,
29
+ validation_message: nil
30
+ )
31
+ system_arguments = {
32
+ name: name,
33
+ id: id,
34
+ label: label,
35
+ caption: caption,
36
+ required: required,
37
+ visually_hide_label: visually_hide_label,
38
+ full_width: full_width,
39
+ disabled: disabled,
40
+ invalid: invalid,
41
+ validation_message: validation_message
42
+ }
43
+
44
+ render(Primer::Alpha::TextArea.new(**system_arguments))
45
+ end
46
+
47
+ # @label Default
48
+ def default
49
+ render(Primer::Alpha::TextArea.new(name: "my-text-area", label: "Tell me about yourself"))
50
+ end
51
+
52
+ # @!group Options
53
+ #
54
+ # @label With caption
55
+ def with_caption
56
+ render(Primer::Alpha::TextArea.new(caption: "With a caption", name: "my-text-area", label: "Tell me about yourself"))
57
+ end
58
+
59
+ # @label Visually hidden label
60
+ def visually_hide_label
61
+ render(Primer::Alpha::TextArea.new(visually_hide_label: true, name: "my-text-area", label: "Tell me about yourself"))
62
+ end
63
+
64
+ # @label Full width
65
+ def full_width
66
+ render(Primer::Alpha::TextArea.new(full_width: true, name: "my-text-area", label: "Tell me about yourself"))
67
+ end
68
+
69
+ # @label Disabled
70
+ def disabled
71
+ render(Primer::Alpha::TextArea.new(disabled: true, name: "my-text-area", label: "Tell me about yourself"))
72
+ end
73
+
74
+ # @label Invalid
75
+ def invalid
76
+ render(Primer::Alpha::TextArea.new(invalid: true, name: "my-text-area", label: "Tell me about yourself"))
77
+ end
78
+
79
+ # @label With validation message
80
+ def with_validation_message
81
+ render(Primer::Alpha::TextArea.new(validation_message: "An error occurred!", name: "my-text-area", label: "Tell me about yourself"))
82
+ end
83
+ #
84
+ # @!endgroup
85
+ end
86
+ end
87
+ end
@@ -9,6 +9,8 @@ module Primer
9
9
  # @param name text
10
10
  # @param id text
11
11
  # @param label text
12
+ # @param caption text
13
+ # @param required toggle
12
14
  # @param visually_hide_label toggle
13
15
  # @param size [Symbol] select [small, medium, large]
14
16
  # @param show_clear_button toggle
@@ -16,14 +18,17 @@ module Primer
16
18
  # @param full_width toggle
17
19
  # @param disabled toggle
18
20
  # @param invalid toggle
21
+ # @param validation_message text
19
22
  # @param placeholder text
20
23
  # @param inset toggle
21
24
  # @param monospace toggle
22
- # @param leading_visual_icon text
25
+ # @param leading_visual_icon octicon
23
26
  def playground(
24
27
  name: "my-text-field",
25
28
  id: "my-text-field",
26
29
  label: "My text field",
30
+ caption: "My text field",
31
+ required: false,
27
32
  visually_hide_label: false,
28
33
  size: Primer::Forms::Dsl::Input::DEFAULT_SIZE.to_s,
29
34
  show_clear_button: false,
@@ -31,6 +36,7 @@ module Primer
31
36
  full_width: false,
32
37
  disabled: false,
33
38
  invalid: false,
39
+ validation_message: nil,
34
40
  placeholder: nil,
35
41
  inset: false,
36
42
  monospace: false,
@@ -40,6 +46,8 @@ module Primer
40
46
  name: name,
41
47
  id: id,
42
48
  label: label,
49
+ caption: caption,
50
+ required: required,
43
51
  visually_hide_label: visually_hide_label,
44
52
  size: size,
45
53
  show_clear_button: show_clear_button,
@@ -47,6 +55,7 @@ module Primer
47
55
  full_width: full_width,
48
56
  disabled: disabled,
49
57
  invalid: invalid,
58
+ validation_message: validation_message,
50
59
  placeholder: placeholder,
51
60
  inset: inset,
52
61
  monospace: monospace
@@ -1,3 +1,3 @@
1
- <%= render(ExampleToggleSwitchForm.new(csrf: "let_me_in", src: toggle_switch_index_path, id: "success-toggle")) %>
1
+ <%= render(ExampleToggleSwitchForm.new(csrf: "let_me_in", label: "Good example", src: toggle_switch_index_path, id: "success-toggle")) %>
2
2
  <hr>
3
- <%= render(ExampleToggleSwitchForm.new(csrf: "a_bad_value", src: toggle_switch_index_path, id: "error-toggle")) %>
3
+ <%= render(ExampleToggleSwitchForm.new(csrf: "a_bad_value", label: "Bad example", src: toggle_switch_index_path, id: "error-toggle")) %>
@@ -1,3 +1,3 @@
1
1
  <%= primer_form_with(url: "/foo") do |f| %>
2
- <%= render(SelectListForm.new(f)) %>
2
+ <%= render(SelectForm.new(f)) %>
3
3
  <% end %>
@@ -3,6 +3,8 @@
3
3
  module Primer
4
4
  module Forms
5
5
  # :nodoc:
6
+ #
7
+ # @logical_path primer/
6
8
  class FormsPreview < ViewComponent::Preview
7
9
  def single_text_field_form; end
8
10
 
@@ -22,7 +24,7 @@ module Primer
22
24
 
23
25
  def array_check_box_group_form; end
24
26
 
25
- def select_list_form; end
27
+ def select_form; end
26
28
 
27
29
  def radio_button_with_nested_form; end
28
30