openproject-primer_view_components 0.6.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -0
  3. data/README.md +13 -1
  4. data/app/assets/javascripts/primer_view_components.js +1 -1
  5. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  6. data/app/assets/styles/primer_view_components.css +1 -1
  7. data/app/assets/styles/primer_view_components.css.map +1 -1
  8. data/app/components/primer/alpha/action_bar.rb +0 -7
  9. data/app/components/primer/alpha/action_list.css +1 -1
  10. data/app/components/primer/alpha/action_list.css.json +1 -0
  11. data/app/components/primer/alpha/action_list.css.map +1 -1
  12. data/app/components/primer/alpha/action_list.pcss +6 -0
  13. data/app/components/primer/alpha/action_menu/action_menu_element.js +37 -6
  14. data/app/components/primer/alpha/action_menu/action_menu_element.ts +39 -5
  15. data/app/components/primer/alpha/action_menu.rb +0 -269
  16. data/app/components/primer/alpha/auto_complete/item.rb +0 -12
  17. data/app/components/primer/alpha/auto_complete.css +1 -1
  18. data/app/components/primer/alpha/auto_complete.css.map +1 -1
  19. data/app/components/primer/alpha/auto_complete.rb +0 -47
  20. data/app/components/primer/alpha/banner.css +1 -1
  21. data/app/components/primer/alpha/banner.css.map +1 -1
  22. data/app/components/primer/alpha/banner.rb +0 -31
  23. data/app/components/primer/alpha/button_marketing.rb +0 -12
  24. data/app/components/primer/alpha/dialog.css +1 -1
  25. data/app/components/primer/alpha/dialog.css.map +1 -1
  26. data/app/components/primer/alpha/dialog.rb +2 -18
  27. data/app/components/primer/alpha/dropdown.css +1 -1
  28. data/app/components/primer/alpha/dropdown.css.map +1 -1
  29. data/app/components/primer/alpha/dropdown.rb +0 -105
  30. data/app/components/primer/alpha/form_control.rb +0 -11
  31. data/app/components/primer/alpha/hellip_button.rb +0 -9
  32. data/app/components/primer/alpha/hidden_text_expander.rb +0 -9
  33. data/app/components/primer/alpha/image.rb +0 -16
  34. data/app/components/primer/alpha/image_crop.rb +0 -11
  35. data/app/components/primer/alpha/layout.css +1 -1
  36. data/app/components/primer/alpha/layout.css.map +1 -1
  37. data/app/components/primer/alpha/layout.pcss +1 -1
  38. data/app/components/primer/alpha/layout.rb +0 -118
  39. data/app/components/primer/alpha/menu.css +1 -1
  40. data/app/components/primer/alpha/menu.css.map +1 -1
  41. data/app/components/primer/alpha/menu.rb +0 -19
  42. data/app/components/primer/alpha/multi_input.rb +0 -33
  43. data/app/components/primer/alpha/nav_list.rb +0 -69
  44. data/app/components/primer/alpha/navigation/tab.rb +0 -35
  45. data/app/components/primer/alpha/octicon_symbols.rb +0 -6
  46. data/app/components/primer/alpha/overlay.rb +0 -14
  47. data/app/components/primer/alpha/segmented_control.css +1 -1
  48. data/app/components/primer/alpha/segmented_control.css.map +1 -1
  49. data/app/components/primer/alpha/segmented_control.rb +0 -61
  50. data/app/components/primer/alpha/tab_container.rb +0 -18
  51. data/app/components/primer/alpha/tab_nav.css +1 -1
  52. data/app/components/primer/alpha/tab_nav.css.map +1 -1
  53. data/app/components/primer/alpha/tab_nav.rb +0 -63
  54. data/app/components/primer/alpha/tab_panels.rb +0 -16
  55. data/app/components/primer/alpha/text_field.css +1 -1
  56. data/app/components/primer/alpha/text_field.css.map +1 -1
  57. data/app/components/primer/alpha/text_field.rb +0 -68
  58. data/app/components/primer/alpha/toggle_switch.css +1 -1
  59. data/app/components/primer/alpha/toggle_switch.css.map +1 -1
  60. data/app/components/primer/alpha/toggle_switch.rb +0 -18
  61. data/app/components/primer/alpha/tooltip.rb +1 -69
  62. data/app/components/primer/alpha/underline_nav.css +1 -1
  63. data/app/components/primer/alpha/underline_nav.css.map +1 -1
  64. data/app/components/primer/alpha/underline_nav.rb +0 -61
  65. data/app/components/primer/alpha/underline_panels.rb +0 -19
  66. data/app/components/primer/beta/auto_complete/item.rb +0 -8
  67. data/app/components/primer/beta/auto_complete.rb +0 -56
  68. data/app/components/primer/beta/avatar.css +1 -1
  69. data/app/components/primer/beta/avatar.css.map +1 -1
  70. data/app/components/primer/beta/avatar.rb +0 -18
  71. data/app/components/primer/beta/avatar_stack.css +1 -1
  72. data/app/components/primer/beta/avatar_stack.css.map +1 -1
  73. data/app/components/primer/beta/avatar_stack.rb +0 -21
  74. data/app/components/primer/beta/base_button.rb +0 -4
  75. data/app/components/primer/beta/blankslate.css +1 -1
  76. data/app/components/primer/beta/blankslate.css.map +1 -1
  77. data/app/components/primer/beta/blankslate.rb +0 -104
  78. data/app/components/primer/beta/border_box/header.rb +4 -11
  79. data/app/components/primer/beta/border_box.css +1 -1
  80. data/app/components/primer/beta/border_box.css.map +1 -1
  81. data/app/components/primer/beta/border_box.html.erb +2 -2
  82. data/app/components/primer/beta/border_box.rb +11 -55
  83. data/app/components/primer/beta/breadcrumbs.rb +0 -7
  84. data/app/components/primer/beta/button.css +1 -1
  85. data/app/components/primer/beta/button.css.json +1 -0
  86. data/app/components/primer/beta/button.css.map +1 -1
  87. data/app/components/primer/beta/button.pcss +6 -2
  88. data/app/components/primer/beta/button.rb +6 -43
  89. data/app/components/primer/beta/button_group.css +1 -1
  90. data/app/components/primer/beta/button_group.css.map +1 -1
  91. data/app/components/primer/beta/button_group.rb +0 -16
  92. data/app/components/primer/beta/clipboard_copy.rb +0 -12
  93. data/app/components/primer/beta/close_button.rb +0 -3
  94. data/app/components/primer/beta/counter.rb +0 -8
  95. data/app/components/primer/beta/details.rb +0 -11
  96. data/app/components/primer/beta/flash.css +1 -1
  97. data/app/components/primer/beta/flash.css.map +1 -1
  98. data/app/components/primer/beta/flash.html.erb +1 -3
  99. data/app/components/primer/beta/flash.pcss +1 -2
  100. data/app/components/primer/beta/flash.rb +1 -23
  101. data/app/components/primer/beta/heading.rb +0 -8
  102. data/app/components/primer/beta/icon_button.rb +0 -21
  103. data/app/components/primer/beta/label.css +1 -1
  104. data/app/components/primer/beta/label.css.map +1 -1
  105. data/app/components/primer/beta/label.rb +0 -20
  106. data/app/components/primer/beta/link.rb +0 -22
  107. data/app/components/primer/beta/markdown.rb +1 -262
  108. data/app/components/primer/beta/octicon.rb +0 -10
  109. data/app/components/primer/beta/popover.css +1 -1
  110. data/app/components/primer/beta/popover.css.map +1 -1
  111. data/app/components/primer/beta/popover.rb +0 -43
  112. data/app/components/primer/beta/progress_bar.rb +1 -22
  113. data/app/components/primer/beta/relative_time.rb +0 -9
  114. data/app/components/primer/beta/spinner.rb +2 -10
  115. data/app/components/primer/beta/state.rb +0 -13
  116. data/app/components/primer/beta/subhead.rb +0 -55
  117. data/app/components/primer/beta/text.rb +0 -4
  118. data/app/components/primer/beta/timeline_item.css +1 -1
  119. data/app/components/primer/beta/timeline_item.css.map +1 -1
  120. data/app/components/primer/beta/timeline_item.rb +0 -9
  121. data/app/components/primer/beta/truncate.rb +0 -50
  122. data/app/components/primer/blankslate_component.rb +0 -76
  123. data/app/components/primer/box.rb +0 -6
  124. data/app/components/primer/button_component.rb +0 -49
  125. data/app/components/primer/component.rb +1 -1
  126. data/app/components/primer/conditional_wrapper.rb +2 -17
  127. data/app/components/primer/icon_button.rb +0 -30
  128. data/app/components/primer/layout_component.rb +0 -12
  129. data/app/components/primer/tooltip.rb +0 -27
  130. data/app/components/primer/truncate.rb +0 -19
  131. data/app/lib/primer/fetch_or_fallback_helper.rb +1 -1
  132. data/lib/primer/accessibility.rb +1 -1
  133. data/lib/primer/deprecations.yml +3 -3
  134. data/lib/primer/forms/dsl/input.rb +1 -0
  135. data/lib/primer/view_components/linters/details_menu_migration.rb +1 -1
  136. data/lib/primer/view_components/linters/migrations/truncate_component.rb +45 -0
  137. data/lib/primer/view_components/linters/tooltipped_migration.rb +1 -1
  138. data/lib/primer/view_components/linters.rb +1 -0
  139. data/lib/primer/view_components/version.rb +2 -2
  140. data/lib/primer/view_components.rb +18 -0
  141. data/lib/primer/yard.rb +8 -9
  142. data/previews/primer/beta/button_preview/leading_visual.html.erb +2 -2
  143. data/previews/primer/beta/button_preview/leading_visual_svg.html.erb +12 -0
  144. data/previews/primer/beta/button_preview/trailing_counter.html.erb +1 -1
  145. data/previews/primer/beta/button_preview/trailing_visual.html.erb +1 -1
  146. data/previews/primer/beta/button_preview.rb +22 -0
  147. data/static/arguments.json +12 -1
  148. data/static/info_arch.json +32 -2
  149. data/static/previews.json +13 -0
  150. metadata +4 -3
  151. data/lib/primer/yard/legacy_gatsby_backend.rb +0 -233
