primer_view_components 0.0.116 → 0.0.117

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -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 +2 -2
  6. data/app/assets/styles/primer_view_components.css.map +1 -1
  7. data/app/components/primer/alpha/action_list.css +1 -1
  8. data/app/components/primer/alpha/action_list.css.json +1 -1
  9. data/app/components/primer/alpha/action_list.css.map +1 -1
  10. data/app/components/primer/alpha/auto_complete/item.rb +4 -4
  11. data/app/components/primer/alpha/auto_complete.rb +6 -6
  12. data/app/components/primer/alpha/dialog.rb +0 -2
  13. data/app/components/primer/alpha/dropdown.rb +53 -53
  14. data/app/components/primer/alpha/hellip_button.rb +41 -0
  15. data/app/components/primer/alpha/hidden_text_expander.rb +1 -1
  16. data/app/components/primer/alpha/layout.rb +48 -48
  17. data/app/components/primer/alpha/menu.css +1 -1
  18. data/app/components/primer/alpha/menu.css.json +1 -1
  19. data/app/components/primer/alpha/menu.css.map +1 -1
  20. data/app/components/primer/alpha/menu.rb +5 -5
  21. data/app/components/primer/alpha/segmented_control.rb +20 -20
  22. data/app/components/primer/{tab_container_component.d.ts → alpha/tab_container.d.ts} +0 -0
  23. data/app/components/primer/{tab_container_component.js → alpha/tab_container.js} +0 -0
  24. data/app/components/primer/alpha/tab_container.rb +43 -0
  25. data/app/components/primer/{tab_container_component.ts → alpha/tab_container.ts} +0 -0
  26. data/app/components/primer/alpha/tab_nav.css +1 -1
  27. data/app/components/primer/alpha/tab_nav.css.json +1 -1
  28. data/app/components/primer/alpha/tab_nav.css.map +1 -1
  29. data/app/components/primer/alpha/tab_nav.rb +32 -32
  30. data/app/components/primer/alpha/tool_tip.js +3 -7
  31. data/app/components/primer/alpha/tool_tip.ts +3 -7
  32. data/app/components/primer/alpha/tooltip.rb +18 -18
  33. data/app/components/primer/alpha/underline_nav.css +1 -1
  34. data/app/components/primer/alpha/underline_nav.css.json +1 -1
  35. data/app/components/primer/alpha/underline_nav.css.map +1 -1
  36. data/app/components/primer/alpha/underline_nav.rb +18 -18
  37. data/app/components/primer/beta/auto_complete/item.rb +2 -3
  38. data/app/components/primer/beta/auto_complete.rb +14 -16
  39. data/app/components/primer/beta/avatar_stack.rb +12 -14
  40. data/app/components/primer/beta/blankslate.rb +0 -1
  41. data/app/components/primer/beta/border_box/header.rb +0 -2
  42. data/app/components/primer/beta/border_box.rb +0 -2
  43. data/app/components/primer/beta/breadcrumbs.css +1 -1
  44. data/app/components/primer/beta/breadcrumbs.css.json +1 -1
  45. data/app/components/primer/beta/breadcrumbs.css.map +1 -1
  46. data/app/components/primer/beta/breadcrumbs.rb +0 -1
  47. data/app/components/primer/beta/button.rb +9 -10
  48. data/app/components/primer/beta/button_group.rb +0 -1
  49. data/app/components/primer/beta/details.rb +0 -1
  50. data/app/components/primer/beta/flash.rb +0 -1
  51. data/app/components/primer/beta/link.rb +2 -3
  52. data/app/components/primer/beta/octicon.rb +0 -1
  53. data/app/components/primer/beta/popover.rb +0 -1
  54. data/app/components/primer/{state_component.css → beta/state.css} +0 -0
  55. data/app/components/primer/beta/state.css.json +1 -0
  56. data/app/components/primer/beta/state.css.map +1 -0
  57. data/app/components/primer/{state_component.pcss → beta/state.pcss} +0 -0
  58. data/app/components/primer/beta/state.rb +76 -0
  59. data/app/components/primer/{subhead_component.css → beta/subhead.css} +0 -0
  60. data/app/components/primer/beta/subhead.css.json +1 -0
  61. data/app/components/primer/beta/subhead.css.map +1 -0
  62. data/app/components/primer/{subhead_component.html.erb → beta/subhead.html.erb} +0 -0
  63. data/app/components/primer/{subhead_component.pcss → beta/subhead.pcss} +0 -0
  64. data/app/components/primer/beta/subhead.rb +135 -0
  65. data/app/components/primer/{timeline_item_component.css → beta/timeline_item.css} +0 -0
  66. data/app/components/primer/beta/timeline_item.css.json +1 -0
  67. data/app/components/primer/beta/timeline_item.css.map +1 -0
  68. data/app/components/primer/{timeline_item_component.html.erb → beta/timeline_item.html.erb} +0 -0
  69. data/app/components/primer/{timeline_item_component.pcss → beta/timeline_item.pcss} +0 -0
  70. data/app/components/primer/beta/timeline_item.rb +90 -0
  71. data/app/components/primer/beta/truncate.css +1 -1
  72. data/app/components/primer/beta/truncate.css.json +1 -1
  73. data/app/components/primer/beta/truncate.css.map +1 -1
  74. data/app/components/primer/beta/truncate.rb +0 -1
  75. data/app/components/primer/button_component.rb +9 -9
  76. data/app/components/primer/component.rb +0 -1
  77. data/app/components/primer/hellip_button.rb +2 -34
  78. data/app/components/primer/navigation/tab_component.rb +16 -16
  79. data/app/components/primer/primer.d.ts +1 -1
  80. data/app/components/primer/primer.js +1 -1
  81. data/app/components/primer/primer.pcss +3 -3
  82. data/app/components/primer/primer.ts +1 -1
  83. data/app/components/primer/state_component.rb +2 -69
  84. data/app/components/primer/subhead_component.rb +2 -128
  85. data/app/components/primer/tab_container_component.rb +2 -36
  86. data/app/components/primer/timeline_item_component.rb +5 -78
  87. data/app/forms/example_toggle_switch_form/example_field_caption.html.erb +1 -0
  88. data/app/forms/example_toggle_switch_form.rb +8 -0
  89. data/app/forms/submit_button_form.rb +4 -4
  90. data/app/lib/primer/tabbed_component_helper.rb +1 -1
  91. data/lib/primer/deprecations.rb +7 -13
  92. data/lib/primer/deprecations.yml +24 -0
  93. data/lib/primer/forms/button.html.erb +2 -2
  94. data/lib/primer/forms/dsl/toggle_switch_input.rb +35 -0
  95. data/lib/primer/forms/toggle_switch.html.erb +17 -0
  96. data/lib/primer/forms/toggle_switch.rb +19 -0
  97. data/lib/primer/forms/toggle_switch_form.rb +74 -0
  98. data/lib/primer/view_components/linters/subhead_component_migration_counter.rb +1 -1
  99. data/lib/primer/view_components/version.rb +1 -1
  100. data/lib/rubocop/cop/primer/component_name_migration.rb +2 -1
  101. data/lib/tasks/docs.rake +6 -6
  102. data/previews/primer/alpha/action_list_preview.rb +44 -44
  103. data/previews/primer/alpha/dropdown_preview.rb +97 -97
  104. data/previews/primer/alpha/hellip_button_preview.rb +24 -0
  105. data/previews/primer/alpha/layout_preview.rb +63 -63
  106. data/previews/primer/alpha/menu_preview/default.html.erb +5 -5
  107. data/previews/primer/alpha/menu_preview/playground.html.erb +5 -5
  108. data/previews/primer/alpha/segmented_control_preview.rb +60 -60
  109. data/previews/primer/alpha/tab_nav_preview.rb +22 -22
  110. data/previews/primer/alpha/tab_panels_preview.rb +2 -2
  111. data/previews/primer/alpha/tooltip_preview/with_multiple_on_a_page.html.erb +6 -6
  112. data/previews/primer/alpha/tooltip_preview.rb +12 -12
  113. data/previews/primer/alpha/underline_nav_preview.rb +4 -4
  114. data/previews/primer/alpha/underline_panels_preview.rb +8 -8
  115. data/previews/primer/beta/auto_complete_item_preview/default.html.erb +2 -2
  116. data/previews/primer/beta/auto_complete_item_preview/playground.html.erb +2 -2
  117. data/previews/primer/beta/auto_complete_item_preview/with_description.html.erb +3 -3
  118. data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +2 -2
  119. data/previews/primer/beta/auto_complete_preview.rb +18 -18
  120. data/previews/primer/beta/avatar_stack_preview.rb +32 -32
  121. data/previews/primer/beta/blankslate_preview.rb +40 -40
  122. data/previews/primer/beta/border_box_preview.rb +38 -38
  123. data/previews/primer/beta/breadcrumbs_preview.rb +2 -2
  124. data/previews/primer/beta/button_group_preview.rb +10 -10
  125. data/previews/primer/beta/button_preview/all_schemes.html.erb +4 -4
  126. data/previews/primer/beta/button_preview/invisible_all_visuals.html.erb +16 -16
  127. data/previews/primer/beta/button_preview/leading_visual.html.erb +2 -2
  128. data/previews/primer/beta/button_preview/trailing_action.html.erb +2 -2
  129. data/previews/primer/beta/button_preview/trailing_visual.html.erb +2 -2
  130. data/previews/primer/beta/button_preview/with_tooltip.html.erb +2 -2
  131. data/previews/primer/beta/details_preview.rb +6 -6
  132. data/previews/primer/beta/state_preview.rb +66 -0
  133. data/previews/primer/beta/subhead_preview/actions.html.erb +14 -0
  134. data/previews/primer/beta/subhead_preview.rb +99 -0
  135. data/previews/primer/beta/timeline_item_preview.rb +30 -0
  136. data/previews/primer/forms/forms_preview/example_toggle_switch_form.html.erb +1 -0
  137. data/previews/primer/forms/forms_preview.rb +2 -0
  138. data/static/arguments.json +118 -118
  139. data/static/audited_at.json +6 -0
  140. data/static/constants.json +67 -54
  141. data/static/statuses.json +12 -6
  142. metadata +36 -23
  143. data/app/components/primer/state_component.css.json +0 -1
  144. data/app/components/primer/state_component.css.map +0 -1
  145. data/app/components/primer/subhead_component.css.json +0 -1
  146. data/app/components/primer/subhead_component.css.map +0 -1
  147. data/app/components/primer/timeline_item_component.css.json +0 -1
  148. data/app/components/primer/timeline_item_component.css.map +0 -1
  149. data/previews/primer/hellip_button_preview.rb +0 -22
  150. data/previews/primer/state_component_preview.rb +0 -26
  151. data/previews/primer/subhead_component_preview.rb +0 -40
  152. data/previews/primer/timeline_item_component_preview.rb +0 -28
