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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/app/assets/javascripts/primer_view_components.js +1 -1
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  5. data/app/assets/styles/primer_view_components.css +1 -1
  6. data/app/assets/styles/primer_view_components.css.map +1 -1
  7. data/app/components/primer/alpha/action_list/item.rb +2 -2
  8. data/app/components/primer/alpha/action_list.rb +2 -0
  9. data/app/components/primer/alpha/image.rb +50 -0
  10. data/app/components/primer/{image_crop.d.ts → alpha/image_crop.d.ts} +0 -0
  11. data/app/components/primer/{image_crop.html.erb → alpha/image_crop.html.erb} +0 -0
  12. data/app/components/primer/{image_crop.js → alpha/image_crop.js} +0 -0
  13. data/app/components/primer/alpha/image_crop.rb +39 -0
  14. data/app/components/primer/{image_crop.ts → alpha/image_crop.ts} +0 -0
  15. data/app/components/primer/alpha/nav_list/item.rb +2 -0
  16. data/app/components/primer/alpha/nav_list/section.rb +2 -0
  17. data/app/components/primer/alpha/segmented_control/item.html.erb +13 -0
  18. data/app/components/primer/alpha/segmented_control/item.rb +29 -0
  19. data/app/components/primer/alpha/segmented_control.css +1 -0
  20. data/app/components/primer/alpha/segmented_control.css.map +1 -0
  21. data/app/components/primer/alpha/segmented_control.d.ts +11 -0
  22. data/app/components/primer/alpha/segmented_control.html.erb +7 -0
  23. data/app/components/primer/alpha/segmented_control.js +48 -0
  24. data/app/components/primer/alpha/segmented_control.pcss +121 -0
  25. data/app/components/primer/alpha/segmented_control.rb +92 -0
  26. data/app/components/primer/alpha/segmented_control.ts +41 -0
  27. data/app/components/primer/alpha/tooltip.rb +2 -2
  28. data/app/components/primer/beta/auto_complete/item.rb +2 -2
  29. data/app/components/primer/beta/avatar.rb +1 -1
  30. data/app/components/primer/beta/blankslate.rb +4 -4
  31. data/app/components/primer/beta/breadcrumbs.rb +1 -1
  32. data/app/components/primer/beta/button.rb +1 -1
  33. data/app/components/primer/beta/label.rb +100 -0
  34. data/app/components/primer/beta/link.rb +99 -0
  35. data/app/components/primer/component.rb +1 -0
  36. data/app/components/primer/image.rb +2 -41
  37. data/app/components/primer/image_crop.rb +2 -32
  38. data/app/components/primer/label_component.rb +2 -93
  39. data/app/components/primer/link_component.rb +2 -92
  40. data/app/components/primer/primer.d.ts +2 -1
  41. data/app/components/primer/primer.js +2 -1
  42. data/app/components/primer/primer.pcss +1 -0
  43. data/app/components/primer/primer.ts +2 -1
  44. data/app/components/primer/subhead_component.rb +1 -1
  45. data/app/components/primer/time_ago_component.rb +2 -0
  46. data/app/helpers/primer/form_helper.rb +1 -0
  47. data/app/lib/primer/view_helper.rb +1 -1
  48. data/lib/primer/deprecations.rb +4 -0
  49. data/lib/primer/form_components.rb +1 -0
  50. data/lib/primer/view_components/linters/argument_mappers/label.rb +4 -4
  51. data/lib/primer/view_components/linters/label_component_migration_counter.rb +3 -3
  52. data/lib/primer/view_components/version.rb +1 -1
  53. data/lib/rubocop/config/default.yml +0 -3
  54. data/lib/rubocop/cop/primer/deprecated_label_schemes.rb +3 -3
  55. data/lib/rubocop/cop/primer/deprecated_label_variants.rb +5 -5
  56. data/lib/tasks/docs.rake +12 -7
  57. data/lib/tasks/test.rake +23 -26
  58. data/previews/primer/alpha/action_list_preview.rb +29 -0
  59. data/previews/primer/alpha/auto_complete_preview.rb +10 -0
  60. data/previews/primer/alpha/button_marketing_preview.rb +9 -0
  61. data/previews/primer/alpha/dialog_preview.rb +18 -1
  62. data/previews/primer/alpha/hidden_text_expander_preview.rb +7 -0
  63. data/previews/primer/alpha/image_crop_preview.rb +31 -0
  64. data/previews/primer/alpha/layout_preview.rb +15 -0
  65. data/previews/primer/alpha/nav_list_preview.rb +29 -0
  66. data/previews/primer/alpha/segmented_control_preview.rb +75 -0
  67. data/previews/primer/alpha/tab_panels_preview.rb +15 -0
  68. data/previews/primer/alpha/text_field_preview.rb +58 -0
  69. data/previews/primer/alpha/toggle_switch_preview.rb +4 -0
  70. data/previews/primer/alpha/tooltip_preview.rb +13 -3
  71. data/previews/primer/alpha/underline_nav_preview/playground.html.erb +8 -0
  72. data/previews/primer/alpha/underline_nav_preview.rb +15 -0
  73. data/previews/primer/alpha/underline_panels_preview.rb +15 -0
  74. data/previews/primer/beta/auto_complete_item_preview/playground.html.erb +9 -0
  75. data/previews/primer/beta/auto_complete_item_preview.rb +14 -0
  76. data/previews/primer/beta/auto_complete_preview.rb +20 -0
  77. data/previews/primer/beta/avatar_preview.rb +9 -0
  78. data/previews/primer/beta/avatar_stack_preview.rb +15 -0
  79. data/previews/primer/beta/base_button_preview.rb +9 -0
  80. data/previews/primer/beta/blankslate_preview.rb +12 -0
  81. data/previews/primer/beta/border_box_preview.rb +14 -0
  82. data/previews/primer/beta/breadcrumbs_preview.rb +11 -0
  83. data/previews/primer/beta/button_group_preview.rb +12 -0
  84. data/previews/primer/beta/close_button_preview.rb +7 -0
  85. data/previews/primer/beta/counter_preview.rb +11 -0
  86. data/previews/primer/beta/details_preview.rb +15 -0
  87. data/previews/primer/beta/flash_preview.rb +12 -0
  88. data/previews/primer/beta/heading_preview.rb +8 -0
  89. data/previews/primer/beta/label_preview.rb +26 -0
  90. data/previews/primer/beta/link_preview.rb +41 -0
  91. data/previews/primer/beta/text_preview.rb +8 -0
  92. data/previews/primer/beta/truncate_preview.rb +7 -0
  93. data/previews/primer/clipboard_copy_preview.rb +8 -0
  94. data/previews/primer/dropdown_preview.rb +18 -0
  95. data/previews/primer/hellip_button_preview.rb +8 -0
  96. data/previews/primer/layout_component_preview.rb +13 -1
  97. data/previews/primer/local_time_component_preview.rb +13 -0
  98. data/previews/primer/markdown_preview.rb +277 -266
  99. data/previews/primer/menu_component_preview/playground.html.erb +17 -0
  100. data/previews/primer/menu_component_preview.rb +4 -1
  101. data/previews/primer/octicon_component_preview.rb +8 -0
  102. data/previews/primer/popover_component_preview.rb +15 -1
  103. data/previews/primer/progress_bar_component_preview.rb +12 -1
  104. data/previews/primer/spinner_component_preview.rb +7 -0
  105. data/previews/primer/state_component_preview.rb +11 -1
  106. data/previews/primer/subhead_component_preview.rb +17 -0
  107. data/previews/primer/time_ago_component_preview.rb +8 -0
  108. data/previews/primer/timeline_item_component_preview.rb +12 -1
  109. data/static/arguments.json +300 -138
  110. data/static/audited_at.json +6 -0
  111. data/static/constants.json +86 -71
  112. data/static/statuses.json +10 -4
  113. metadata +27 -9
  114. data/previews/primer/image_crop_preview.rb +0 -22
  115. data/previews/primer/label_component_preview.rb +0 -15
  116. data/previews/primer/link_component_preview.rb +0 -29