@@ -14,56 +14,6 @@ module Primer
14
14
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
15
15
  renders_many :items, "TruncateText"
16
16
 
17
- # @example Default
18
- # <%= render(Primer::Beta::Truncate.new) { "branch-name-that-is-really-long" } %>
19
- #
20
- # @example Multiple items
21
- # <%= render(Primer::Beta::Truncate.new) do |component| %>
22
- # <% component.with_item do %>really-long-repository-owner-name<% end %>
23
- # <% component.with_item(font_weight: :bold) do %>
24
- # <%= render(Primer::BaseComponent.new(tag: :span, font_weight: :normal)) { "/" } %> really-long-repository-name
25
- # <% end %>
26
- # <% end %>
27
- #
28
- # @example Advanced multiple items
29
- # <%= render(Primer::Beta::Truncate.new(tag: :ol)) do |component| %>
30
- # <% component.with_item(tag: :li) do %>primer<% end %>
31
- # <% component.with_item(tag: :li, priority: true) do %>/ css<% end %>
32
- # <% component.with_item(tag: :li) do %>/ Issues<% end %>
33
- # <% component.with_item(tag: :li) do %>/ #123 —<% end %>
34
- # <% component.with_item(tag: :li, priority: true) do %>
35
- # Visual bug on primer.style found in lists
36
- # <% end %>
37
- # <% end %>
38
- #
39
- # @example Expand on hover or focus
40
- # <%= render(Primer::Beta::Truncate.new) do |component| %>
41
- # <% component.with_item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
42
- # <% component.with_item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
43
- # <% component.with_item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
44
- # <% component.with_item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
45
- # <% end %>
46
- #
47
- # @example Max widths
48
- # <%= render(Primer::Beta::Truncate.new) do |component| %>
49
- # <% component.with_item(max_width: 300, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
50
- # <% component.with_item(max_width: 200, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
51
- # <% component.with_item(max_width: 100, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
52
- # <% end %>
53
- #
54
- # @example Max widths on new lines
55
- # <%= render(Primer::Beta::Truncate.new) do |component| %>
56
- # <% component.with_item(max_width: 300, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
57
- # <% end %>
58
- # <br/>
59
- # <%= render(Primer::Beta::Truncate.new) do |component| %>
60
- # <% component.with_item(max_width: 200, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
61
- # <% end %>
62
- # <br/>
63
- # <%= render(Primer::Beta::Truncate.new) do |component| %>
64
- # <% component.with_item(max_width: 100, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
65
- # <% end %>
66
- #
67
17
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
68
18
  def initialize(**system_arguments)