@@ -0,0 +1,135 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # Use `Subhead` as the start of a section. The `:heading` slot will render an `<h2>` font-sized text.
6
+ #
7
+ # - Optionally set the `:description` slot to render a short description and the `:actions` slot for a related action.
8
+ # - Use a succinct, one-line description for the `:description` slot. For longer descriptions, omit the description slot and render a paragraph below the `Subhead`.
9
+ # - Use the actions slot to render a related action to the right of the heading. Use <%= link_to_component(Primer::ButtonComponent) %> or <%= link_to_component(Primer::Beta::Link) %>.
10
+ #
11
+ # @accessibility
12
+ # The `:heading` slot defaults to rendering a `<div>`. Update the tag to a heading element with the appropriate level to improve page navigation for assistive technologies.
13
+ # <%= link_to_heading_practices %>
14
+ class Subhead < Primer::Component
15
+ status :beta
16
+
17
+ DEFAULT_HEADING_TAG = :div
18
+ HEADING_TAG_OPTIONS = [DEFAULT_HEADING_TAG, :h1, :h2, :h3, :h4, :h5, :h6].freeze
19
+
20
+ # The heading
21
+ #
22
+ # @param tag [Symbol] <%= one_of(Primer::Beta::Subhead::HEADING_TAG_OPTIONS)%>
23
+ # @param danger [Boolean] Whether to style the heading as dangerous.
24
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
25
+ renders_one :heading, lambda { |tag: DEFAULT_HEADING_TAG, danger: false, **system_arguments|
26
+ system_arguments[:tag] = fetch_or_fallback(HEADING_TAG_OPTIONS, tag, DEFAULT_HEADING_TAG)
27
+ system_arguments[:classes] = class_names(
28
+ system_arguments[:classes],
29
+ "Subhead-heading",
30
+ "Subhead-heading--danger": danger
31
+ )
32
+
33
+ Primer::BaseComponent.new(**system_arguments)
34
+ }
35
+
36
+ # Actions
37
+ #
38
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
39
+ renders_one :actions, lambda { |**system_arguments|
40
+ deny_tag_argument(**system_arguments)
41
+ system_arguments[:tag] = :div
42
+ system_arguments[:classes] = class_names(system_arguments[:classes], "Subhead-actions")
43
+
44
+ Primer::BaseComponent.new(**system_arguments)
45
+ }
46
+
47
+ # The description
48
+ #
49
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
50
+ renders_one :description, lambda { |**system_arguments|
51
+ deny_tag_argument(**system_arguments)
52
+ system_arguments[:tag] = :div
53
+ system_arguments[:classes] = class_names(system_arguments[:classes], "Subhead-description")
54
+
55
+ Primer::BaseComponent.new(**system_arguments)
56
+ }
57
+
58
+ # @example Default
59
+ # <%= render(Primer::Beta::Subhead.new) do |component| %>
60
+ # <% component.with_heading(tag: :h3) do %>
61
+ # My Heading
62
+ # <% end %>
63
+ # <% component.with_description do %>
64
+ # My Description
65
+ # <% end %>
66
+ # <% end %>
67
+ #
68
+ # @example With dangerous heading
69
+ # <%= render(Primer::Beta::Subhead.new) do |component| %>
70
+ # <% component.with_heading(tag: :h3, danger: true) do %>
71
+ # My Heading
72
+ # <% end %>
73
+ # <% component.with_description do %>
74
+ # My Description
75
+ # <% end %>
76
+ # <% end %>
77
+ #
78
+ # @example With long description
79
+ # <%= render(Primer::Beta::Subhead.new) do |component| %>
80
+ # <% component.with_heading(tag: :h3) do %>
81
+ # My Heading
82
+ # <% end %>
83
+ # <% end %>
84
+ # <p> This is a longer description that is sitting below the Subhead. It's much longer than a description that could sit comfortably in the Subhead. </p>
85
+ #
86
+ # @example Without border
87
+ # <%= render(Primer::Beta::Subhead.new(hide_border: true)) do |component| %>
88
+ # <% component.with_heading do %>
89
+ # My Heading
90
+ # <% end %>
91
+ # <% component.with_description do %>
92
+ # My Description
93
+ # <% end %>
94
+ # <% end %>
95
+ #
96
+ # @example With actions
97
+ # <%= render(Primer::Beta::Subhead.new) do |component| %>
98
+ # <% component.with_heading do %>
99
+ # My Heading
100
+ # <% end %>
101
+ # <% component.with_description do %>
102
+ # My Description
103
+ # <% end %>
104
+ # <% component.with_actions do %>
105
+ # <%= render(
106
+ # Primer::ButtonComponent.new(
107
+ # tag: :a, href: "http://www.google.com", scheme: :danger
108
+ # )
109
+ # ) { "Action" } %>
110
+ # <% end %>
111
+ # <% end %>
112
+ #
113
+ # @param spacious [Boolean] Whether to add spacing to the Subhead.
114
+ # @param hide_border [Boolean] Whether to hide the border under the heading.
115
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
116
+ def initialize(spacious: false, hide_border: false, **system_arguments)
117
+ @system_arguments = deny_tag_argument(**system_arguments)
118
+
119
+ @system_arguments[:tag] = :div
120
+ @system_arguments[:classes] =
121
+ class_names(
122
+ @system_arguments[:classes],
123
+ "Subhead",
124
+ "Subhead--spacious": spacious,
125
+ "border-bottom-0": hide_border
126
+ )
127
+ @system_arguments[:mb] ||= hide_border ? 0 : nil
128
+ end
129
+
130
+ def render?
131
+ heading.present?
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1 @@
1
+ {"name":"beta/timeline_item","selectors":[".TimelineItem",".TimelineItem:before",".TimelineItem:target .TimelineItem-badge",".TimelineItem-badge",".TimelineItem-badge--success",".TimelineItem-body",".TimelineItem-avatar",".TimelineItem-break",".TimelineItem--condensed",".TimelineItem--condensed:last-child",".TimelineItem--condensed .TimelineItem-badge"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["timeline_item.pcss"],"names":[],"mappings":"AAEA,cAEE,YAAa,CAEb,+CAAiD,CADjD,iDAAmD,CAFnD,iBAqBF,CAfE,qBAQE,0CAA2C,CAL3C,QAAS,CAIT,UAAW,CAFX,aAAc,CADd,MAAO,CAHP,iBAAkB,CAClB,KAAM,CAIN,yCAGF,CAEA,yCACE,yCAA0C,CAC1C,6CACF,CAGF,oBASE,kBAAmB,CACnB,+CAAgD,CAChD,4EAA8E,CAC9E,iBAAkB,CAJlB,2BAA4B,CAL5B,YAAa,CAWb,aAAc,CATd,6CAA+C,CAQ/C,sBAAuB,CANvB,kEAAqE,CADrE,gEAAkE,CALlE,iBAAkB,CAGlB,4CAA8C,CAF9C,SAaF,CAEA,6BAEE,8CAA+C,CAC/C,qDAA6D,CAF7D,iCAGF,CAEA,mBAIE,2BAA4B,CAC5B,SAAU,CAFV,iCAAmC,CADnC,cAAe,CADf,WAKF,CAEA,qBAEE,UAAW,CADX,iBAAkB,CAElB,SACF,CAEA,oBAOE,4CAA6C,CAC7C,QAAS,CACT,kFAAoF,CANpF,4CAA8C,CAC9C,QAAS,CACT,2DAA8D,CAC9D,iBAAkB,CALlB,iBAAkB,CAClB,SAQF,CAEA,yBAEE,gBAAiB,CADjB,kCAgBF,CAZE,oCACE,kDACF,CAEA,6CAKE,4CAA6C,CAC7C,QAAS,CAFT,2BAA4B,CAH5B,+BAAiC,CAEjC,oCAAsC,CADtC,iCAKF","file":"timeline_item.css","sourcesContent":["/* TimelineItem */\n\n.TimelineItem {\n position: relative;\n display: flex;\n padding: var(--primer-stack-padding-normal, 16px) 0;\n margin-left: var(--primer-stack-gap-normal, 16px);\n\n /* The Timeline */\n &::before {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n display: block;\n width: var(--primer-borderWidth-thick, 2px);\n content: '';\n background-color: var(--color-border-muted);\n }\n\n &:target .TimelineItem-badge {\n border-color: var(--color-accent-emphasis);\n box-shadow: 0 0 0.2em var(--color-accent-muted);\n }\n}\n\n.TimelineItem-badge {\n position: relative;\n z-index: 1;\n display: flex;\n width: var(--primer-control-medium-size, 32px);\n height: var(--primer-control-medium-size, 32px);\n margin-right: var(--primer-controlStack-medium-gap-condensed, 8px);\n margin-left: calc(var(--primer-control-medium-size, 32px) / -2 + 1px);\n color: var(--color-fg-muted);\n align-items: center;\n background-color: var(--color-timeline-badge-bg);\n border: var(--primer-borderWidth-thick, 2px) solid var(--color-canvas-default);\n border-radius: 50%;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.TimelineItem-badge--success {\n color: var(--color-fg-on-emphasis);\n background-color: var(--color-success-emphasis);\n border: var(--primer-borderWidth-thin, 1px) solid transparent;\n}\n\n.TimelineItem-body {\n min-width: 0;\n max-width: 100%;\n margin-top: var(--base-size-4, 4px);\n color: var(--color-fg-muted);\n flex: auto;\n}\n\n.TimelineItem-avatar {\n position: absolute;\n left: -72px;\n z-index: 1;\n}\n\n.TimelineItem-break {\n position: relative;\n z-index: 1;\n height: var(--primer-stack-gap-spacious, 24px);\n margin: 0;\n margin-bottom: calc(var(--primer-stack-gap-normal, 16px) * -1);\n margin-left: -56px;\n background-color: var(--color-canvas-default);\n border: 0;\n border-top: var(--primer-borderWidth-thicker, 4px) solid var(--color-border-default);\n}\n\n.TimelineItem--condensed {\n padding-top: var(--base-size-4, 4px);\n padding-bottom: 0;\n\n /* TimelineItem--condensed is often grouped. (commits) */\n &:last-child {\n padding-bottom: var(--primer-stack-gap-normal, 16px);\n }\n\n & .TimelineItem-badge {\n height: var(--base-size-16, 16px);\n margin-top: var(--base-size-8, 8px);\n margin-bottom: var(--base-size-8, 8px);\n color: var(--color-fg-muted);\n background-color: var(--color-canvas-default);\n border: 0;\n }\n}\n"]}
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # Use `TimelineItem` to display items on a vertical timeline, connected by badge elements.
6
+ class TimelineItem < Primer::Component
7
+ status :beta
8
+
9
+ # Avatar to be rendered to the left of the Badge.
10
+ #
11
+ # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Avatar) %>.
12
+ renders_one :avatar, lambda { |src:, size: 40, shape: :square, **system_arguments|
13
+ system_arguments[:classes] = class_names(
14
+ "TimelineItem-avatar",
15
+ system_arguments[:classes]
16
+ )
17
+
18
+ Primer::Beta::Avatar.new(src: src, size: size, shape: shape, **system_arguments)
19
+ }
20
+
21
+ # Badge that will be connected to other TimelineItems.
22
+ #
23
+ # @param icon [String] Name of <%= link_to_octicons %> to use.
24
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
25
+ renders_one :badge, "Badge"
26
+
27
+ # Body to be rendered to the left of the Badge.
28
+ #
29
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
30
+ renders_one :body, lambda { |**system_arguments|
31
+ deny_tag_argument(**system_arguments)
32
+ system_arguments[:tag] = :div
33
+ system_arguments[:classes] = class_names(
34
+ "TimelineItem-body",
35
+ system_arguments[:classes]
36
+ )
37
+
38
+ Primer::BaseComponent.new(**system_arguments)
39
+ }
40
+
41
+ # @example Default
42
+ # <div style="padding-left: 60px">
43
+ # <%= render(Primer::Beta::TimelineItem.new) do |component| %>
44
+ # <% component.with_avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "github") %>
45
+ # <% component.with_badge(bg: :success_emphasis, color: :on_emphasis, icon: :check) %>
46
+ # <% component.with_body { "Success!" } %>
47
+ # <% end %>
48
+ # </div>
49
+ #
50
+ # @param condensed [Boolean] Reduce the vertical padding and remove the background from the badge item. Most commonly used in commits.
51
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
52
+ def initialize(condensed: false, **system_arguments)
53
+ @system_arguments = deny_tag_argument(**system_arguments)
54
+ @system_arguments[:tag] = :div
55
+ @system_arguments[:classes] = class_names(
56
+ "TimelineItem",
57
+ condensed ? "TimelineItem--condensed" : "",
58
+ system_arguments[:classes]
59
+ )
60
+ end
61
+
62
+ def render?
63
+ avatar? || badge? || body?
64
+ end
65
+
66
+ # This component is part of `Primer::Beta::TimelineItem` and should not be
67
+ # used as a standalone component.
68
+ class Badge < Primer::Component
69
+ status :beta
70
+
71
+ def initialize(icon: nil, **system_arguments)
72
+ @icon = icon
73
+
74
+ @system_arguments = deny_tag_argument(**system_arguments)
75
+ @system_arguments[:tag] = :div
76
+ @system_arguments[:classes] = class_names(
77
+ "TimelineItem-badge",
78
+ system_arguments[:classes]
79
+ )
80
+ end
81
+
82
+ def call
83
+ render(Primer::BaseComponent.new(**@system_arguments)) do
84
+ render(Primer::Beta::Octicon.new(@icon))
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -1 +1 @@
1
- .Truncate{display:inline-flex;max-width:100%;min-width:0}.Truncate>.Truncate-text{max-width:-moz-fit-content;max-width:fit-content;min-width:1ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:is(.Truncate>.Truncate-text)+.Truncate-text{margin-left:var(--primer-control-small-gap,4px)}.Truncate>.Truncate-text.Truncate-text--primary{flex-basis:200%}.Truncate>.Truncate-text.Truncate-text--expandable:active,.Truncate>.Truncate-text.Truncate-text--expandable:focus,.Truncate>.Truncate-text.Truncate-text--expandable:hover{cursor:pointer;flex-shrink:0;max-width:100%!important}
1
+ .Truncate{display:inline-flex;max-width:100%;min-width:0}.Truncate>.Truncate-text{max-width:-moz-fit-content;max-width:fit-content;min-width:1ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.Truncate>.Truncate-text+.Truncate-text{margin-left:var(--primer-control-small-gap,4px)}.Truncate>.Truncate-text.Truncate-text--primary{flex-basis:200%}.Truncate>.Truncate-text.Truncate-text--expandable:active,.Truncate>.Truncate-text.Truncate-text--expandable:focus,.Truncate>.Truncate-text.Truncate-text--expandable:hover{cursor:pointer;flex-shrink:0;max-width:100%!important}
@@ -1 +1 @@
1
- {"name":"beta/truncate","selectors":[".Truncate",".Truncate>.Truncate-text",":is(.Truncate>.Truncate-text)+.Truncate-text",".Truncate>.Truncate-text.Truncate-text--primary",".Truncate>.Truncate-text.Truncate-text--expandable:active",".Truncate>.Truncate-text.Truncate-text--expandable:focus",".Truncate>.Truncate-text.Truncate-text--expandable:hover"]}
1
+ {"name":"beta/truncate","selectors":[".Truncate",".Truncate>.Truncate-text",".Truncate>.Truncate-text+.Truncate-text",".Truncate>.Truncate-text.Truncate-text--primary",".Truncate>.Truncate-text.Truncate-text--expandable:active",".Truncate>.Truncate-text.Truncate-text--expandable:focus",".Truncate>.Truncate-text.Truncate-text--expandable:hover"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["truncate.pcss"],"names":[],"mappings":"AAEA,UACE,mBAAoB,CAEpB,cAAe,CADf,WA0BF,CAvBE,yBAEE,0BAAsB,CAAtB,qBAAsB,CADtB,aAAc,CAEd,eAAgB,CAChB,sBAAuB,CACvB,kBAiBF,CAfE,6CACE,+CACF,CAEA,gDACE,eACF,CAEA,4KAKE,cAAe,CADf,aAAc,CADd,wBAGF","file":"truncate.css","sourcesContent":["/* Truncate */\n\n.Truncate {\n display: inline-flex;\n min-width: 0;\n max-width: 100%;\n\n & > .Truncate-text {\n min-width: 1ch;\n max-width: fit-content;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n & + .Truncate-text {\n margin-left: var(--primer-control-small-gap, 4px);\n }\n\n &.Truncate-text--primary {\n flex-basis: 200%;\n }\n\n &.Truncate-text--expandable:hover,\n &.Truncate-text--expandable:focus,\n &.Truncate-text--expandable:active {\n max-width: 100% !important;\n flex-shrink: 0;\n cursor: pointer;\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["truncate.pcss"],"names":[],"mappings":"AAEA,UACE,mBAAoB,CAEpB,cAAe,CADf,WA0BF,CAvBE,yBAEE,0BAAsB,CAAtB,qBAAsB,CADtB,aAAc,CAEd,eAAgB,CAChB,sBAAuB,CACvB,kBAiBF,CAfE,wCACE,+CACF,CAEA,gDACE,eACF,CAEA,4KAKE,cAAe,CADf,aAAc,CADd,wBAGF","file":"truncate.css","sourcesContent":["/* Truncate */\n\n.Truncate {\n display: inline-flex;\n min-width: 0;\n max-width: 100%;\n\n & > .Truncate-text {\n min-width: 1ch;\n max-width: fit-content;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n & + .Truncate-text {\n margin-left: var(--primer-control-small-gap, 4px);\n }\n\n &.Truncate-text--primary {\n flex-basis: 200%;\n }\n\n &.Truncate-text--expandable:hover,\n &.Truncate-text--expandable:focus,\n &.Truncate-text--expandable:active {\n max-width: 100% !important;\n flex-shrink: 0;\n cursor: pointer;\n }\n }\n}\n"]}
@@ -4,7 +4,6 @@ module Primer
4
4
  module Beta
5
5
  # Use `Truncate` to shorten overflowing text with an ellipsis.
6
6
  class Truncate < Primer::Component
7
- warn_on_deprecated_slot_setter
8
7
  status :beta
9
8
 
10
9
  # Text slot used for the truncated text.
@@ -88,21 +88,21 @@ module Primer
88
88
  # <%= render(Primer::ButtonComponent.new(block: :true, scheme: :primary)) { "Primary block" } %>
89
89
  #
90
90
  # @example With leading visual
91
- # <%= render(Primer::ButtonComponent.new) do |c| %>
92
- # <% c.with_leading_visual_icon(icon: :star) %>
91
+ # <%= render(Primer::ButtonComponent.new) do |component| %>
92
+ # <% component.with_leading_visual_icon(icon: :star) %>
93
93
  # Button
94
94
  # <% end %>
95
95
  #
96
96
  # @example With trailing visual
97
- # <%= render(Primer::ButtonComponent.new) do |c| %>
98
- # <% c.with_trailing_visual_counter(count: 15) %>
97
+ # <%= render(Primer::ButtonComponent.new) do |component| %>
98
+ # <% component.with_trailing_visual_counter(count: 15) %>
99
99
  # Button
100
100
  # <% end %>
101
101
  #
102
102
  # @example With leading and trailing visuals
103
- # <%= render(Primer::ButtonComponent.new) do |c| %>
104
- # <% c.with_leading_visual_icon(icon: :star) %>
105
- # <% c.with_trailing_visual_counter(count: 15) %>
103
+ # <%= render(Primer::ButtonComponent.new) do |component| %>
104
+ # <% component.with_leading_visual_icon(icon: :star) %>
105
+ # <% component.with_trailing_visual_counter(count: 15) %>
106
106
  # Button
107
107
  # <% end %>
108
108
  #
@@ -115,8 +115,8 @@ module Primer
115
115
  # @description
116
116
  # Use tooltips sparingly and as a last resort. Consult the <%= link_to_component(Primer::Alpha::Tooltip) %> documentation for more information.
117
117
  # @code
118
- # <%= render(Primer::ButtonComponent.new(id: "button-with-tooltip")) do |c| %>
119
- # <% c.with_tooltip(text: "Tooltip text") %>
118
+ # <%= render(Primer::ButtonComponent.new(id: "button-with-tooltip")) do |component| %>
119
+ # <% component.with_tooltip(text: "Tooltip text") %>
120
120
  # Button
121
121
  # <% end %>
122
122
  #
@@ -6,7 +6,6 @@ module Primer
6
6
  # @private
7
7
  # :nocov:
8
8
  class Component < ViewComponent::Base
9
- warn_on_deprecated_slot_setter
10
9
  include ViewComponent::SlotableV2 unless ViewComponent::Base < ViewComponent::SlotableV2
11
10
  include ViewComponent::PolymorphicSlots unless ViewComponent::Base < ViewComponent::PolymorphicSlots
12
11
  include ClassNameHelper
@@ -1,39 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use `HellipButton` to render a button with a hellip. Often used for hidden text expanders.
5
- # @accessibility
6
- # Always set an accessible label to help the user interact with the component.
7
- #
8
- # * This button is displaying a hellip as its content (The three dots character). Therefore a label is needed for screen readers.
9
- # * Set the attribute `aria-label` on the system arguments. E.g. `Primer::HellipButton.new("aria-label": "Expand next part")`
10
- class HellipButton < Primer::Component
11
- # @example Default
12
- # <%= render(Primer::HellipButton.new("aria-label": "No effect")) %>
13
- #
14
- # @example Inline
15
- # <%= render(Primer::HellipButton.new(inline: true, "aria-label": "No effect")) %>
16
- #
17
- # @example Styling the button
18
- # <%= render(Primer::HellipButton.new(p: 1, classes: "custom-class", "aria-label": "No effect")) %>
19
- #
20
- # @param inline [Boolean] Whether or not the button is inline.
21
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
22
- def initialize(inline: false, **system_arguments)
23
- @system_arguments = deny_tag_argument(**system_arguments)
24
-
25
- validate_aria_label
26
-
27
- @system_arguments[:tag] = :button
28
- @system_arguments[:"aria-expanded"] = false
29
- @system_arguments[:classes] = class_names(
30
- @system_arguments[:classes],
31
- "inline" => inline
32
- )
33
- end
34
-
35
- def call
36
- render(Primer::Beta::BaseButton.new(**@system_arguments)) { "&hellip;".html_safe }
37
- end
4
+ class HellipButton < Primer::Alpha::HellipButton
5
+ status :deprecated
38
6
  end
39
7
  end
@@ -63,31 +63,31 @@ module Primer
63
63
  attr_reader :selected
64
64
 
65
65
  # @example Default
66
- # <%= render(Primer::Navigation::TabComponent.new(selected: true)) do |c| %>
67
- # <% c.with_text { "Selected" } %>
66
+ # <%= render(Primer::Navigation::TabComponent.new(selected: true)) do |component| %>
67
+ # <% component.with_text { "Selected" } %>
68
68
  # <% end %>
69
- # <%= render(Primer::Navigation::TabComponent.new) do |c| %>
70
- # <% c.with_text { "Not selected" } %>
69
+ # <%= render(Primer::Navigation::TabComponent.new) do |component| %>
70
+ # <% component.with_text { "Not selected" } %>
71
71
  # <% end %>
72
72
  #
73
73
  # @example With icons and counters
74
- # <%= render(Primer::Navigation::TabComponent.new) do |c| %>
75
- # <% c.with_icon(:star) %>
76
- # <% c.with_text { "Tab" } %>
74
+ # <%= render(Primer::Navigation::TabComponent.new) do |component| %>
75
+ # <% component.with_icon(:star) %>
76
+ # <% component.with_text { "Tab" } %>
77
77
  # <% end %>
78
- # <%= render(Primer::Navigation::TabComponent.new) do |c| %>
79
- # <% c.with_icon(:star) %>
80
- # <% c.with_text { "Tab" } %>
81
- # <% c.with_counter(count: 10) %>
78
+ # <%= render(Primer::Navigation::TabComponent.new) do |component| %>
79
+ # <% component.with_icon(:star) %>
80
+ # <% component.with_text { "Tab" } %>
81
+ # <% component.with_counter(count: 10) %>
82
82
  # <% end %>
83
- # <%= render(Primer::Navigation::TabComponent.new) do |c| %>
84
- # <% c.with_text { "Tab" } %>
85
- # <% c.with_counter(count: 10) %>
83
+ # <%= render(Primer::Navigation::TabComponent.new) do |component| %>
84
+ # <% component.with_text { "Tab" } %>
85
+ # <% component.with_counter(count: 10) %>
86
86
  # <% end %>
87
87
  #
88
88
  # @example Inside a list
89
- # <%= render(Primer::Navigation::TabComponent.new(list: true)) do |c| %>
90
- # <% c.with_text { "Tab" } %>
89
+ # <%= render(Primer::Navigation::TabComponent.new(list: true)) do |component| %>
90
+ # <% component.with_text { "Tab" } %>
91
91
  # <% end %>
92
92
  #
93
93
  # @example With custom HTML
@@ -9,7 +9,7 @@ import './alpha/x_banner';
9
9
  import './beta/auto_complete/auto_complete';
10
10
  import './beta/clipboard_copy';
11
11
  import './local_time';
12
- import './tab_container_component';
12
+ import './alpha/tab_container';
13
13
  import './time_ago_component';
14
14
  import '../../../lib/primer/forms/primer_multi_input';
15
15
  import '../../../lib/primer/forms/primer_text_field';
@@ -9,7 +9,7 @@ import './alpha/x_banner';
9
9
  import './beta/auto_complete/auto_complete';
10
10
  import './beta/clipboard_copy';
11
11
  import './local_time';
12
- import './tab_container_component';
12
+ import './alpha/tab_container';
13
13
  import './time_ago_component';
14
14
  import '../../../lib/primer/forms/primer_multi_input';
15
15
  import '../../../lib/primer/forms/primer_text_field';
@@ -28,10 +28,10 @@
28
28
  @import "./beta/link.pcss";
29
29
  @import "./beta/popover.pcss";
30
30
  @import "./beta/progress_bar.pcss";
31
+ @import "./beta/state.pcss";
32
+ @import "./beta/subhead.pcss";
31
33
  @import "./beta/truncate.pcss";
32
34
 
33
35
  /* to be renamed */
34
- @import "./state_component.pcss";
35
- @import "./subhead_component.pcss";
36
- @import "./timeline_item_component.pcss";
36
+ @import "./beta/timeline_item.pcss";
37
37
  @import "./truncate.pcss";
@@ -9,7 +9,7 @@ import './alpha/x_banner'
9
9
  import './beta/auto_complete/auto_complete'
10
10
  import './beta/clipboard_copy'
11
11
  import './local_time'
12
- import './tab_container_component'
12
+ import './alpha/tab_container'
13
13
  import './time_ago_component'
14
14
  import '../../../lib/primer/forms/primer_multi_input'
15
15
  import '../../../lib/primer/forms/primer_text_field'
@@ -1,74 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use `State` for rendering the status of an item.
5
- class StateComponent < Primer::Component
6
- status :beta
7
-
8
- SCHEME_DEFAULT = :default
9
- NEW_SCHEME_MAPPINGS = {
10
- open: "State--open",
11
- closed: "State--closed",
12
- merged: "State--merged"
13
- }.freeze
14
-
15
- DEPRECATED_SCHEME_MAPPINGS = {
16
- SCHEME_DEFAULT => "",
17
- :green => "State--open",
18
- :red => "State--closed",
19
- :purple => "State--merged"
20
- }.freeze
21
- SCHEME_MAPPINGS = NEW_SCHEME_MAPPINGS.merge(DEPRECATED_SCHEME_MAPPINGS)
22
- SCHEME_OPTIONS = SCHEME_MAPPINGS.keys
23
-
24
- SIZE_DEFAULT = :default
25
- SIZE_MAPPINGS = {
26
- SIZE_DEFAULT => "",
27
- :small => "State--small"
28
- }.freeze
29
- SIZE_OPTIONS = SIZE_MAPPINGS.keys
30
-
31
- TAG_DEFAULT = :span
32
- TAG_OPTIONS = [TAG_DEFAULT, :div].freeze
33
-
34
- # @example Default
35
- # <%= render(Primer::StateComponent.new(title: "title")) { "State" } %>
36
- #
37
- # @example Schemes
38
- # <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
39
- # <%= render(Primer::StateComponent.new(title: "title", scheme: :open)) { "Open" } %>
40
- # <%= render(Primer::StateComponent.new(title: "title", scheme: :closed)) { "Closed" } %>
41
- # <%= render(Primer::StateComponent.new(title: "title", scheme: :merged)) { "Merged" } %>
42
- #
43
- # @example Sizes
44
- # <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
45
- # <%= render(Primer::StateComponent.new(title: "title", size: :small)) { "Small" } %>
46
- #
47
- # @param title [String] `title` HTML attribute.
48
- # @param scheme [Symbol] Background color. <%= one_of(Primer::StateComponent::SCHEME_OPTIONS) %>
49
- # @param tag [Symbol] HTML tag for element. <%= one_of(Primer::StateComponent::TAG_OPTIONS) %>
50
- # @param size [Symbol] <%= one_of(Primer::StateComponent::SIZE_OPTIONS) %>
51
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
52
- def initialize(
53
- title:,
54
- scheme: SCHEME_DEFAULT,
55
- tag: TAG_DEFAULT,
56
- size: SIZE_DEFAULT,
57
- **system_arguments
58
- )
59
- @system_arguments = system_arguments
60
- @system_arguments[:title] = title
61
- @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_DEFAULT)
62
- @system_arguments[:classes] = class_names(
63
- @system_arguments[:classes],
64
- "State",
65
- SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, SCHEME_DEFAULT)],
66
- SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
67
- )
68
- end
69
-
70
- def call
71
- render(Primer::BaseComponent.new(**@system_arguments)) { content }
72
- end
4
+ class StateComponent < Primer::Beta::State
5
+ status :deprecated
73
6
  end
74
7
  end