@@ -4,6 +4,15 @@ module Primer
4
4
  module Alpha
5
5
  # @label ButtonMarketing
6
6
  class ButtonMarketingPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ # @param scheme [Symbol] select [default, primary, outline, transparent]
9
+ # @param variant [Symbol] select [default, large]
10
+ # @param tag [Symbol] select [button, a]
11
+ # @param type [Symbol] select [button, submit]
12
+ def playground(tag: :button, type: :button, scheme: :default, variant: :default)
13
+ render(Primer::Alpha::ButtonMarketing.new(tag: tag, type: type, scheme: scheme, variant: variant)) { "Default" }
14
+ end
15
+
7
16
  # @label Default options
8
17
  # @param scheme [Symbol] select [default, primary, outline, transparent]
9
18
  # @param variant [Symbol] select [default, large]
@@ -4,6 +4,23 @@ module Primer
4
4
  module Alpha
5
5
  # @label Dialog
6
6
  class DialogPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param title [String] text
10
+ # @param subtitle [String] text
11
+ # @param size [Symbol] select [small, medium, medium_portrait, large, xlarge]
12
+ # @param position [Symbol] select [center, left, right]
13
+ # @param position_narrow [Symbol] select [inherit, bottom, fullscreen, left, right]
14
+ # @param visually_hide_title [Boolean] toggle
15
+ # @param button_text [String] text
16
+ # @param body_text [String] text
17
+ def playground(title: "Test Dialog", subtitle: nil, size: :medium, button_text: "Show Dialog", body_text: "Content", position: :center, position_narrow: :fullscreen, visually_hide_title: false)
18
+ render(Primer::Alpha::Dialog.new(title: title, subtitle: subtitle, size: size, position: position, position_narrow: position_narrow, visually_hide_title: visually_hide_title)) do |d|
19
+ d.with_show_button { button_text }
20
+ d.with_body { body_text }
21
+ end
22
+ end
23
+
7
24
  # @label Default options