69
19
  @system_arguments = system_arguments
@@ -16,82 +16,6 @@ module Primer
16
16
  Primer::Beta::Spinner.new(**system_arguments)
17
17
  }
18
18
 
19
- #
20
- # @example Basic
21
- # <%= render Primer::BlankslateComponent.new(
22
- # title: "Title",
23
- # description: "Description",
24
- # ) %>
25
- #
26
- # @example Icon
27
- # @description
28
- # Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
29
- # @code
30
- # <%= render Primer::BlankslateComponent.new(
31
- # icon: :globe,
32
- # title: "Title",
33
- # description: "Description",
34
- # ) %>
35
- #
36
- # @example Loading
37
- # @description
38
- # Add a [SpinnerComponent](https://primer.style/view-components/components/spinner) to the blankslate in place of an icon.
39
- # @code
40
- # <%= render Primer::BlankslateComponent.new(
41
- # title: "Title",
42
- # description: "Description",
43
- # ) do |component| %>
44
- # <% component.with_spinner(size: :large) %>
45
- # <% end %>
46
- #
47
- # @example Custom content
48
- # @description
49
- # Pass custom content as a block in place of `description`.
50
- # @code
51
- # <%= render Primer::BlankslateComponent.new(
52
- # title: "Title",
53
- # ) do %>
54
- # <em>Your custom content here</em>
55
- # <% end %>
56
- #
57
- # @example Action button
58
- # @description
59
- # Provide a button to guide users to take action from the blankslate. The button appears below the description and custom content.
60
- # @code
61
- # <%= render Primer::BlankslateComponent.new(
62
- # icon: :book,
63
- # title: "Welcome to the mona wiki!",
64
- # description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
65
- #
66
- # button_text: "Create the first page",
67
- # button_url: "https://github.com/monalisa/mona/wiki/_new",
68
- # ) %>
69
- #
70
- # @example Link
71
- # @description
72
- # Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
73
- # @code
74
- # <%= render Primer::BlankslateComponent.new(
75
- # icon: :book,
76
- # title: "Welcome to the mona wiki!",
77
- # description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
78
- # link_text: "Learn more about wikis",
79
- # link_url: "https://docs.github.com/en/github/building-a-strong-community/about-wikis",
80
- # ) %>
81
- #
82
- # @example Variations
83
- # @description
84
- # There are a few variations of how the Blankslate appears: `narrow` adds a maximum width, `large` increases the font size, and `spacious` adds extra padding.
85
- # @code
86
- # <%= render Primer::BlankslateComponent.new(
87
- # icon: :book,
88
- # title: "Welcome to the mona wiki!",
89
- # description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
90
- # narrow: true,
91
- # large: true,
92
- # spacious: true,
93
- # ) %>
94
- #
95
19
  # @param title [String] Text that appears in a larger bold font.
