primer_view_components 0.0.120 → 0.0.122
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 +58 -0
- data/app/assets/styles/primer_view_components.css +2 -2
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_list.css.json +123 -1
- data/app/components/primer/alpha/auto_complete.css.json +23 -1
- data/app/components/primer/alpha/banner.css.json +24 -1
- data/app/components/primer/alpha/button_marketing.css.json +33 -1
- data/app/components/primer/alpha/check_box.rb +74 -0
- data/app/components/primer/alpha/check_box_group.rb +36 -0
- data/app/components/primer/alpha/dialog.css.json +82 -1
- data/app/components/primer/alpha/dialog.rb +1 -1
- data/app/components/primer/alpha/dropdown.css.json +40 -1
- data/app/components/primer/alpha/form_button.rb +32 -0
- data/app/components/primer/alpha/form_control.html.erb +26 -0
- data/app/components/primer/alpha/form_control.rb +105 -0
- data/app/components/primer/alpha/layout.css.json +80 -1
- data/app/components/primer/alpha/menu.css.json +28 -1
- data/app/components/primer/alpha/multi_input.rb +81 -0
- data/app/components/primer/alpha/radio_button.rb +25 -0
- data/app/components/primer/alpha/radio_button_group.rb +36 -0
- data/app/components/primer/alpha/segmented_control/item.rb +1 -0
- data/app/components/primer/alpha/segmented_control.css +1 -1
- data/app/components/primer/alpha/segmented_control.css.json +31 -1
- data/app/components/primer/alpha/segmented_control.css.map +1 -1
- data/app/components/primer/alpha/segmented_control.pcss +43 -12
- data/app/components/primer/alpha/segmented_control.rb +30 -0
- data/app/components/primer/alpha/select.rb +37 -0
- data/app/components/primer/alpha/submit_button.rb +32 -0
- data/app/components/primer/alpha/tab_nav.css.json +24 -1
- data/app/components/primer/alpha/tab_panels.rb +7 -0
- data/app/components/primer/alpha/text_area.rb +24 -0
- data/app/components/primer/alpha/text_field.css +2 -2
- data/app/components/primer/alpha/text_field.css.json +134 -1
- data/app/components/primer/alpha/text_field.css.map +1 -1
- data/app/components/primer/alpha/text_field.pcss +27 -0
- data/app/components/primer/alpha/text_field.rb +16 -20
- data/app/components/primer/alpha/toggle_switch.css +1 -1
- data/app/components/primer/alpha/toggle_switch.css.json +40 -1
- data/app/components/primer/alpha/toggle_switch.css.map +1 -1
- data/app/components/primer/alpha/toggle_switch.pcss +31 -61
- data/app/components/primer/alpha/underline_nav.css.json +28 -1
- data/app/components/primer/base_component.rb +3 -3
- data/app/components/primer/beta/avatar.css.json +17 -1
- data/app/components/primer/beta/avatar_stack.css.json +28 -1
- data/app/components/primer/beta/blankslate.css.json +22 -1
- data/app/components/primer/beta/border_box.css.json +54 -1
- data/app/components/primer/beta/breadcrumbs.css.json +11 -1
- data/app/components/primer/beta/button.css.json +71 -1
- data/app/components/primer/beta/close_button.rb +1 -1
- data/app/components/primer/beta/counter.css.json +10 -1
- data/app/components/primer/beta/flash.css.json +27 -1
- data/app/components/primer/beta/label.css.json +25 -1
- data/app/components/primer/beta/link.css.json +19 -1
- data/app/components/primer/beta/popover.css.json +39 -1
- data/app/components/primer/beta/progress_bar.css.json +10 -1
- data/app/components/primer/{local_time.d.ts → beta/relative_time.d.ts} +0 -0
- data/app/components/primer/{local_time.js → beta/relative_time.js} +0 -0
- data/app/components/primer/{local_time.ts → beta/relative_time.ts} +0 -0
- data/app/components/primer/beta/state.css.json +13 -1
- data/app/components/primer/beta/subhead.css.json +12 -1
- data/app/components/primer/beta/timeline_item.css.json +16 -1
- data/app/components/primer/beta/truncate.css.json +12 -1
- data/app/components/primer/component.rb +12 -3
- data/app/components/primer/primer.d.ts +1 -2
- data/app/components/primer/primer.js +1 -2
- data/app/components/primer/primer.ts +1 -2
- data/app/components/primer/truncate.css.json +13 -1
- data/app/forms/example_toggle_switch_form.rb +1 -1
- data/app/forms/{select_list_form.rb → select_form.rb} +1 -1
- data/app/lib/primer/css/layout.css.json +316 -1
- data/app/lib/primer/css/utilities.css.json +1659 -1
- data/app/lib/primer/view_helper.rb +0 -1
- data/lib/primer/deprecations.yml +0 -78
- data/lib/primer/form_components.rb +26 -6
- data/lib/primer/forms/acts_as_component.rb +12 -1
- data/lib/primer/forms/builder.rb +1 -17
- data/lib/primer/forms/button.rb +4 -1
- data/lib/primer/forms/check_box_group.html.erb +14 -9
- data/lib/primer/forms/check_box_group.rb +5 -0
- data/lib/primer/forms/dsl/check_box_group_input.rb +3 -4
- data/lib/primer/forms/dsl/input.rb +33 -2
- data/lib/primer/forms/dsl/input_methods.rb +49 -1
- data/lib/primer/forms/dsl/radio_button_group_input.rb +2 -3
- data/lib/primer/forms/dsl/{select_list_input.rb → select_input.rb} +2 -2
- data/lib/primer/forms/dsl/text_field_input.rb +7 -5
- data/lib/primer/forms/form_control.rb +0 -1
- data/lib/primer/forms/group.html.erb +1 -1
- data/lib/primer/forms/multi.html.erb +8 -6
- data/lib/primer/forms/multi.rb +2 -0
- data/lib/primer/forms/radio_button_group.html.erb +14 -9
- data/lib/primer/forms/radio_button_group.rb +5 -0
- data/lib/primer/forms/{select_list.html.erb → select.html.erb} +0 -0
- data/lib/primer/forms/{select_list.rb → select.rb} +2 -2
- data/lib/primer/forms/spacing_wrapper.html.erb +1 -1
- data/lib/primer/forms/text_area.rb +1 -1
- data/lib/primer/forms/text_field.rb +5 -1
- data/lib/primer/forms/toggle_switch_form.rb +10 -3
- data/lib/primer/forms/utils.rb +20 -0
- data/lib/primer/view_components/engine.rb +1 -1
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/primer/yard/backend.rb +1 -15
- data/lib/primer/yard/component_manifest.rb +44 -27
- data/lib/primer/yard/component_ref.rb +40 -0
- data/lib/primer/yard/docs_helper.rb +16 -2
- data/lib/primer/yard/legacy_gatsby_backend.rb +9 -15
- data/lib/primer/yard/lookbook_docs_helper.rb +32 -0
- data/lib/primer/yard/lookbook_pages_backend.rb +194 -0
- data/lib/primer/yard/registry.rb +6 -21
- data/lib/primer/yard/renders_many_handler.rb +1 -1
- data/lib/primer/yard/renders_one_handler.rb +1 -1
- data/lib/primer/yard.rb +14 -0
- data/lib/tasks/docs.rake +26 -13
- data/lib/tasks/static.rake +22 -0
- data/previews/pages/forms/01_introduction.md.erb +44 -0
- data/previews/pages/forms/02_getting_started.md.erb +125 -0
- data/previews/pages/forms/03_caption_templates.md.erb +30 -0
- data/previews/pages/forms/04_after_content.md.erb +39 -0
- data/previews/pages/forms/05_groups_layouts.md.erb +22 -0
- data/previews/pages/forms/06_miscellaneous_inputs.md.erb +43 -0
- data/previews/pages/forms/07_toggle_switch_forms.md.erb +58 -0
- data/previews/pages/forms/08_validations.md.erb +28 -0
- data/previews/pages/forms/09_compound_forms.md.erb +97 -0
- data/previews/primer/alpha/auto_complete_preview.rb +6 -6
- data/previews/primer/alpha/check_box_group_preview.rb +89 -0
- data/previews/primer/alpha/check_box_preview.rb +62 -0
- data/previews/primer/alpha/form_control_preview/playground.html.erb +9 -0
- data/previews/primer/alpha/form_control_preview.rb +106 -0
- data/previews/primer/alpha/multi_input_preview/playground.html.erb +41 -0
- data/previews/primer/alpha/multi_input_preview.rb +80 -0
- data/previews/primer/alpha/radio_button_group_preview.rb +83 -0
- data/previews/primer/alpha/radio_button_preview.rb +62 -0
- data/previews/primer/alpha/segmented_control_preview/with_label_and_caption.html.erb +9 -0
- data/previews/primer/alpha/segmented_control_preview/with_subhead_actions.html.erb +11 -0
- data/previews/primer/alpha/segmented_control_preview.rb +7 -1
- data/previews/primer/alpha/select_preview.rb +130 -0
- data/previews/primer/alpha/text_area_preview.rb +87 -0
- data/previews/primer/alpha/text_field_preview.rb +24 -1
- data/previews/primer/alpha/toggle_switch_preview.rb +9 -9
- data/previews/primer/beta/auto_complete_preview.rb +17 -17
- data/previews/primer/forms/forms_preview/example_toggle_switch_form.html.erb +2 -2
- data/previews/primer/forms/forms_preview/{select_list_form.html.erb → select_form.html.erb} +1 -1
- data/previews/primer/forms/forms_preview.rb +3 -1
- data/previews/primer/url_helpers.rb +1 -1
- data/static/arguments.json +1348 -1412
- data/static/audited_at.json +12 -21
- data/static/constants.json +20 -51
- data/static/previews.json +1812 -0
- data/static/statuses.json +10 -19
- metadata +47 -32
- data/app/components/primer/dropdown/menu.rb +0 -14
- data/app/components/primer/dropdown.rb +0 -7
- data/app/components/primer/hellip_button.rb +0 -7
- data/app/components/primer/label_component.rb +0 -7
- data/app/components/primer/link_component.rb +0 -7
- data/app/components/primer/local_time.rb +0 -63
- data/app/components/primer/markdown.rb +0 -7
- data/app/components/primer/menu_component.rb +0 -7
- data/app/components/primer/octicon_component.rb +0 -7
- data/app/components/primer/octicon_symbols_component.rb +0 -7
- data/app/components/primer/popover_component.rb +0 -8
- data/app/components/primer/spinner_component.rb +0 -7
- data/app/components/primer/state_component.rb +0 -7
- data/app/components/primer/subhead_component.rb +0 -7
- data/app/components/primer/tab_container_component.rb +0 -7
- data/app/components/primer/time_ago_component.d.ts +0 -1
- data/app/components/primer/time_ago_component.js +0 -1
- data/app/components/primer/time_ago_component.rb +0 -51
- data/app/components/primer/time_ago_component.ts +0 -1
- data/app/components/primer/timeline_item_component.rb +0 -13
- data/previews/primer/local_time_component_preview.rb +0 -57
- data/previews/primer/time_ago_component_preview.rb +0 -27
@@ -19,7 +19,7 @@ module Primer
|
|
19
19
|
label_text: label_text,
|
20
20
|
input_id: "input-id",
|
21
21
|
list_id: "test-id",
|
22
|
-
src:
|
22
|
+
src: UrlHelpers.autocomplete_index_path(version: "alpha"),
|
23
23
|
is_label_visible: is_label_visible,
|
24
24
|
is_label_inline: is_label_inline,
|
25
25
|
with_icon: with_icon,
|
@@ -42,7 +42,7 @@ module Primer
|
|
42
42
|
label_text: label_text,
|
43
43
|
input_id: "input-id",
|
44
44
|
list_id: "test-id",
|
45
|
-
src:
|
45
|
+
src: UrlHelpers.autocomplete_index_path(version: "alpha"),
|
46
46
|
is_label_visible: is_label_visible,
|
47
47
|
is_label_inline: is_label_inline,
|
48
48
|
with_icon: with_icon,
|
@@ -62,7 +62,7 @@ module Primer
|
|
62
62
|
label_text: "Select a fruit",
|
63
63
|
input_id: "input-id-1",
|
64
64
|
list_id: "test-id-1",
|
65
|
-
src:
|
65
|
+
src: UrlHelpers.autocomplete_index_path(version: "alpha"),
|
66
66
|
is_label_visible: false
|
67
67
|
)
|
68
68
|
)
|
@@ -77,7 +77,7 @@ module Primer
|
|
77
77
|
label_text: "Select a fruit",
|
78
78
|
input_id: "input-id-2",
|
79
79
|
list_id: "test-id-2",
|
80
|
-
src:
|
80
|
+
src: UrlHelpers.autocomplete_index_path(version: "alpha"),
|
81
81
|
is_label_inline: true
|
82
82
|
)
|
83
83
|
)
|
@@ -92,7 +92,7 @@ module Primer
|
|
92
92
|
label_text: "Select a fruit",
|
93
93
|
input_id: "input-id-3",
|
94
94
|
list_id: "test-id-3",
|
95
|
-
src:
|
95
|
+
src: UrlHelpers.autocomplete_index_path(version: "alpha"),
|
96
96
|
with_icon: true
|
97
97
|
)
|
98
98
|
)
|
@@ -107,7 +107,7 @@ module Primer
|
|
107
107
|
label_text: "Select a fruit",
|
108
108
|
input_id: "input-id-4",
|
109
109
|
list_id: "test-id-4",
|
110
|
-
src:
|
110
|
+
src: UrlHelpers.autocomplete_index_path(version: "alpha"),
|
111
111
|
is_clearable: true
|
112
112
|
)
|
113
113
|
)
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label CheckBoxGroup
|
6
|
+
class CheckBoxGroupPreview < 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-check-group",
|
15
|
+
label: "I would go into battle with:",
|
16
|
+
caption: "Qa'pla!",
|
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::CheckBoxGroup.new(**system_arguments)) do |component|
|
27
|
+
component.check_box(label: "Jean-Luc Picard", value: "picard")
|
28
|
+
component.check_box(label: "Hikaru Sulu", value: "sulu")
|
29
|
+
component.check_box(label: "Kathryn Janeway", value: "janeway")
|
30
|
+
component.check_box(label: "Benjamin Sisko", value: "sisko")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @label Default
|
35
|
+
def default
|
36
|
+
render(Primer::Alpha::CheckBoxGroup.new(name: "my-check-group", label: "I would go into battle with:")) do |component|
|
37
|
+
component.check_box(label: "Jean-Luc Picard", value: "picard")
|
38
|
+
component.check_box(label: "Hikaru Sulu", value: "sulu")
|
39
|
+
component.check_box(label: "Kathryn Janeway", value: "janeway")
|
40
|
+
component.check_box(label: "Benjamin Sisko", value: "sisko")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# @!group Options
|
45
|
+
#
|
46
|
+
# @label With caption
|
47
|
+
def with_caption
|
48
|
+
render(Primer::Alpha::CheckBoxGroup.new(caption: "With a caption", name: "my-check-group", label: "I would go into battle with:")) do |component|
|
49
|
+
component.check_box(label: "Jean-Luc Picard", value: "picard1")
|
50
|
+
component.check_box(label: "Hikaru Sulu", value: "sulu1")
|
51
|
+
component.check_box(label: "Kathryn Janeway", value: "janeway1")
|
52
|
+
component.check_box(label: "Benjamin Sisko", value: "sisko1")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# @label Visually hidden label
|
57
|
+
def visually_hide_label
|
58
|
+
render(Primer::Alpha::CheckBoxGroup.new(visually_hide_label: true, name: "my-check-group", label: "I would go into battle with:")) do |component|
|
59
|
+
component.check_box(label: "Jean-Luc Picard", value: "picard2")
|
60
|
+
component.check_box(label: "Hikaru Sulu", value: "sulu2")
|
61
|
+
component.check_box(label: "Kathryn Janeway", value: "janeway2")
|
62
|
+
component.check_box(label: "Benjamin Sisko", value: "sisko2")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# @label Full width
|
67
|
+
def full_width
|
68
|
+
render(Primer::Alpha::CheckBoxGroup.new(full_width: true, name: "my-check-group", label: "I would go into battle with:")) do |component|
|
69
|
+
component.check_box(label: "Jean-Luc Picard", value: "picard3")
|
70
|
+
component.check_box(label: "Hikaru Sulu", value: "sulu3")
|
71
|
+
component.check_box(label: "Kathryn Janeway", value: "janeway3")
|
72
|
+
component.check_box(label: "Benjamin Sisko", value: "sisko3")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# @label Disabled
|
77
|
+
def disabled
|
78
|
+
render(Primer::Alpha::CheckBoxGroup.new(disabled: true, name: "my-check-group", label: "I would go into battle with:")) do |component|
|
79
|
+
component.check_box(label: "Jean-Luc Picard", value: "picard4")
|
80
|
+
component.check_box(label: "Hikaru Sulu", value: "sulu4")
|
81
|
+
component.check_box(label: "Kathryn Janeway", value: "janeway4")
|
82
|
+
component.check_box(label: "Benjamin Sisko", value: "sisko4")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
#
|
86
|
+
# @!endgroup
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label CheckBox
|
6
|
+
class CheckBoxPreview < 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-check-box",
|
18
|
+
id: nil,
|
19
|
+
value: "picard",
|
20
|
+
label: "Jean-Luc Picard",
|
21
|
+
caption: "Make it so",
|
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::CheckBox.new(**system_arguments))
|
35
|
+
end
|
36
|
+
|
37
|
+
# @label Default
|
38
|
+
def default
|
39
|
+
render(Primer::Alpha::CheckBox.new(name: "my-check-box", label: "Jean-Luc Picard"))
|
40
|
+
end
|
41
|
+
|
42
|
+
# @!group Options
|
43
|
+
#
|
44
|
+
# @label With caption
|
45
|
+
def with_caption
|
46
|
+
render(Primer::Alpha::CheckBox.new(caption: "With a caption", name: "my-check-box1", label: "Jean-Luc Picard"))
|
47
|
+
end
|
48
|
+
|
49
|
+
# @label Visually hidden label
|
50
|
+
def visually_hide_label
|
51
|
+
render(Primer::Alpha::CheckBox.new(visually_hide_label: true, name: "my-check-box2", label: "Jean-Luc Picard"))
|
52
|
+
end
|
53
|
+
|
54
|
+
# @label Disabled
|
55
|
+
def disabled
|
56
|
+
render(Primer::Alpha::CheckBox.new(disabled: true, name: "my-check-box4", label: "Jean-Luc Picard"))
|
57
|
+
end
|
58
|
+
#
|
59
|
+
# @!endgroup
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= render(Primer::Alpha::FormControl.new(**system_arguments)) do |component| %>
|
2
|
+
<% component.with_input do |input_arguments| %>
|
3
|
+
<%= render(Primer::Alpha::SegmentedControl.new("aria-label": "Best character", **input_arguments)) do |seg| %>
|
4
|
+
<% seg.with_item(label: "Han Solo", selected: true) %>
|
5
|
+
<% seg.with_item(label: "Luke Skywalker") %>
|
6
|
+
<% seg.with_item(label: "Leia Organa") %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
@@ -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,9 @@
|
|
1
|
+
<%= render(Primer::Box.new(display: :flex, direction: :column)) do %>
|
2
|
+
<%= render(Primer::BaseComponent.new(tag: "span", id: "scLabel-horiz")) { "File view" } %>
|
3
|
+
<%= render(Primer::Alpha::SegmentedControl.new("aria-labelledby": "scLabel-horiz", "aria-describedby": "scCaption-horiz")) do |component| %>
|
4
|
+
<% component.with_item(label: "Preview", selected: true) %>
|
5
|
+
<% component.with_item(label: "Raw") %>
|
6
|
+
<% component.with_item(label: "Blame") %>
|
7
|
+
<% end %>
|
8
|
+
<%= render(Primer::Beta::Text.new(font_size: :small, mt: 1, color: :muted, id: "scCaption-horiz")) { "Change the way the file is viewed" } %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= render(Primer::Beta::Subhead.new) do |component| %>
|
2
|
+
<% component.with_heading(id: "scLabel-vert") { "File view" } %>
|
3
|
+
<% component.with_description(id: "scCaption-vert") { "Change the way the file is viewed" } %>
|
4
|
+
<% component.with_actions do %>
|
5
|
+
<%= render(Primer::Alpha::SegmentedControl.new("aria-labelledby": "scLabel-vert", "aria-describedby": "scCaption-vert")) do |component| %>
|
6
|
+
<% component.with_item(label: "Preview", selected: true) %>
|
7
|
+
<% component.with_item(label: "Raw") %>
|
8
|
+
<% component.with_item(label: "Blame") %>
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
@@ -152,13 +152,19 @@ module Primer
|
|
152
152
|
# NOTE: this preview uses a group to force it's display below the other groups
|
153
153
|
# @!group With link as tag
|
154
154
|
def with_link_as_tag
|
155
|
-
render(Primer::Alpha::SegmentedControl.new) do |component|
|
155
|
+
render(Primer::Alpha::SegmentedControl.new("aria-label": "File view")) do |component|
|
156
156
|
component.with_item(tag: :a, href: "#", label: "Preview", icon: :eye, selected: true)
|
157
157
|
component.with_item(tag: :a, href: "#", label: "Raw", icon: :"file-code")
|
158
158
|
component.with_item(tag: :a, href: "#", label: "Blame", icon: :people)
|
159
159
|
end
|
160
160
|
end
|
161
161
|
# @!endgroup
|
162
|
+
|
163
|
+
# @!group With aria labeled headings
|
164
|
+
def with_subhead_actions; end
|
165
|
+
|
166
|
+
def with_label_and_caption; end
|
167
|
+
# @!endgroup
|
162
168
|
end
|
163
169
|
end
|
164
170
|
end
|