8
25
  #
9
26
  # @param title [String] text
@@ -80,7 +97,7 @@ module Primer
80
97
  show_divider: show_divider
81
98
  })
82
99
  end
83
-
100
+
84
101
  # @label Nested dialog
85
102
  #
86
103
  # @param title [String] text
@@ -4,6 +4,13 @@ module Primer
4
4
  module Alpha
5
5
  # @label HiddenTextExpander
6
6
  class HiddenTextExpanderPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ # @param label [String] text
9
+ # @param inline [Boolean] toggle
10
+ def playground(label: "No effect", inline: false)
11
+ render(Primer::Alpha::HiddenTextExpander.new(inline: inline, "aria-label": label))
12
+ end
13
+
7
14
  # @label Default options
8
15
  # @param label [String] text
9
16
  # @param inline [Boolean] toggle
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # @label ImageCrop
6
+ class ImageCropPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param rounded [Boolean]
10
+ def playground(rounded: false)
11
+ render(Primer::Alpha::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: rounded))
12
+ end
13
+
14
+ # @label Default Options
15
+ #
16
+ # @param rounded [Boolean]
17
+ def default(rounded: false)
18
+ render(Primer::Alpha::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: rounded))
19
+ end
20
+
21
+ # @label Custom loading slot
22
+ #
23
+ # @param rounded [Boolean]
24
+ def loading(rounded: false)
25
+ render(Primer::Alpha::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: rounded)) do |c|
26
+ c.with_loading { "Loading..." }
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -4,6 +4,21 @@ module Primer
4
4
  module Alpha
5
5
  # @label Layout
6
6
  class LayoutPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ # @param stacking_breakpoint [Symbol] select [sm, md, lg]
9
+ # @param first_in_source [Symbol] select [sidebar, main]
10
+ # @param gutter [Symbol] select [default, none, condensed, spacious]
11
+ def playground(stacking_breakpoint: :sm, gutter: :default, first_in_source: :sidebar)
12
+ render(Primer::Alpha::Layout.new(stacking_breakpoint: stacking_breakpoint, gutter: gutter, first_in_source: first_in_source)) do |c|
13
+ c.with_main(bg: :attention, p: 6) do
14
+ "Main content"
15
+ end
16
+ c.with_sidebar(bg: :accent, p: 6) do
17
+ "Sidebar content"
18
+ end
19
+ end
20
+ end
21
+
7
22
  # @label Default options
8
23
  # @param stacking_breakpoint [Symbol] select [sm, md, lg]