96
20
  # @param title_tag [Symbol] HTML tag to use for title.
97
21
  # @param icon [Symbol] Octicon icon to use at top of component.
@@ -5,12 +5,6 @@ module Primer
5
5
  class Box < Primer::Component
6
6
  status :stable
7
7
 
8
- # @example Default
9
- # <%= render(Primer::Box.new) { "Your content here" } %>
10
- #
11
- # @example Color and padding
12
- # <%= render(Primer::Box.new(bg: :subtle, p: 3)) { "Hello world" } %>
13
- #
14
8
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
15
9
  def initialize(**system_arguments)
16
10
  @system_arguments = deny_tag_argument(**system_arguments)
@@ -71,55 +71,6 @@ module Primer
71
71
  Primer::Alpha::Tooltip.new(**system_arguments)
72
72
  }
73
73
 
74
- # @example Schemes
75
- # <%= render(Primer::ButtonComponent.new) { "Default" } %>
76
- # <%= render(Primer::ButtonComponent.new(scheme: :primary)) { "Primary" } %>
77
- # <%= render(Primer::ButtonComponent.new(scheme: :danger)) { "Danger" } %>
78
- # <%= render(Primer::ButtonComponent.new(scheme: :outline)) { "Outline" } %>
79
- # <%= render(Primer::ButtonComponent.new(scheme: :invisible)) { "Invisible" } %>
80
- # <%= render(Primer::ButtonComponent.new(scheme: :link)) { "Link" } %>
81
- #
82
- # @example Sizes
83
- # <%= render(Primer::ButtonComponent.new(size: :small)) { "Small" } %>
84
- # <%= render(Primer::ButtonComponent.new(size: :medium)) { "Medium" } %>
85
- #
86
- # @example Block
87
- # <%= render(Primer::ButtonComponent.new(block: :true)) { "Block" } %>
88
- # <%= render(Primer::ButtonComponent.new(block: :true, scheme: :primary)) { "Primary block" } %>
89
- #
90
- # @example With leading visual
91
- # <%= render(Primer::ButtonComponent.new) do |component| %>
92
- # <% component.with_leading_visual_icon(icon: :star) %>
93
- # Button
94
- # <% end %>
95
- #
96
- # @example With trailing visual
97
- # <%= render(Primer::ButtonComponent.new) do |component| %>
98
- # <% component.with_trailing_visual_counter(count: 15) %>
99
- # Button
100
- # <% end %>
101
- #
102
- # @example With leading and trailing visuals
103
- # <%= render(Primer::ButtonComponent.new) do |component| %>
104
- # <% component.with_leading_visual_icon(icon: :star) %>
105
- # <% component.with_trailing_visual_counter(count: 15) %>
106
- # Button
107
- # <% end %>
108
- #
109
- # @example With dropdown caret
110
- # <%= render(Primer::ButtonComponent.new(dropdown: true)) do %>
111
- # Button
112
- # <% end %>
113
- #
114
- # @example With tooltip
115
- # @description
116
- # Use tooltips sparingly and as a last resort. Consult the <%= link_to_component(Primer::Alpha::Tooltip) %> documentation for more information.
117
- # @code
118
- # <%= render(Primer::ButtonComponent.new(id: "button-with-tooltip")) do |component| %>
119
- # <% component.with_tooltip(text: "Tooltip text") %>
120
- # Button
121
- # <% end %>
122
- #
123
74
  # @param scheme [Symbol] <%= one_of(Primer::ButtonComponent::SCHEME_OPTIONS) %>
124
75
  # @param variant [Symbol] DEPRECATED. <%= one_of(Primer::ButtonComponent::SIZE_OPTIONS) %>
125
76
  # @param size [Symbol] <%= one_of(Primer::ButtonComponent::SIZE_OPTIONS) %>
@@ -52,7 +52,7 @@ module Primer
52
52
  message += " and will be removed in v#{version}." if version
53
53
  message += " Use #{new_class.name} instead." if new_class
54
54
 
