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,21 @@ module Primer
4
4
  module Beta
5
5
  # @label Details
6
6
  class DetailsPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param overlay [Symbol] select [none, default, dark]
10
+ # @param reset [Boolean] toggle
11
+ def playground(reset: false, overlay: :default)
12
+ render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |c|
13
+ c.with_summary do
14
+ "Summary"
15
+ end
16
+ c.with_body do
17
+ "Body"
18
+ end
19
+ end
20
+ end
21
+
7
22
  # @label Default options
8
23
  #
9
24
  # @param overlay [Symbol] select [none, default, dark]
@@ -4,6 +4,18 @@ module Primer
4
4
  module Beta
5
5
  # @label Flash
6
6
  class FlashPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param full toggle
10
+ # @param spacious toggle
11
+ # @param dismissible toggle
12
+ # @param icon [Symbol] select [alert, check, info, people]
13
+ # @param scheme [Symbol] select [default, warning, danger, success]
14
+ # @param content text
15
+ def playground(full: false, spacious: false, dismissible: false, icon: :people, scheme: Primer::Beta::Flash::DEFAULT_SCHEME, content: "This is a flash message!")
16
+ render(Primer::Beta::Flash.new(full: full, spacious: spacious, dismissible: dismissible, icon: icon, scheme: scheme)) { content }
17
+ end
18
+
7
19
  # @label Default
8
20
  #
9
21
  # @param full toggle
@@ -4,6 +4,14 @@ module Primer
4
4
  module Beta
5
5
  # @label Heading
6
6
  class HeadingPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param tag [Symbol] select [h1, h2, h3, h4, h5, h6]
10
+ # @param content [String] text
11
+ def playground(tag: :h2, content: "Heading")
12
+ render(Primer::Beta::Heading.new(tag: tag)) { content }
13
+ end
14
+
7
15
  # @label Default options
8
16
  #
9
17
  # @param tag [Symbol] select [h1, h2, h3, h4, h5, h6]
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Label
6
+ class LabelPreview < ViewComponent::Preview
7
+ # @label Default Options
8
+ #
9
+ # @param size [Symbol] select [medium, large]
10
+ # @param tag [Symbol] select [span, summary, a, div]
11
+ # @param inline [Boolean] toggle
12
+ def default(size: :medium, tag: :span, inline: false)
13
+ render(Primer::Beta::Label.new(tag: tag, size: size, inline: inline)) { "Label" }
14
+ end
15
+
16
+ # @label Playground
17
+ #
18
+ # @param size [Symbol] select [medium, large]
19
+ # @param tag [Symbol] select [span, summary, a, div]
20
+ # @param inline [Boolean] toggle
21
+ def playground(size: :medium, tag: :span, inline: false)
22
+ render(Primer::Beta::Label.new(tag: tag, size: size, inline: inline)) { "Label" }
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Link
6
+ class LinkPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param underline [Boolean]
10
+ # @param muted [Boolean]
11
+ # @param tag [Symbol] select [a, span]
12
+ # @param scheme [Symbol] select [default, primary, secondary]
13
+ def playground(tag: :a, scheme: :default, muted: false, underline: true)
14
+ render(Primer::Beta::Link.new(href: "#", tag: tag, scheme: scheme, muted: muted, underline: underline)) { "This is a link!" }
15
+ end
16
+
17
+ # @label Default Options
18
+ #
19
+ # @param underline [Boolean]
20
+ # @param muted [Boolean]
21
+ # @param tag [Symbol] select [a, span]
22
+ # @param scheme [Symbol] select [default, primary, secondary]
23
+ def default(tag: :a, scheme: :default, muted: false, underline: true)
24
+ render(Primer::Beta::Link.new(href: "#", tag: tag, scheme: scheme, muted: muted, underline: underline)) { "This is a link!" }
25
+ end
26
+
27
+ # @label With Tooltip
28
+ #
29
+ # @param underline [Boolean]
30
+ # @param muted [Boolean]
31
+ # @param tag [Symbol] select [a, span]
32
+ # @param scheme [Symbol] select [default, primary, secondary]
33
+ def tooltip(tag: :a, scheme: :default, muted: false, underline: true)
34
+ render(Primer::Beta::Link.new(href: "#", id: "tooltip-link", tag: tag, scheme: scheme, muted: muted, underline: underline)) do |component|
35
+ component.with_tooltip(text: "Tooltip text")
36
+ "Link with tooltip"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -4,6 +4,14 @@ module Primer
4
4
  module Beta
5
5
  # @label Text
6
6
  class TextPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param tag [Symbol] select [div, p, span]
10
+ # @param content [String] text
11
+ def playground(tag: :span, content: "Text")
12
+ render(Primer::Beta::Text.new(tag: tag)) { content }
13
+ end
14
+
7
15
  # @label Default options
8
16
  #