9
24
  # @param first_in_source [Symbol] select [sidebar, main]
@@ -4,6 +4,35 @@ module Primer
4
4
  module Alpha
5
5
  # @label NavList
6
6
  class NavListPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ def playground
9
+ render(Primer::Alpha::NavList.new(selected_item_id: :code_review_limits)) do |list|
10
+ list.with_section(aria: { label: "Repository settings" }) do |section|
11
+ section.with_heading(title: "Repository settings")
12
+
13
+ section.with_item(label: "General", href: "/general") do |item|
14
+ item.with_leading_visual_icon(icon: :gear)
15
+ end
16
+ end
17
+
18
+ list.with_section(aria: { label: "Access" }) do |section|
19
+ section.with_heading(title: "Access")
20
+
21
+ section.with_item(label: "Collaborators and teams", href: "/collaborators", selected_by_ids: :collaborators) do |item|
22
+ item.with_leading_visual_icon(icon: :people)
23
+ end
24
+
25
+ section.with_item(label: "Moderation options", href: "/moderation") do |item|
26
+ item.with_leading_visual_icon(icon: :"comment-discussion")
27
+
28
+ item.with_item(label: "Interaction limits", href: "/interaction-limits", selected_by_ids: :interaction_limits)
29
+ item.with_item(label: "Code review limits", href: "/review-limits", selected_by_ids: :code_review_limits)
30
+ item.with_item(label: "Reported content", href: "/reported-content", selected_by_ids: :reported_content)
31
+ end
32
+ end
33
+ end
34
+ end
35
+
7
36
  # @label Default
8
37
  def default
9
38
  render(Primer::Alpha::NavList.new(selected_item_id: :code_review_limits)) do |list|
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Setup Playground to use all available component props
4
+ # Setup Features to use individual component props and combinations
5
+
6
+ module Primer
7
+ module Alpha
8
+ # @label SegmentedControl
9
+ class SegmentedControlPreview < ViewComponent::Preview
10
+ # @label Playground
11
+ # @param full_width [Boolean] toggle
12
+ # @param hide_labels [Boolean] toggle
13
+ # @param icon [Symbol] octicon
14
+ # @param size select [small, medium, large]
15
+ def playground(full_width: false, hide_labels: false, size: :medium, icon: :none)
16
+ if icon == :none
17
+ icon = hide_labels ? :zap : nil
18
+ end
19
+ render(Primer::Alpha::SegmentedControl.new("aria-label": "File view", full_width: full_width, hide_labels: hide_labels, size: size)) do |c|
20
+ c.with_item(label: "Preview", icon: icon, selected: true)
21
+ c.with_item(label: "Raw", icon: icon)
22
+ c.with_item(label: "Blame", icon: icon)
23
+ end
24
+ end
25
+
26
+ # @param full_width [Boolean] toggle
27
+ # @param size select [small, medium, large]
28
+ def default(full_width: false, size: :medium)
29
+ render(Primer::Alpha::SegmentedControl.new("aria-label": "File view", full_width: full_width, size: size)) do |c|
30
+ c.with_item(label: "Preview", selected: true)
31
+ c.with_item(label: "Raw")
32
+ c.with_item(label: "Blame")
33
+ end
34
+ end
35
+
36
+ # @param hide_labels [Boolean] toggle
37
+ # @param size select [small, medium, large]
38
+ def full_width(hide_labels: false, size: :medium)
39
+ render(Primer::Alpha::SegmentedControl.new("aria-label": "File view", full_width: true, hide_labels: hide_labels, size: size)) do |c|
40
+ c.with_item(label: "Preview", icon: (hide_labels ? :zap : nil), selected: true)
41
+ c.with_item(label: "Raw", icon: (hide_labels ? :zap : nil))
42
+ c.with_item(label: "Blame", icon: (hide_labels ? :zap : nil))
43
+ end
44
+ end
45
+
46
+ # @param full_width [Boolean] toggle
47
+ # @param size select [small, medium, large]
48
+ def icons_and_text(full_width: false, size: :medium)
49
+ render(Primer::Alpha::SegmentedControl.new("aria-label": "File view", full_width: full_width, size: size)) do |c|
50
+ c.with_item(label: "Preview", icon: :eye, selected: true)
51
+ c.with_item(label: "Raw", icon: :"file-code")
52
+ c.with_item(label: "Blame", icon: :people)
53
+ end
54
+ end
55
+
56
+ # @param full_width [Boolean] toggle
57
+ # @param size select [small, medium, large]
58
+ def icons_only(full_width: false, size: :medium)
59
+ render(Primer::Alpha::SegmentedControl.new("aria-label": "File view", full_width: full_width, hide_labels: true, size: size)) do |c|
60
+ c.with_item(label: "Preview", icon: :eye, selected: true)
61
+ c.with_item(label: "Raw", icon: :"file-code")
62
+ c.with_item(label: "Blame", icon: :people)
63
+ end
64
+ end
65
+
66
+ def with_links_as_tags
67
+ render(Primer::Alpha::SegmentedControl.new) do |c|
68
+ c.with_item(tag: :a, href: "#", label: "Preview", icon: :eye, selected: true)
69
+ c.with_item(tag: :a, href: "#", label: "Raw", icon: :"file-code")
70
+ c.with_item(tag: :a, href: "#", label: "Blame", icon: :people)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -4,6 +4,21 @@ module Primer
4
4
  module Alpha