55
- ActiveSupport::Deprecation.warn(message)
55
+ ::Primer::ViewComponents.deprecation.warn(message)
56
56
  end
57
57
 
58
58
  def validate_aria_label
@@ -4,24 +4,9 @@ module Primer
4
4
  # Conditionally renders a `Primer::BaseComponent` around the given content. If the given condition
5
5
  # is true, a `Primer::BaseComponent` will render around the content. If the condition is false, only
6
6
  # the content is rendered.
7
- #
8
- # @example True conditional
9
- # <%# condition is true, so content will be wrapped in a <span> tag
10
- # <%= render Primer::ConditionalWrapper.new(condition: true, tag: :span, class: "foobar")) do %>
11
- # <%# also rendered %>
12
- # <p class="bazboo">Some text</p>
13
- # <% end %>
14
- #
15
- # @example False conditional
16
- # <%# condition is false so no <span> tag will render around the content (i.e. the <p> tag)
17
- # <%= render(Primer::ConditionalWrapper.new(condition: false, tag: :span, class: "foobar")) do %>
18
- # <%# this content will be rendered %>
19
- # <p class="bazboo">Some text</p>
20
- # <% end %>
21
- #
22
- # @param condition [Boolean] Whether or not to wrap the content in a `Primer::BaseComponent`.
23
- # @param base_component_arguments [Hash] The arguments to pass to `Primer::BaseComponent`.
24
7
  class ConditionalWrapper < Primer::Component
8
+ # @param condition [Boolean] Whether or not to wrap the content in a `Primer::BaseComponent`.
9
+ # @param base_component_arguments [Hash] The arguments to pass to `Primer::BaseComponent`.
25
10
  def initialize(condition:, **base_component_arguments)
26
11
  @condition = condition
27
12
  @base_component_arguments = base_component_arguments
@@ -21,36 +21,6 @@ module Primer
21
21
  }.freeze
22
22
  SCHEME_OPTIONS = SCHEME_MAPPINGS.keys
23
23
 
24
- # @example Default
25
- #
26
- # <%= render(Primer::IconButton.new(icon: :search, "aria-label": "Search", id: "search-button")) %>
27
- #
28
- # @example Schemes
29
- #
30
- # <%= render(Primer::IconButton.new(icon: :search, "aria-label": "Search")) %>
31
- # <%= render(Primer::IconButton.new(icon: :trash, "aria-label": "Delete", scheme: :danger)) %>
32
- #
33
- # @example In a BorderBox
34
- #
35
- # <%= render(Primer::Beta::BorderBox.new) do |component| %>
36
- # <% component.with_body do %>
37
- # <%= render(Primer::Beta::Text.new(pr: 2)) { "Body" } %>
38
- # <%= render(Primer::IconButton.new(icon: :pencil, box: true, "aria-label": "Edit")) %>
39
- # <% end %>
40
- # <% end %>
41
- #
42
- # @example With an `aria-description`
43
- # @description
44
- # If you need to have a longer description for the icon button, use both the `aria-label` and `aria-description`
45
- # attributes. A label should be short and concise, while the description can be longer as it is intended to provide
46
- # more context and information. See the accessibility section for more information.
47
- # @code
48
- # <%= render(Primer::IconButton.new(icon: :bold, "aria-label": "Bold", "aria-description": "Add bold text, Cmd+b")) %>
49
- #
50
- # @example Custom tooltip direction
51
- #
52
- # <%= render(Primer::IconButton.new(icon: :search, "aria-label": "Search", tooltip_direction: :e)) %>
53
- #
54
24
  # @param scheme [Symbol] <%= one_of(Primer::IconButton::SCHEME_OPTIONS) %>
55
25
  # @param icon [String] Name of <%= link_to_octicons %> to use.
56
26
  # @param tag [Symbol] <%= one_of(Primer::Beta::BaseButton::TAG_OPTIONS) %>
@@ -38,18 +38,6 @@ module Primer
38
38
  DEFAULT_SIDEBAR_COL = 3
39
39
  ALLOWED_SIDEBAR_COLS = (1..(MAX_COL - 1)).to_a.freeze
40
40
 
41
- # @example Default
42
- # <%= render(Primer::LayoutComponent.new) do |component| %>
43
- # <% component.with_sidebar { "Sidebar" } %>
44
- # <% component.with_main { "Main" } %>
45
- # <% end %>
46
- #
47
- # @example Left sidebar
48
- # <%= render(Primer::LayoutComponent.new(side: :left)) do |component| %>
49
- # <% component.with_sidebar { "Sidebar" } %>
50
- # <% component.with_main { "Main" } %>
51
- # <% end %>
52
- #
53
41
  # @param responsive [Boolean] Whether to collapse layout to a single column at smaller widths.
54
42
  # @param side [Symbol] Which side to display the sidebar on. <%= one_of(Primer::LayoutComponent::ALLOWED_SIDES) %>
55
43
  # @param sidebar_col [Integer] Sidebar column width.