9
17
  # @param tag [Symbol] select [div, p, span]
@@ -4,6 +4,13 @@ module Primer
4
4
  module Beta
5
5
  # @label Truncate
6
6
  class TruncatePreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param text [String] text
10
+ def playground(text: "branch-name-that-is-really-long")
11
+ render(Primer::Beta::Truncate.new) { text }
12
+ end
13
+
7
14
  # @label Default options
8
15
  #
9
16
  # @param text [String] text
@@ -3,6 +3,14 @@
3
3
  module Primer
4
4
  # @label ClipboardCopy
5
5
  class ClipboardCopyPreview < ViewComponent::Preview
6
+ # @label Playground
7
+ #
8
+ # @param aria_label [String]
9
+ # @param value [String]
10
+ def playground(value: "Text to copy", aria_label: "Copy text to the system clipboard")
11
+ render(Primer::ClipboardCopy.new(value: value, "aria-label": aria_label))
12
+ end
13
+
6
14
  # @label Default Options
7
15
  #
8
16
  # @param aria_label [String]
@@ -3,6 +3,24 @@
3
3
  module Primer
4
4
  # @label Dropdown
5
5
  class DropdownPreview < ViewComponent::Preview
6
+ # @label Playground
7
+ #
8
+ # @param with_caret [Boolean] toggle
9
+ # @param overlay [Symbol] select [none, default, dark]
10
+ def playground(overlay: :default, with_caret: false)
11
+ render(Primer::Dropdown.new(overlay: overlay, with_caret: with_caret)) do |c|
12
+ c.with_button { "Dropdown" }
13
+
14
+ c.with_menu(header: "Header") do |m|
15
+ m.with_item { "Item 1" }
16
+ m.with_item { "Item 2" }
17
+ m.with_item(divider: true)
18
+ m.with_item { "Item 3" }
19
+ m.with_item { "Item 4" }
20
+ end
21
+ end
22
+ end
23
+
6
24
  # @label Default Options
7
25
  #
8
26
  # @param with_caret [Boolean] toggle
@@ -10,5 +10,13 @@ module Primer
10
10
  def default(inline: false, aria_label: "No effect")
11
11
  render(Primer::HellipButton.new(inline: inline, "aria-label": aria_label))
12
12
  end
13
+
14
+ # @label Playground
15
+ #
16
+ # @param aria_label [String]
17
+ # @param inline [Boolean]
18
+ def playground(inline: false, aria_label: "No effect")
19
+ render(Primer::HellipButton.new(inline: inline, "aria-label": aria_label))
20
+ end
13
21
  end
14
22
  end
@@ -3,7 +3,19 @@
3
3
  module Primer
4
4
  # @label LayoutComponent
5
5
  class LayoutComponentPreview < ViewComponent::Preview
6
- # @label Default Options
6
+ # @label Playground
7
+ #
8
+ # @param responsive [Boolean]
9
+ # @param side [Symbol] select [left, right]
10
+ # @param sidebar_col [Integer] select [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
11
+ def playground(responsive: false, side: :right, sidebar_col: 3)
12
+ render(Primer::LayoutComponent.new(responsive: responsive, side: side, sidebar_col: sidebar_col)) do |component|
13
+ component.with_main { "Main" }
14
+ component.with_sidebar { "Sidebar" }
15
+ end
16
+ end
17
+
18
+ # @label Default
7
19
  #
8
20
  # @param responsive [Boolean]
9
21
  # @param side [Symbol] select [left, right]
@@ -3,6 +3,19 @@
3
3
  module Primer
4
4
  # @label LocalTime
5
5
  class LocalTimeComponentPreview < ViewComponent::Preview
6
+ # @param datetime datetime-local
7
+ # @param weekday [Symbol] select [long, short]
8
+ # @param month [Symbol] select [long, short]
9
+ # @param year [Symbol] select [numeric, "2-digit"]
10
+ # @param day [Symbol] select [numeric, "2-digit"]
11
+ # @param hour [Symbol] select [numeric, "2-digit"]
12
+ # @param minute [Symbol] select [numeric, "2-digit"]
13
+ # @param second [Symbol] select [numeric, "2-digit"]
14
+ # @param time_zone_name [Symbol] select [long, short]
15
+ def playground(datetime: "2014-04-01T16:30:00-08:00", weekday: :short, month: :short, year: :numeric, day: :numeric, hour: :numeric, minute: :numeric, second: :numeric, time_zone_name: :short)
16
+ render(Primer::LocalTime.new(datetime: DateTime.parse(datetime), weekday: weekday, month: month, year: year, day: day, hour: hour, minute: minute, second: second, time_zone_name: time_zone_name))
17
+ end
18
+
6
19
  # @param datetime datetime-local
7
20
  # @param weekday [Symbol] select [long, short]
8
21
  # @param month [Symbol] select [long, short]