5
5
  # @label TabPanels
6
6
  class TabPanelsPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param number_of_panels [Integer] number
10
+ # @param align [Symbol] select [left, right]
11
+ def playground(number_of_panels: 3, align: :left)
12
+ render(Primer::Alpha::TabPanels.new(label: "label", align: align)) do |c|
13
+ Array.new(number_of_panels || 3) do |i|
14
+ c.tab(selected: i.zero?, id: "tab-#{i + 1}") do |t|
15
+ t.panel { "Panel #{i + 1}" }
16
+ t.text { "Tab #{i + 1}" }
17
+ end
18
+ end
19
+ end
20
+ end
21
+
7
22
  # @label Default options
8
23
  #
9
24
  # @param number_of_panels [Integer] number
@@ -4,6 +4,64 @@ module Primer
4
4
  module Alpha
5
5
  # @label TextField
6
6
  class TextFieldPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param name text
10
+ # @param id text
11
+ # @param label text
12
+ # @param visually_hide_label toggle
13
+ # @param size [Symbol] select [small, medium, large]
14
+ # @param show_clear_button toggle
15
+ # @param clear_button_id text
16
+ # @param full_width toggle
17
+ # @param disabled toggle
18
+ # @param invalid toggle
19
+ # @param placeholder text
20
+ # @param inset toggle
21
+ # @param monospace toggle
22
+ # @param leading_visual_icon text
23
+ def playground(
24
+ name: "my-text-field",
25
+ id: "my-text-field",
26
+ label: "My text field",
27
+ visually_hide_label: false,
28
+ size: Primer::Forms::Dsl::Input::DEFAULT_SIZE.to_s,
29
+ show_clear_button: false,
30
+ clear_button_id: "my-text-field-clear-button",
31
+ full_width: false,
32
+ disabled: false,
33
+ invalid: false,
34
+ placeholder: nil,
35
+ inset: false,
36
+ monospace: false,
37
+ leading_visual_icon: nil
38
+ )
39
+ system_arguments = {
40
+ name: name,
41
+ id: id,
42
+ label: label,
43
+ visually_hide_label: visually_hide_label,
44
+ size: size,
45
+ show_clear_button: show_clear_button,
46
+ clear_button_id: clear_button_id,
47
+ full_width: full_width,
48
+ disabled: disabled,
49
+ invalid: invalid,
50
+ placeholder: placeholder,
51
+ inset: inset,
52
+ monospace: monospace
53
+ }
54
+
55
+ if leading_visual_icon
56
+ system_arguments[:leading_visual] = {
57
+ icon: leading_visual_icon,
58
+ size: :small
59
+ }
60
+ end
61
+
62
+ render(Primer::Alpha::TextField.new(**system_arguments))
63
+ end
64
+
7
65
  # @label Default
8
66
  #
9
67
  # @param name text
@@ -6,6 +6,10 @@ module Primer
6
6
  class ToggleSwitchPreview < ViewComponent::Preview
7
7
  include ActionView::Helpers::FormTagHelper