@@ -28,33 +28,6 @@ module Primer
28
28
  se
29
29
  ]
30
30
 
31
- # @example Default
32
- # <div class="pt-5">
33
- # <%= render(Primer::Tooltip.new(label: "Even bolder")) { "Default Bold Text" } %>
34
- # </div>
35
- #
36
- # @example Wrapping another component
37
- # <div class="pt-5">
38
- # <%= render(Primer::Tooltip.new(label: "Even bolder")) do %>
39
- # <%= render(Primer::ButtonComponent.new) { "Bold Button" } %>
40
- # <% end %>
41
- # </div>
42
- #
43
- # @example With a direction
44
- # <div class="pt-5">
45
- # <%= render(Primer::Tooltip.new(label: "Even bolder", direction: :s)) { "Bold Text With a Direction" } %>
46
- # </div>
47
- #
48
- # @example With an alignment
49
- # <div class="pt-5">
50
- # <%= render(Primer::Tooltip.new(label: "Even bolder", direction: :s, alignment: :right_1)) { "Bold Text With an Alignment" } %>
51
- # </div>
52
- #
53
- # @example Without a delay
54
- # <div class="pt-5">
55
- # <%= render(Primer::Tooltip.new(label: "Even bolder", direction: :s, no_delay: true)) { "Bold Text without a delay" } %>
56
- # </div>
57
- #
58
31
  # @param label [String] the text to appear in the tooltip
59
32
  # @param direction [String] Direction of the tooltip. <%= one_of(Primer::Tooltip::DIRECTION_OPTIONS) %>
60
33
  # @param align [String] Align tooltips to the left or right of an element, combined with a `direction` to specify north or south. <%= one_of(Primer::Tooltip::ALIGN_MAPPING.keys) %>
@@ -8,25 +8,6 @@ module Primer
8
8
  DEFAULT_TAG = :div
9
9
  TAG_OPTIONS = [DEFAULT_TAG, :span, :p, :strong].freeze
10
10
 
11
- # @example Default
12
- # <div class="col-2">
13
- # <%= render(Primer::Truncate.new(tag: :p)) { "branch-name-that-is-really-long" } %>
14
- # </div>
15
- #
16
- # @example Inline
17
- # <%= render(Primer::Truncate.new(tag: :span, inline: true)) { "branch-name-that-is-really-long" } %>
18
- #
19
- # @example Expandable
20
- # <%= render(Primer::Truncate.new(tag: :span, inline: true, expandable: true)) { "branch-name-that-is-really-long" } %>
21
- #
22
- # @example Custom size
23
- # <%= render(Primer::Truncate.new(tag: :span, inline: true, expandable: true, max_width: 100)) { "branch-name-that-is-really-long" } %>
24
- #
25
- # @example With HTML content
26
- # <%= render(Primer::Truncate.new(tag: :span, inline: true, expandable: true, max_width: 100)) do %>
27
- # <span>branch-name-that-is-really-long</span>
28
- # <% end %>
29
- #
30
11
  # @param tag [Symbol] <%= one_of(Primer::Truncate::TAG_OPTIONS) %>
31
12
  # @param inline [Boolean] Whether the element is inline (or inline-block).
32
13
  # @param expandable [Boolean] Whether the entire string should be revealed on hover. Can only be used in conjunction with `inline`.
@@ -29,7 +29,7 @@ module Primer
29
29
  if allowed_values.include?(given_value)
30
30
  given_value
31
31
  elsif deprecated_values&.include?(given_value)
32
- ActiveSupport::Deprecation.warn("#{given_value} is deprecated and will be removed in a future version.") unless Rails.env.production? || silence_deprecations?
32
+ ::Primer::ViewComponents.deprecation.warn("#{given_value} is deprecated and will be removed in a future version.") unless Rails.env.production? || silence_deprecations?
33
33
 
34
34
  given_value
35
35
  else
@@ -39,7 +39,7 @@ module Primer
39
39
 
40
40
  class << self
41
41
  def ignore_preview?(preview_class)
42
- preview_class.name.start_with?("Docs::") || IGNORED_PREVIEWS.include?(preview_class)
42
+ IGNORED_PREVIEWS.include?(preview_class)
43
43
  end
44
44
 
45
45
  def axe_rules_to_skip(component: nil, scenario_name: nil, flatten: false)
@@ -20,7 +20,7 @@ deprecations:
20
20
  - component: "Primer::ButtonComponent"
21
21
  autocorrect: false
22
22
  replacement: "Primer::Beta::Button"
23
- guide: "https://primer.style/view-components/guides/primer_button_component"
23
+ guide: "https://primer.style/design/guides/development/rails/migration-guides/primer-button-component"
24
24
 
25
25
  - component: "Primer::IconButton"
26
26
  autocorrect: true
@@ -29,7 +29,7 @@ deprecations:
29
29
  - component: "Primer::LayoutComponent"
30
30
  autocorrect: false
31
31
  replacement: "Primer::Alpha::Layout"