8
8
 
9
+ def playground
10
+ render(ToggleSwitch.new(src: "/toggle_switch"))
11
+ end
12
+
9
13
  def default
10
14
  render(ToggleSwitch.new(src: "/toggle_switch"))
11
15
  end
@@ -4,6 +4,16 @@ module Primer
4
4
  module Alpha
5
5
  # @label Tooltip
6
6
  class TooltipPreview < ViewComponent::Preview
7
+ # @param type [Symbol] select [["Description", description], ["Label", label]]
8
+ # @param direction select [s, n, e, w, ne, nw, se, sw]
9
+ # @param tooltip_text text
10
+ def playground(type: :description, direction: :s, tooltip_text: "Tooltip text")
11
+ render(Primer::Beta::Button.new(id: "button-with-tooltip")) do |c|
12
+ c.tooltip(text: tooltip_text, type: type, direction: direction)
13
+ "Button"
14
+ end
15
+ end
16
+
7
17
  # @param type [Symbol] select [["Description", description], ["Label", label]]
8
18
  # @param direction select [s, n, e, w, ne, nw, se, sw]
9
19
  # @param tooltip_text text
@@ -65,9 +75,9 @@ module Primer
65
75
  end
66
76
  end
67
77
 
68
- # @label Tooltip with Primer::LinkComponent
78
+ # @label Tooltip with Primer::Beta::Link
69
79
  def tooltip_with_link(type: :description, direction: :s, tooltip_text: "Tooltip text")
70
- render(Primer::LinkComponent.new(href: "#link-with-tooltip", id: "link-with-tooltip")) do |c|
80
+ render(Primer::Beta::Link.new(href: "#link-with-tooltip", id: "link-with-tooltip")) do |c|
71
81
  c.tooltip(text: tooltip_text, type: type, direction: direction)
72
82
  "Button"
73
83
  end
@@ -75,7 +85,7 @@ module Primer
75
85
 
76
86
  # @label Tooltip with Primer::IconButton
77
87
  def tooltip_with_icon_button(direction: :s, tooltip_text: "Tooltip text")
78
- render(Primer::IconButton.new(icon: :search, "aria-label": tooltip_text, tooltip_direction: direction))
88
+ render(Primer::Beta::IconButton.new(icon: :search, "aria-label": tooltip_text, tooltip_direction: direction))
79
89
  end
80
90
  # @!endgroup
81
91
  end
@@ -0,0 +1,8 @@
1
+ <%= render(Primer::Alpha::UnderlineNav.new(label: label, tag: tag, align: align)) do |component| %>
2
+ <% Array.new(number_of_panels || 3) do |i| %>
3
+ <% component.with_tab(href: "#", selected: i.zero?) { "Item #{i + 1}" } %>
4
+ <% end %>
5
+ <% component.with_actions do %>
6
+ <%= render(Primer::ButtonComponent.new) { "Button" } %>
7
+ <% end %>
8
+ <% end %>
@@ -4,6 +4,21 @@ module Primer
4
4
  module Alpha
5
5
  # @label UnderlineNav
6
6
  class UnderlineNavPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param label [String] text
10
+ # @param tag [Symbol] select [div, nav]
11
+ # @param align [Symbol] select [left, right]
12
+ # @param number_of_panels [Integer] number
13
+ def playground(label: "Default with nav element", tag: :nav, align: :left, number_of_panels: 3)
14
+ render_with_template(locals: {
15
+ label: label,
16
+ tag: tag,
17
+ align: align,
18
+ number_of_panels: number_of_panels
19
+ })
20
+ end
21
+
7
22
  # @label Default options
8
23
  #
9
24
  # @param label [String] text
@@ -4,6 +4,21 @@ module Primer
4
4
  module Alpha
5
5
  # @label UnderlinePanels
6
6
  class UnderlinePanelsPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param number_of_panels [Integer] number
10
+ # @param align [Symbol] select [left, right]
11
+ def playground(number_of_panels: 3, align: :left)
12
+ render(Primer::Alpha::UnderlinePanels.new(label: "Test navigation", align: align)) do |c|
13
+ Array.new(number_of_panels || 3) do |i|
14
+ c.tab(selected: i.zero?, id: "tab-#{i + 1}") do |t|
15
+ t.panel { "Panel #{i + 1}" }
16
+ t.text { "Tab #{i + 1}" }
17
+ end
18
+ end
19
+ end
20
+ end
21
+
7
22
  # @label Default options
8
23
  #
9
24
  # @param number_of_panels [Integer] number
@@ -0,0 +1,9 @@
1
+ <%= render(
2
+ Primer::Beta::AutoComplete::Item.new(
3
+ selected: selected,
4
+ disabled: disabled,
5
+ value: ''
6
+ )) do |c| %>
7
+ <% c.leading_visual_icon(icon: :search) %>
8
+ Label text
9
+ <% end %>
@@ -4,6 +4,20 @@ module Primer
4
4
  module Beta
5
5
  # @label AutoCompleteItem
6
6
  class AutoCompleteItemPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ # @param selected toggle
9
+ # @param disabled toggle
10
+ # @param value text
11
+ def playground(value: "", selected: false, disabled: false)
12
+ render_with_template(
13
+ locals: {
14
+ selected: selected,
15
+ disabled: disabled,
16
+ value: value
17
+ }
18
+ )
19
+ end
20
+
7
21
  # @label Default
8
22
  # @param selected toggle
9
23
  # @param disabled toggle
@@ -4,6 +4,26 @@ module Primer
4
4
  module Beta
5
5
  # @label AutoComplete
6
6
  class AutoCompletePreview < ViewComponent::Preview
7
+ # @label Playground
8
+ # @param label_text text
9
+ # @param show_clear_button toggle
10
+ # @param visually_hide_label toggle
11
+ # @param placeholder text
12
+ # @param size select [small, medium, large]
13
+ # @param full_width toggle
14
+ # @param disabled toggle
15
+ # @param invalid toggle
16
+ # @param input_id text
17
+ # @param list_id text
18
+ # @param input_name text
19
+ # @param inset toggle
20
+ # @param monospace toggle
21
+ def playground(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :medium, full_width: false, disabled: false, invalid: false, input_id: "input-id", list_id: "list-id", input_name: "input-id", inset: false, monospace: false)
22
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name, inset: inset, monospace: monospace)) do |c|
23
+ c.leading_visual_icon(icon: :search)
24
+ end
25
+ end
26
+
7
27
  # @label Default
8
28
  # @param label_text text
9
29
  # @param show_clear_button toggle
@@ -4,6 +4,15 @@ module Primer
4
4
  module Beta
5
5
  # @label Avatar
6
6
  class AvatarPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param size [Integer] select [16, 20, 24, 32, 40, 48, 80]