32
- guide: "https://primer.style/view-components/guides/primer_layout_component"
32
+ guide: "https://primer.style/design/guides/development/rails/migration-guides/primer-layout-component"
33
33
 
34
34
  - component: "Primer::Navigation::TabComponent"
35
35
  autocorrect: true
@@ -42,4 +42,4 @@ deprecations:
42
42
  - component: "Primer::Truncate"
43
43
  autocorrect: false
44
44
  replacement: "Primer::Beta::Truncate"
45
- guide: "https://primer.style/view-components/guides/primer_truncate"
45
+ guide: "https://primer.style/design/guides/development/rails/migration-guides/primer-truncate"
@@ -115,6 +115,7 @@ module Primer
115
115
  end
116
116
 
117
117
  add_input_aria(:required, true) if required?
118
+ add_input_aria(:invalid, true) if invalid?
118
119
  add_input_aria(:describedby, ids.values) if ids.any?
119
120
 
120
121
  # avoid browser-native validation, which doesn't match Primer's style
@@ -11,7 +11,7 @@ module ERBLint
11
11
  include Helpers::RuleHelpers
12
12
 
13
13
  MIGRATE_FROM_DETAILS_MENU = "<details-menu> has been deprecated. Please instead use Primer::Alpha::ActionMenu" \
14
- "https://primer.style/design/components/action-menu/rails/alpha"
14
+ " https://primer.style/design/components/action-menu/rails/alpha"
15
15
  DETAILS_MENU_RUBY_PATTERN = /tag:?\s+:"details-menu"/.freeze
16
16
 
17
17
  def run(processed_source)
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Migrations
6
+ # Lint & autocorrect Truncate components
7
+ class TruncateComponent < RuboCop::Cop::Cop
8
+ INVALID_MESSAGE = <<~STR
9
+ `Primer::Truncate` is deprecated. Please use `Primer::Beta::Truncate` instead!
10
+ STR
11
+
12
+ def_node_matcher :truncate_component, <<~PATTERN
13
+ (send (const (const nil? :Primer) :Truncate) :new ...)
14
+ PATTERN
15
+
16
+ def_node_matcher :hash_with_inline_value?, <<~PATTERN
17
+ (hash ... (pair (sym :inline) (...)) ... )
18
+ PATTERN
19
+
20
+ def_node_matcher :truncate_with_tag?, <<~PATTERN
21
+ (hash ... (pair (sym :tag) (...)) ... )
22
+ PATTERN
23
+
24
+ def on_send(node)
25
+ return unless truncate_component(node)
26
+
27
+ add_offense(node, message: INVALID_MESSAGE)
28
+ end
29
+
30
+ def autocorrect(node)
31
+ return if hash_with_inline_value?(node.arguments.first)
32
+
33
+ lambda do |corrector|
34
+ if node.arguments.first.nil? == false
35
+ corrector.replace(node.children.first, "Primer::Beta::Truncate")
36
+ corrector.insert_after(node.arguments.first, ", tag: :div") unless truncate_with_tag?(node.arguments.first)
37
+ else
38
+ corrector.replace(node.loc.expression, "Primer::Beta::Truncate.new(tag: :div)")
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -10,7 +10,7 @@ module ERBLint
10
10
  include LinterRegistry
11
11
  include Helpers::RuleHelpers
12
12
 
13
- MIGRATE_TO_NEWER_TOOLTIP = ".tooltipped has been deprecated. There are major accessibility concerns with using this tooltip so please take action. See https://github.com/primer/view_components/blob/main/docs/content/guides/accessibility/tooltipped_migration.md."
13
+ MIGRATE_TO_NEWER_TOOLTIP = ".tooltipped has been deprecated. There are major accessibility concerns with using this tooltip so please take action. See https://primer.style/design/guides/development/rails/migration-guides/primer-css-tooltipped."
14
14
  TOOLTIPPED_RUBY_PATTERN = /classes:.*tooltipped|class:.*tooltipped/.freeze
15
15
 
16
16
  def run(processed_source)
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Dir[File.join(__dir__, "linters", "*.rb")].sort.each { |file| require file }
4
+ Dir[File.join(__dir__, "linters", "migrations", "*.rb")].sort.each { |file| require file }
@@ -5,8 +5,8 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 6
9
- PATCH = 3
8
+ MINOR = 8
9
+ PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
12
12
  end
@@ -7,9 +7,27 @@ require "primer/view_components/engine"
7
7
  module Primer
8
8
  # :nodoc:
9
9
  module ViewComponents
10
+ DEPRECATION_HORIZON = "1.0"
11
+
10
12
  # primer/view_components root directory.
11
13
  def self.root
12
14
  Pathname(File.expand_path(File.join("..", ".."), __dir__))
13
15
  end