10
+ # @param shape [Symbol] select [circle, square]
11
+ # @param href [String] text
12
+ def playground(size: 24, shape: :circle, href: nil)
13
+ render(Primer::Beta::Avatar.new(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser", size: size, shape: shape, href: href))
14
+ end
15
+
7
16
  # @label Default options
8
17
  #
9
18
  # @param size [Integer] select [16, 20, 24, 32, 40, 48, 80]
@@ -4,6 +4,21 @@ module Primer
4
4
  module Beta
5
5
  # @label AvatarStack
6
6
  class AvatarStackPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param number_of_avatars [Integer] number
10
+ # @param tag select [["div", div], ["span", span]]
11
+ # @param align select [["Left", left], ["Right", right]]
12
+ # @param tooltipped toggle
13
+ # @param tooltip_label text
14
+ def playground(number_of_avatars: 1, tag: :div, align: :left, tooltipped: false, tooltip_label: "This is a tooltip!")
15
+ render(Primer::Beta::AvatarStack.new(tag: tag, align: align, tooltipped: tooltipped, body_arguments: { label: tooltip_label })) do |c|
16
+ Array.new(number_of_avatars || 1) do
17
+ c.avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser")
18
+ end
19
+ end
20
+ end
21
+
7
22
  # @label Default options
8
23
  #
9
24
  # @param number_of_avatars [Integer] number
@@ -4,6 +4,15 @@ module Primer
4
4
  module Beta
5
5
  # @label BaseButton
6
6
  class BaseButtonPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param type [Symbol] select [button, submit]
10
+ # @param tag [Symbol] select [button, a, summary]
11
+ # @param block [Boolean] toggle
12
+ def playground(tag: :button, block: false, type: :button)
13
+ render(Primer::Beta::BaseButton.new(tag: tag, block: block, type: type)) { "Button" }
14
+ end
15
+
7
16
  # @label Default options
8
17
  #
9
18
  # @param type [Symbol] select [button, submit]
@@ -4,6 +4,18 @@ module Primer
4
4
  module Beta
5
5
  # @label Blankslate
6
6
  class BlankslatePreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param narrow [Boolean] toggle
10
+ # @param spacious [Boolean] toggle
11
+ # @param border [Boolean] toggle
12
+ def playground(narrow: false, spacious: false, border: false)
13
+ render Primer::Beta::Blankslate.new(narrow: narrow, spacious: spacious, border: border) do |c|
14
+ c.heading(tag: :h2).with_content("Title")
15
+ c.description { "Description" }
16
+ end
17
+ end
18
+
7
19
  # @label Default options
8
20
  #
9
21
  # @param narrow [Boolean] toggle
@@ -4,6 +4,20 @@ module Primer
4
4
  module Beta
5
5
  # @label BorderBox
6
6
  class BorderBoxPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param padding [Symbol] select [default, condensed]
10
+ def playground(padding: :default)
11
+ render(Primer::Beta::BorderBox.new(padding: padding)) do |component|
12
+ component.header { "Header" }
13
+ component.body { "Body" }
14
+ component.row { "Row one" }
15
+ component.row { "Row two" }
16
+ component.row { "Row three" }
17
+ component.footer { "Footer" }
18
+ end
19
+ end
20
+
7
21
  # @label Default options
8
22
  #
9
23
  # @param padding [Symbol] select [default, condensed]
@@ -4,6 +4,17 @@ module Primer
4
4
  module Beta
5
5
  # @label Breadcrumbs
6
6
  class BreadcrumbsPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param number_of_links [Integer] number
10
+ def playground(number_of_links: 2)
11
+ render(Primer::Beta::Breadcrumbs.new) do |component|
12
+ Array.new(number_of_links || 3) do |i|
13
+ component.item(href: "##{i}") { "Breadcrumb Item #{i + 1}" }
14
+ end
15
+ end
16
+ end
17
+
7
18
  # @label Default options
8
19
  #
9
20
  # @param number_of_links [Integer] number
@@ -4,6 +4,18 @@ module Primer
4
4
  module Beta
5
5
  # @label ButtonGroup
6
6
  class ButtonGroupPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param size [Symbol] select [medium, small]
10
+ def playground(size: :medium)
11
+ render(Primer::Beta::ButtonGroup.new(size: size)) do |c|
12
+ c.button { "Button" }
13
+ c.button(scheme: :primary) { "Primary" }
14
+ c.button(scheme: :danger) { "Danger" }
15
+ c.button(scheme: :outline) { "Outline" }
16
+ end
17
+ end
18
+
7
19
  # @label Default options
8
20
  #
9
21
  # @param size [Symbol] select [medium, small]
@@ -4,6 +4,13 @@ module Primer
4
4
  module Beta
5
5
  # @label CloseButton
6
6
  class CloseButtonPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param type [Symbol] select [button, submit]
10
+ def playground(type: :button)
11
+ render(Primer::Beta::CloseButton.new(type: type))
12
+ end
13
+
7
14
  # @label Default options
8
15
  #
9
16
  # @param type [Symbol] select [button, submit]
@@ -4,6 +4,17 @@ module Primer
4
4
  module Beta
5
5
  # @label Counter
6
6
  class CounterPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param count number
10
+ # @param limit number
11
+ # @param hide_if_zero toggle
12
+ # @param round toggle
13
+ # @param scheme [Symbol] select [[Default, default], [Primary, primary], [Secondary, secondary]]]
14
+ def playground(count: 1_000, limit: nil, round: false, hide_if_zero: false, scheme: :default)
15
+ render(Primer::Beta::Counter.new(count: count, round: round, limit: limit, hide_if_zero: hide_if_zero, scheme: scheme))
16
+ end
17
+
7
18
  # @label Default Options
8
19
  #
9
20
  # @param count number