16
+
17
+ # Skip coverage here because only one branch will execute depending on what
18
+ # Rails version you're running.
19
+
20
+ # :nocov:
21
+ def self.deprecation
22
+ @deprecation ||=
23
+ if Rails.application.respond_to?(:deprecators)
24
+ Rails.application.deprecators[:primer_view_components] ||= ActiveSupport::Deprecation.new(
25
+ DEPRECATION_HORIZON, "primer_view_components"
26
+ )
27
+ else
28
+ ActiveSupport::Deprecation.instance
29
+ end
30
+ end
31
+ # :nocov:
14
32
  end
15
33
  end
data/lib/primer/yard.rb CHANGED
@@ -5,15 +5,14 @@ require "yard"
5
5
  module Primer
6
6
  # :nodoc:
7
7
  module Yard
8
- autoload :Backend, "primer/yard/backend"
9
- autoload :ComponentManifest, "primer/yard/component_manifest"
10
- autoload :ComponentRef, "primer/yard/component_ref"
11
- autoload :DocsHelper, "primer/yard/docs_helper"
12
- autoload :InfoArchDocsHelper, "primer/yard/info_arch_docs_helper"
13
- autoload :LegacyGatsbyBackend, "primer/yard/legacy_gatsby_backend"
14
- autoload :Registry, "primer/yard/registry"
15
- autoload :RendersManyHandler, "primer/yard/renders_many_handler"
16
- autoload :RendersOneHandler, "primer/yard/renders_one_handler"
8
+ autoload :Backend, "primer/yard/backend"
9
+ autoload :ComponentManifest, "primer/yard/component_manifest"
10
+ autoload :ComponentRef, "primer/yard/component_ref"
11
+ autoload :DocsHelper, "primer/yard/docs_helper"
12
+ autoload :InfoArchDocsHelper, "primer/yard/info_arch_docs_helper"
13
+ autoload :Registry, "primer/yard/registry"
14
+ autoload :RendersManyHandler, "primer/yard/renders_many_handler"
15
+ autoload :RendersOneHandler, "primer/yard/renders_one_handler"
17
16
 
18
17
  ::YARD::Tags::Library.define_tag("Snapshot preview", :snapshot)
19
18
  end
@@ -2,9 +2,9 @@
2
2
  scheme: scheme,
3
3
  size: size,
4
4
  block: block,
5
- id: id,
5
+ id: "button-preview",
6
6
  align_content: align_content
7
7
  )) do |component| %>
8
8
  <% component.with_leading_visual_icon(icon: :search) %>
9
- Button
9
+ Search
10
10
  <% end %>
@@ -0,0 +1,12 @@
1
+ <%= render(Primer::Beta::Button.new(
2
+ scheme: scheme,
3
+ size: size,
4
+ block: block,
5
+ id: "button-preview",
6
+ align_content: align_content
7
+ )) do |component| %>
8
+ <% component.with_leading_visual_svg do %>
9
+ <path d="M8 16a2 2 0 001.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 008 16z"></path><path fill-rule="evenodd" d="M8 1.5A3.5 3.5 0 004.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.018.018 0 00-.003.01l.001.006c0 .002.002.004.004.006a.017.017 0 00.006.004l.007.001h10.964l.007-.001a.016.016 0 00.006-.004.016.016 0 00.004-.006l.001-.007a.017.017 0 00-.003-.01l-1.703-2.554a1.75 1.75 0 01-.294-.97V5A3.5 3.5 0 008 1.5zM3 5a5 5 0 0110 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.518 1.518 0 0113.482 13H2.518a1.518 1.518 0 01-1.263-2.36l1.703-2.554A.25.25 0 003 7.947V5z"></path>
10
+ <% end %>
11
+ Button
12
+ <% end %>
@@ -7,5 +7,5 @@
7
7
  )) do |component| %>
8
8
  <% component.with_leading_visual_icon(icon: :star) %>
9
9
  <% component.with_trailing_visual_counter(count: 15) %>
10
- Button
10
+ Star
11
11
  <% end %>
@@ -7,5 +7,5 @@
7
7
  tag: tag
8
8
  )) do |component| %>
9
9
  <% component.with_trailing_visual_counter(count: "15") %>
10
- Button
10
+ Comment
11
11
  <% end %>
@@ -264,6 +264,28 @@ module Primer
264
264
  })
265
265
  end
266
266
 
267
+ # @label Leading visual SVG
268
+ # @param scheme select [default, primary, danger, invisible, link]
269
+ # @param size select [small, medium]
270
+ # @param block toggle
271
+ # @param align_content select [center, start]
272
+ # @snapshot
273
+ def leading_visual_svg(
274
+ scheme: :invisible,
275
+ size: :medium,
276
+ block: false,
277
+ id: "button-preview",
278
+ align_content: :center
279
+ )
280
+ render_with_template(locals: {
281
+ scheme: scheme,
282
+ size: size,
283
+ block: block,
284
+ id: id,
285
+ align_content: align_content
286
+ })
287
+ end
288
+
267
289
  # @label Trailing action
268
290
  # @param block toggle
269
291
  # @param align_content select [center, start]