primer_view_components 0.0.76 → 0.0.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2635afac7c52d9fff327adc5ae000e6feccd1c5d315d3cce099f09c6863f8c08
4
- data.tar.gz: aa0b235e2ac2d48bc37793adb799b0662357b516768774cd82db8ff7ca76bc8f
3
+ metadata.gz: efdaf09d509cff222b24533bd12292eaf2c7c40601a999e210a84e846384eb2b
4
+ data.tar.gz: '0894a654919ab70c1e6bd0e745bd11ce0da8353f8f31b53fc0b28d27fdb53d4f'
5
5
  SHA512:
6
- metadata.gz: 7a9d2f32a73ac1790ae1903532581fa1349728efdd261061fa9a50fb9e5973618a69e9a149f0894861cb069780a0fed78aeab981e15d3811a32c54583e497962
7
- data.tar.gz: 0d7ffafa34ea38a5b97fc3d05ec55ea4b6fc43067b986dce17c5774a9c89b120cb2bf9a1033522c855b9d7dd49e1db8be1496fdbe22ac082c2887b5fcedbb6af
6
+ metadata.gz: 6223be5579e8e71fc861bc77928a5f542a6ee4bb7b5afcffcec446b12c44eb6f6f58ff244186396e92b2528dc9415c62ef66d075cdd1a92ce7250a52eb7b5ff2
7
+ data.tar.gz: 16b1230824ddd70123231a593397e6939165d101e00d0038923c460d944086b6c132e0714dcc65a527b83cd07f78182fc8888a06ee3831e429002d2fb7b9a9b7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.0.79
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1188](https://github.com/primer/view_components/pull/1188) [`fb7218ac`](https://github.com/primer/view_components/commit/fb7218ac5c4de2253cb627c99bc9469635cde98b) Thanks [@joelhawksley](https://github.com/joelhawksley)! - Revert leftover deprecated arguments from 1163.
8
+
9
+ ## 0.0.78
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1186](https://github.com/primer/view_components/pull/1186) [`ff2c3fe1`](https://github.com/primer/view_components/commit/ff2c3fe1913d7a1d65dbd4f608b68155ed247bef) Thanks [@joelhawksley](https://github.com/joelhawksley)! - Revert #1163, as additional work will be needed to ship those changes to production successfully.
14
+
15
+ ## 0.0.77
16
+
17
+ ### Patch Changes
18
+
19
+ - [#1185](https://github.com/primer/view_components/pull/1185) [`66a15b1a`](https://github.com/primer/view_components/commit/66a15b1a556e9814109317729b729dbee5316594) Thanks [@joelhawksley](https://github.com/joelhawksley)! - Rename FlashComponent to Flash
20
+
21
+ * [#1183](https://github.com/primer/view_components/pull/1183) [`84b9e4ef`](https://github.com/primer/view_components/commit/84b9e4ef60c9f0d1c2df830f247f2a55aac82783) Thanks [@camertron](https://github.com/camertron)! - Remove trailing newlines from the output of LinkComponent
22
+
3
23
  ## 0.0.76
4
24
 
5
25
  ### Patch Changes
@@ -1,26 +1,24 @@
1
1
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
- <div class="<%= @form_group_classes %>">
3
- <label for="<%= @input_id %>" class="FormControl-label <% if @visually_hide_label %>sr-only<% end %>">
2
+ <label for="<%= @input_id %>" class="<%= @label_classes %>">
3
+ <% if @is_label_visible %>
4
4
  <%= @label_text %>
5
- </label>
6
- <% if leading_visual || @show_clear_button %>
7
- <div class="<%= @field_wrap_classes %> <% if leading_visual %>FormControl-fieldWrap--input-leadingVisual<% end %>">
8
- <%= leading_visual %>
9
- <%= input %>
10
- <% if @show_clear_button %>
11
- <button id="<%= @input_id %>-clear" class="FormControl--input-trailingAction" aria-label="Clear"><%= primer_octicon "x-circle-fill" %></button>
12
- <% end %>
13
- </div>
14
5
  <% else %>
15
- <%= input %>
6
+ <span class="sr-only"><%= @label_text %></span>
16
7
  <% end %>
17
- </div>
18
- <div class="Overlay-backdrop--anchor">
19
- <div class="Overlay Overlay--height-auto Overlay--width-auto">
20
- <div class="Overlay-body Overlay-body--paddingNone">
21
- <%= results %>
8
+ </label>
9
+ <span class="autocomplete-body">
10
+ <% if @with_icon %>
11
+ <div class="form-control autocomplete-embedded-icon-wrap">
12
+ <%= render Primer::OcticonComponent.new(:search) %>
13
+ <% end %>
14
+ <%= input %>
15
+ <% if @is_clearable %>
16
+ <button id="<%= @input_id %>-clear" class="btn-octicon" aria-label="Clear"><%= primer_octicon "x" %></button>
17
+ <% end %>
18
+ <% if @with_icon %>
22
19
  </div>
23
- </div>
24
- </div>
20
+ <% end %>
21
+ <%= results %>
22
+ </span>
25
23
  <div id="<%= @list_id %>-feedback" class="sr-only"></div>
26
24
  <% end %>
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO: use generic ActionList item for Autocomplete
4
3
  module Primer
5
4
  module Beta
6
5
  class AutoComplete
@@ -30,17 +29,14 @@ module Primer
30
29
  @system_arguments[:"aria-disabled"] = true if disabled
31
30
 
32
31
  @system_arguments[:classes] = class_names(
33
- "ActionList-item",
34
- system_arguments[:classes]
32
+ "autocomplete-item",
33
+ system_arguments[:classes],
34
+ "disabled" => disabled
35
35
  )
36
36
  end
37
37
 
38
38
  def call
39
- render(Primer::BaseComponent.new(**@system_arguments)) do
40
- render(Primer::BaseComponent.new(tag: :span, classes: "ActionList-content")) do
41
- render(Primer::BaseComponent.new(tag: :span, classes: "ActionList-item-label")) { content }
42
- end
43
- end
39
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
44
40
  end
45
41
  end
46
42
  end
@@ -8,20 +8,11 @@ module Primer
8
8
  # Always set an accessible label to help the user interact with the component.
9
9
  #
10
10
  # * `label_text` is required and visible by default.
11
- # * If you must hide the label, set `visually_hide_label` to `true`.
11
+ # * If you must use a non-visible label, set `is_label_visible` to `false`.
12
12
  # However, please note that a visible label should almost always
13
13
  # be used unless there is compelling reason not to. A placeholder is not a label.
14
14
  class AutoComplete < Primer::Component
15
15
  status :beta
16
-
17
- DEFAULT_SIZE = :medium
18
- SIZE_MAPPINGS = {
19
- :small => "FormControl--small",
20
- DEFAULT_SIZE => "FormControl--medium",
21
- :large => "FormControl--large"
22
- }.freeze
23
- SIZE_OPTIONS = SIZE_MAPPINGS.keys
24
-
25
16
  #
26
17
  # Customizable results list.
27
18
  #
@@ -31,26 +22,13 @@ module Primer
31
22
  system_arguments[:tag] = :ul
32
23
  system_arguments[:id] = @list_id
33
24
  system_arguments[:classes] = class_names(
34
- "ActionList",
25
+ "autocomplete-results",
35
26
  system_arguments[:classes]
36
27
  )
37
28
 
38
29
  Primer::BaseComponent.new(**system_arguments)
39
30
  }
40
31
 
41
- #
42
- # Leading visual.
43
- #
44
- # - `leading_visual_icon` for a <%= link_to_component(Primer::OcticonComponent) %>.
45
- #
46
- # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
47
- renders_one :leading_visual, types: {
48
- icon: lambda { |**system_arguments|
49
- system_arguments[:classes] = class_names("FormControl--input-leadingVisual")
50
- Primer::OcticonComponent.new(**system_arguments)
51
- }
52
- }
53
-
54
32
  # Customizable input used to search for results.
55
33
  # It is preferred to use this slot sparingly - it will be created by default if not explicity added.
56
34
  #
@@ -60,7 +38,7 @@ module Primer
60
38
  sanitized_args = deny_single_argument(:autofocus, "autofocus is not allowed for accessibility reasons. See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus#accessibility_considerations for more information.", **sanitized_args)
61
39
  deny_aria_key(
62
40
  :label,
63
- "instead of `aria-label`, include `label_text` and set `visually_hide_label` to `true` on the component initializer.",
41
+ "instead of `aria-label`, include `label_text` and set `is_label_visible` to `false` on the component initializer.",
64
42
  **sanitized_args
65
43
  )
66
44
  deny_single_argument(
@@ -77,82 +55,45 @@ module Primer
77
55
  sanitized_args[:name] = @input_name
78
56
  sanitized_args[:tag] = :input
79
57
  sanitized_args[:autocomplete] = "off"
80
- sanitized_args[:disabled] = true if @disabled
81
- sanitized_args[:invalid] = true if @invalid
58
+
82
59
  sanitized_args[:type] = :text
83
60
  sanitized_args[:classes] = class_names(
84
- "FormControl",
85
- "FormControl--input",
86
- SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, @size, DEFAULT_SIZE)],
61
+ "form-control",
87
62
  sanitized_args[:classes]
88
63
  )
89
- sanitized_args[:placeholder] = @placeholder
90
64
 
91
65
  Primer::BaseComponent.new(**sanitized_args)
92
66
  }
93
67
 
94
- # @example Leading visual
68
+ # @example Default
95
69
  # @description
96
- # Display any Octicon as a leading visual within the field
70
+ # Labels are stacked by default.
97
71
  # @code
98
- # <%= render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", src: "/auto_complete", input_id:"input-id-1", list_id: "list-id-1")) do |c| %>
99
- # <% c.leading_visual_icon(icon: :search) %>
100
- # <% c.results do %>
101
- # <%= render(Primer::Beta::AutoComplete::Item.new(selected: true, value: "apple")) do |_c| %>
102
- # Apple
103
- # <% end %>
104
- # <%= render(Primer::Beta::AutoComplete::Item.new(value: "orange")) do |_c| %>
105
- # Orange
106
- # <% end %>
107
- # <% end %>
108
- # <% end %>
72
+ # <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--default", list_id: "fruits-popup--default")) %>
109
73
  #
110
- # @example Trailing action
74
+ # @example With inline label
111
75
  # @description
112
- # Show a clear button
76
+ # Labels can be inline by setting `is_label_inline: true`. However, labels will always become stacked on smaller screen sizes.
113
77
  # @code
114
- # <%= render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id-2", list_id: "list-id-2", src: "/auto_complete", show_clear_button: true )) do |c| %>
115
- # <% c.results do %>
116
- # <%= render(Primer::Beta::AutoComplete::Item.new(selected: true, value: "apple")) do |_c| %>
117
- # Apple
118
- # <% end %>
119
- # <%= render(Primer::Beta::AutoComplete::Item.new(value: "orange")) do |_c| %>
120
- # Orange
121
- # <% end %>
122
- # <% end %>
123
- # <% end %>
78
+ # <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", is_label_inline: true, input_id: "fruits-input--inline-label", list_id: "fruits-popup--inline-label")) %>
124
79
  #
125
- # @example Visually hidden label
80
+ # @example With non-visible label
126
81
  # @description
127
- # A non-visible label may be rendered with `visually_hide_label: true`, but it is highly discouraged. See <%= link_to_accessibility %>.
82
+ # A non-visible label may be rendered with `is_label_visible: false`, but it is highly discouraged. See <%= link_to_accessibility %>.
128
83
  # @code
129
- # <%= render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", input_id: "fruits-input--custom-results-1", list_id: "fruits-popup--custom-result-1", src: "/auto_complete", visually_hide_label: true)) do |c| %>
130
- # <% c.leading_visual_icon(icon: :search) %>
131
- # <% c.results do %>
132
- # <%= render(Primer::Beta::AutoComplete::Item.new(selected: true, value: "apple")) do |_c| %>
133
- # Apple
134
- # <% end %>
135
- # <%= render(Primer::Beta::AutoComplete::Item.new(value: "orange")) do |_c| %>
136
- # Orange
137
- # <% end %>
138
- # <% end %>
139
- # <% end %>
84
+ # <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--non-visible-label", list_id: "fruits-popup--non-visible-label", is_label_visible: false)) %>
140
85
  #
141
- # @example Full width field
86
+ # @example With icon
142
87
  # @description
143
- # To allow field to span width of its container, set `full_width` to `true`.
88
+ # To display a search icon, set `with_icon` to `true`.
144
89
  # @code
145
- # <%= render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", input_id: "fruits-input--custom-results-2", list_id: "fruits-popup--custom-results-2", src: "/auto_complete", full_width: true)) do |c| %>
146
- # <% c.leading_visual_icon(icon: :search) %>
147
- # <% c.results do %>
148
- # <%= render(Primer::Beta::AutoComplete::Item.new(selected: true, value: "apple")) do |_c| %>
149
- # Apple
150
- # <% end %>
151
- # <%= render(Primer::Beta::AutoComplete::Item.new(value: "orange")) do |_c| %>
152
- # Orange
153
- # <% end %>
154
- # <% end %>
155
- # <% end %>
90
+ # <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", list_id: "fruits-popup--icon", input_id: "fruits-input--icon", with_icon: true)) %>
91
+ #
92
+ # @example With icon and non-visible label
93
+ # <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", list_id: "fruits-popup--icon-no-label", input_id: "fruits-input--icon-no-label", with_icon: true, is_label_visible: false)) %>
94
+ #
95
+ # @example With clear button
96
+ # <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--clear", list_id: "fruits-popup--clear", is_clearable: true)) %>
156
97
  #
157
98
  # @example With custom classes for the input
158
99
  # <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--custom-input", list_id: "fruits-popup--custom-input")) do |c| %>
@@ -176,42 +117,25 @@ module Primer
176
117
  # @param input_id [String] Id of the input element.
177
118
  # @param input_name [String] Optional name of the input element, defaults to `input_id` when not set.
178
119
  # @param list_id [String] Id of the list element.
179
- # @param visually_hide_label [Boolean] Controls if the label is visible. If `true`, screen reader only text will be added.
180
- # @param show_clear_button [Boolean] Adds optional clear button.
120
+ # @param with_icon [Boolean] Controls if a search icon is visible, defaults to `false`.
121
+ # @param is_label_visible [Boolean] Controls if the label is visible. If `false`, screen reader only text will be added.
122
+ # @param is_clearable [Boolean] Adds optional clear button.
123
+ # @param is_label_inline [Boolean] Controls if the label is inline. On smaller screens, label will always become stacked.
181
124
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
182
- # @param size [Hash] Input size can be small, medium (default), or large
183
- # @param full_width [Boolean] Input can be full-width or fit to content
184
- # @param disabled [Boolean] Disabled input
185
- # @param invalid [Boolean] Invalid input
186
- # @param placeholder [String] The placeholder text displayed within the input
187
- def initialize(label_text:, src:, list_id:, input_id:, input_name: nil, placeholder: nil, show_clear_button: false, visually_hide_label: false, size: DEFAULT_SIZE, full_width: false, disabled: false, invalid: false, **system_arguments)
125
+ def initialize(label_text:, src:, list_id:, input_id:, input_name: nil, is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false, **system_arguments)
188
126
  @label_text = label_text
189
127
  @list_id = list_id
190
128
  @input_id = input_id
191
129
  @input_name = input_name || input_id
192
- @placeholder = placeholder
193
- @visually_hide_label = visually_hide_label
194
- @show_clear_button = show_clear_button
130
+ @is_label_visible = is_label_visible
131
+ @with_icon = with_icon
132
+ @is_clearable = is_clearable
133
+
134
+ @label_classes = label_classes(is_label_visible: is_label_visible, is_label_inline: is_label_inline)
195
135
  @system_arguments = deny_tag_argument(**system_arguments)
196
136
  @system_arguments[:tag] = "auto-complete"
197
137
  @system_arguments[:src] = src
198
138
  @system_arguments[:for] = list_id
199
- @disabled = disabled
200
- @invalid = invalid
201
- @size = size
202
- @full_width = full_width
203
- @field_wrap_classes = class_names(
204
- "FormControl-fieldWrap",
205
- "FormControl-fieldWrap--input",
206
- SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, @size, DEFAULT_SIZE)],
207
- "FormControl-fieldWrap--disabled": disabled,
208
- "FormControl-fieldWrap--invalid": invalid,
209
- "FormControl-fieldWrap--input-trailingAction": show_clear_button
210
- )
211
- @form_group_classes = class_names(
212
- "FormGroup",
213
- "FormGroup--fullWidth": full_width
214
- )
215
139
  end
216
140
 
217
141
  # add `input` and `results` without needing to explicitly call them in the view
@@ -219,6 +143,20 @@ module Primer
219
143
  results(classes: "") unless results
220
144
  input(classes: "") unless input
221
145
  end
146
+
147
+ private
148
+
149
+ # Private: determines the label classes based on component configration.
150
+ #
151
+ # If the label is not visible, return an empty string.
152
+ #
153
+ # @param args [Hash] The component configuration.
154
+ # @return [String] The label classes.
155
+ def label_classes(**args)
156
+ return "" if args[:is_label_visible] == false
157
+
158
+ args[:is_label_inline] ? "autocomplete-label-inline" : "autocomplete-label-stacked"
159
+ end
222
160
  end
223
161
  end
224
162
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # Use `Flash` to inform users of successful or pending actions.
6
+ class Flash < Primer::Component
7
+ status :beta
8
+
9
+ # Optional action content showed on the right side of the component.
10
+ #
11
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
12
+ renders_one :action, lambda { |**system_arguments|
13
+ deny_tag_argument(**system_arguments)
14
+ system_arguments[:tag] = :div
15
+ system_arguments[:classes] = class_names(system_arguments[:classes], "flash-action")
16
+
17
+ Primer::BaseComponent.new(**system_arguments)
18
+ }
19
+
20
+ DEFAULT_SCHEME = :default
21
+ SCHEME_MAPPINGS = {
22
+ DEFAULT_SCHEME => "",
23
+ :warning => "flash-warn",
24
+ :danger => "flash-error",
25
+ :success => "flash-success"
26
+ }.freeze
27
+ # @example Schemes
28
+ # <%= render(Primer::Beta::Flash.new) { "This is a flash message!" } %>
29
+ # <%= render(Primer::Beta::Flash.new(scheme: :warning)) { "This is a warning flash message!" } %>
30
+ # <%= render(Primer::Beta::Flash.new(scheme: :danger)) { "This is a danger flash message!" } %>
31
+ # <%= render(Primer::Beta::Flash.new(scheme: :success)) { "This is a success flash message!" } %>
32
+ #
33
+ # @example Full width
34
+ # <%= render(Primer::Beta::Flash.new(full: true)) { "This is a full width flash message!" } %>
35
+ #
36
+ # @example Dismissible
37
+ # <%= render(Primer::Beta::Flash.new(dismissible: true)) { "This is a dismissible flash message!" } %>
38
+ #
39
+ # @example Icon
40
+ # <%= render(Primer::Beta::Flash.new(icon: :people)) { "This is a flash message with an icon!" } %>
41
+ #
42
+ # @example With actions
43
+ # <%= render(Primer::Beta::Flash.new) do |component| %>
44
+ # This is a flash message with actions!
45
+ # <% component.action do %>
46
+ # <%= render(Primer::ButtonComponent.new(size: :small)) { "Take action" } %>
47
+ # <% end %>
48
+ # <% end %>
49
+ #
50
+ # @param full [Boolean] Whether the component should take up the full width of the screen.
51
+ # @param spacious [Boolean] Whether to add margin to the bottom of the component.
52
+ # @param dismissible [Boolean] Whether the component can be dismissed with an X button.
53
+ # @param icon [Symbol] Name of Octicon icon to use.
54
+ # @param scheme [Symbol] <%= one_of(Primer::Beta::Flash::SCHEME_MAPPINGS.keys) %>
55
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
56
+ def initialize(full: false, spacious: false, dismissible: false, icon: nil, scheme: DEFAULT_SCHEME, **system_arguments)
57
+ @icon = icon
58
+ @dismissible = dismissible
59
+ @system_arguments = deny_tag_argument(**system_arguments)
60
+ @system_arguments[:tag] = :div
61
+ @system_arguments[:classes] = class_names(
62
+ @system_arguments[:classes],
63
+ "flash",
64
+ SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)],
65
+ "flash-full": full
66
+ )
67
+ @system_arguments[:mb] ||= spacious ? 4 : nil
68
+ end
69
+ end
70
+ end
71
+ end
@@ -82,5 +82,11 @@ module Primer
82
82
  def before_render
83
83
  raise ArgumentError, "href is required when using <a> tag" if @system_arguments[:tag] == :a && @system_arguments[:href].nil? && !Rails.env.production?
84
84
  end
85
+
86
+ def call
87
+ render(Primer::BaseComponent.new(**@system_arguments)) do
88
+ content.to_s + tooltip.to_s
89
+ end
90
+ end
85
91
  end
86
92
  end
@@ -1 +1 @@
1
- import '@github/tab-container-element';
1
+ gimport '@github/tab-container-element';
@@ -8,7 +8,7 @@ module ERBLint
8
8
  # Maps classes in a flash element to arguments for the Flash component.
9
9
  class Flash < Base
10
10
  SCHEME_MAPPINGS = Primer::ViewComponents::Constants.get(
11
- component: "Primer::FlashComponent",
11
+ component: "Primer::Beta::Flash",
12
12
  constant: "SCHEME_MAPPINGS",
13
13
  symbolize: true
14
14
  ).freeze
@@ -7,14 +7,14 @@ require_relative "argument_mappers/flash"
7
7
  module ERBLint
8
8
  module Linters
9
9
  # Counts the number of times a HTML flash is used instead of the component.
10
- class FlashComponentMigrationCounter < BaseLinter
10
+ class FlashMigrationCounter < BaseLinter
11
11
  include Autocorrectable
12
12
 
13
13
  TAGS = %w[div].freeze
14
14
  CLASSES = %w[flash].freeze
15
- MESSAGE = "We are migrating flashes to use [Primer::FlashComponent](https://primer.style/view-components/components/flash), please try to use that instead of raw HTML."
15
+ MESSAGE = "We are migrating flashes to use [Primer::Beta::Flash](https://primer.style/view-components/components/flash), please try to use that instead of raw HTML."
16
16
  ARGUMENT_MAPPER = ArgumentMappers::Flash
17
- COMPONENT = "Primer::FlashComponent"
17
+ COMPONENT = "Primer::Beta::Flash"
18
18
 
19
19
  def map_arguments(tag, tag_tree)
20
20
  # We can only autocorrect elements with simple text as content.
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 76
8
+ PATCH = 79
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
@@ -33,22 +33,6 @@ module RuboCop
33
33
  # }
34
34
  #
35
35
  DEPRECATED = {
36
- is_label_inline: {
37
- true => nil,
38
- false => nil
39
- },
40
- with_icon: {
41
- true => nil,
42
- false => nil
43
- },
44
- is_label_visible: {
45
- false => "visually_hide_label: true",
46
- true => "visually_hide_label: false"
47
- },
48
- is_clearable: {
49
- false => "show_clear_button: false",
50
- true => "show_clear_button: true"
51
- },
52
36
  bg: {
53
37
  white: "bg: :primary",
54
38
  gray_light: "bg: :secondary",
data/lib/tasks/docs.rake CHANGED
@@ -55,7 +55,7 @@ namespace :docs do
55
55
  Primer::DetailsComponent,
56
56
  Primer::Dropdown,
57
57
  Primer::DropdownMenuComponent,
58
- Primer::FlashComponent,
58
+ Primer::Beta::Flash,
59
59
  Primer::FlexComponent,
60
60
  Primer::FlexItemComponent,
61
61
  Primer::HeadingComponent,
data/static/arguments.yml CHANGED
@@ -210,39 +210,28 @@
210
210
  type: String
211
211
  default: N/A
212
212
  description: Id of the list element.
213
- - name: visually_hide_label
213
+ - name: with_icon
214
214
  type: Boolean
215
215
  default: "`false`"
216
- description: Controls if the label is visible. If `true`, screen reader only text
217
- will be added.
218
- - name: show_clear_button
216
+ description: Controls if a search icon is visible, defaults to `false`.
217
+ - name: is_label_visible
218
+ type: Boolean
219
+ default: "`true`"
220
+ description: Controls if the label is visible. If `false`, screen reader only
221
+ text will be added.
222
+ - name: is_clearable
219
223
  type: Boolean
220
224
  default: "`false`"
221
225
  description: Adds optional clear button.
226
+ - name: is_label_inline
227
+ type: Boolean
228
+ default: "`false`"
229
+ description: Controls if the label is inline. On smaller screens, label will always
230
+ become stacked.
222
231
  - name: system_arguments
223
232
  type: Hash
224
233
  default: N/A
225
234
  description: "[System arguments](/system-arguments)"
226
- - name: size
227
- type: Hash
228
- default: "`:medium`"
229
- description: Input size can be small, medium (default), or large
230
- - name: full_width
231
- type: Boolean
232
- default: "`false`"
233
- description: Input can be full-width or fit to content
234
- - name: disabled
235
- type: Boolean
236
- default: "`false`"
237
- description: Disabled input
238
- - name: invalid
239
- type: Boolean
240
- default: "`false`"
241
- description: Invalid input
242
- - name: placeholder
243
- type: String
244
- default: "`nil`"
245
- description: The placeholder text displayed within the input
246
235
  - component: AutoCompleteItem
247
236
  source: https://github.com/primer/view_components/tree/main/app/components/primer/beta/auto_complete/item.rb
248
237
  parameters:
@@ -341,6 +330,33 @@
341
330
  type: Hash
342
331
  default: N/A
343
332
  description: "[System arguments](/system-arguments)"
333
+ - component: Flash
334
+ source: https://github.com/primer/view_components/tree/main/app/components/primer/beta/flash.rb
335
+ parameters:
336
+ - name: full
337
+ type: Boolean
338
+ default: "`false`"
339
+ description: Whether the component should take up the full width of the screen.
340
+ - name: spacious
341
+ type: Boolean
342
+ default: "`false`"
343
+ description: Whether to add margin to the bottom of the component.
344
+ - name: dismissible
345
+ type: Boolean
346
+ default: "`false`"
347
+ description: Whether the component can be dismissed with an X button.
348
+ - name: icon
349
+ type: Symbol
350
+ default: "`nil`"
351
+ description: Name of Octicon icon to use.
352
+ - name: scheme
353
+ type: Symbol
354
+ default: "`:default`"
355
+ description: One of `:danger`, `:default`, `:success`, or `:warning`.
356
+ - name: system_arguments
357
+ type: Hash
358
+ default: N/A
359
+ description: "[System arguments](/system-arguments)"
344
360
  - component: Text
345
361
  source: https://github.com/primer/view_components/tree/main/app/components/primer/beta/text.rb
346
362
  parameters:
@@ -546,33 +562,6 @@
546
562
  type: Hash
547
563
  default: N/A
548
564
  description: "[System arguments](/system-arguments)"
549
- - component: Flash
550
- source: https://github.com/primer/view_components/tree/main/app/components/primer/flash_component.rb
551
- parameters:
552
- - name: full
553
- type: Boolean
554
- default: "`false`"
555
- description: Whether the component should take up the full width of the screen.
556
- - name: spacious
557
- type: Boolean
558
- default: "`false`"
559
- description: Whether to add margin to the bottom of the component.
560
- - name: dismissible
561
- type: Boolean
562
- default: "`false`"
563
- description: Whether the component can be dismissed with an X button.
564
- - name: icon
565
- type: Symbol
566
- default: "`nil`"
567
- description: Name of Octicon icon to use.
568
- - name: scheme
569
- type: Symbol
570
- default: "`:default`"
571
- description: One of `:danger`, `:default`, `:success`, or `:warning`.
572
- - name: system_arguments
573
- type: Hash
574
- default: N/A
575
- description: "[System arguments](/system-arguments)"
576
565
  - component: Flex
577
566
  source: https://github.com/primer/view_components/tree/main/app/components/primer/flex_component.rb
578
567
  parameters:
@@ -18,6 +18,7 @@
18
18
  "Primer::Beta::Blankslate": "",
19
19
  "Primer::Beta::Breadcrumbs": "",
20
20
  "Primer::Beta::Breadcrumbs::Item": "",
21
+ "Primer::Beta::Flash": "",
21
22
  "Primer::Beta::Text": "",
22
23
  "Primer::Beta::Truncate": "",
23
24
  "Primer::Beta::Truncate::TruncateText": "",
@@ -35,7 +36,6 @@
35
36
  "Primer::Dropdown::Menu": "",
36
37
  "Primer::Dropdown::Menu::Item": "",
37
38
  "Primer::DropdownMenuComponent": "",
38
- "Primer::FlashComponent": "",
39
39
  "Primer::FlexComponent": "",
40
40
  "Primer::FlexItemComponent": "",
41
41
  "Primer::HeadingComponent": "",
data/static/classes.yml CHANGED
@@ -1,8 +1,4 @@
1
1
  ---
2
- - ".ActionList"
3
- - ".ActionList-content"
4
- - ".ActionList-item"
5
- - ".ActionList-item-label"
6
2
  - ".AvatarStack"
7
3
  - ".AvatarStack--right"
8
4
  - ".AvatarStack--three-plus"
@@ -23,18 +19,6 @@
23
19
  - ".Counter"
24
20
  - ".Counter--primary"
25
21
  - ".Counter--secondary"
26
- - ".FormControl"
27
- - ".FormControl--input"
28
- - ".FormControl--input-leadingVisual"
29
- - ".FormControl--input-trailingAction"
30
- - ".FormControl--medium"
31
- - ".FormControl-fieldWrap"
32
- - ".FormControl-fieldWrap--input"
33
- - ".FormControl-fieldWrap--input-leadingVisual"
34
- - ".FormControl-fieldWrap--input-trailingAction"
35
- - ".FormControl-label"
36
- - ".FormGroup"
37
- - ".FormGroup--fullWidth"
38
22
  - ".Label"
39
23
  - ".Label--accent"
40
24
  - ".Label--attention"
@@ -65,12 +49,6 @@
65
49
  - ".Link--muted"
66
50
  - ".Link--primary"
67
51
  - ".Link--secondary"
68
- - ".Overlay"
69
- - ".Overlay--height-auto"
70
- - ".Overlay--width-auto"
71
- - ".Overlay-backdrop--anchor"
72
- - ".Overlay-body"
73
- - ".Overlay-body--paddingNone"
74
52
  - ".Popover"
75
53
  - ".Popover-message"
76
54
  - ".Popover-message--large"
@@ -104,6 +82,12 @@
104
82
  - ".UnderlineNav-item"
105
83
  - ".UnderlineNav-octicon"
106
84
  - ".anim-rotate"
85
+ - ".autocomplete-body"
86
+ - ".autocomplete-embedded-icon-wrap"
87
+ - ".autocomplete-item"
88
+ - ".autocomplete-label-inline"
89
+ - ".autocomplete-label-stacked"
90
+ - ".autocomplete-results"
107
91
  - ".avatar"
108
92
  - ".avatar-more"
109
93
  - ".avatar-small"
@@ -183,6 +167,7 @@
183
167
  - ".flex-justify-center"
184
168
  - ".flex-shrink-0"
185
169
  - ".float-right"
170
+ - ".form-control"
186
171
  - ".gutter-condensed"
187
172
  - ".gutter-lg"
188
173
  - ".hidden-text-expander"
@@ -199,18 +199,7 @@
199
199
  ]
200
200
  },
201
201
  "Primer::Beta::AutoComplete": {
202
- "DEFAULT_SIZE": "medium",
203
- "Item": "Primer::Beta::AutoComplete::Item",
204
- "SIZE_MAPPINGS": {
205
- "small": "FormControl--small",
206
- "medium": "FormControl--medium",
207
- "large": "FormControl--large"
208
- },
209
- "SIZE_OPTIONS": [
210
- "small",
211
- "medium",
212
- "large"
213
- ]
202
+ "Item": "Primer::Beta::AutoComplete::Item"
214
203
  },
215
204
  "Primer::Beta::AutoComplete::Item": {
216
205
  },
@@ -270,6 +259,15 @@
270
259
  },
271
260
  "Primer::Beta::Breadcrumbs::Item": {
272
261
  },
262
+ "Primer::Beta::Flash": {
263
+ "DEFAULT_SCHEME": "default",
264
+ "SCHEME_MAPPINGS": {
265
+ "default": "",
266
+ "warning": "flash-warn",
267
+ "danger": "flash-error",
268
+ "success": "flash-success"
269
+ }
270
+ },
273
271
  "Primer::Beta::Text": {
274
272
  "DEFAULT_TAG": "span"
275
273
  },
@@ -427,15 +425,6 @@
427
425
  "dark": "dropdown-menu-dark"
428
426
  }
429
427
  },
430
- "Primer::FlashComponent": {
431
- "DEFAULT_SCHEME": "default",
432
- "SCHEME_MAPPINGS": {
433
- "default": "",
434
- "warning": "flash-warn",
435
- "danger": "flash-error",
436
- "success": "flash-success"
437
- }
438
- },
439
428
  "Primer::FlexComponent": {
440
429
  "ALIGN_ITEMS_DEFAULT": null,
441
430
  "ALIGN_ITEMS_MAPPINGS": {
data/static/statuses.json CHANGED
@@ -18,6 +18,7 @@
18
18
  "Primer::Beta::Blankslate": "beta",
19
19
  "Primer::Beta::Breadcrumbs": "beta",
20
20
  "Primer::Beta::Breadcrumbs::Item": "alpha",
21
+ "Primer::Beta::Flash": "beta",
21
22
  "Primer::Beta::Text": "beta",
22
23
  "Primer::Beta::Truncate": "beta",
23
24
  "Primer::Beta::Truncate::TruncateText": "alpha",
@@ -35,7 +36,6 @@
35
36
  "Primer::Dropdown::Menu": "alpha",
36
37
  "Primer::Dropdown::Menu::Item": "alpha",
37
38
  "Primer::DropdownMenuComponent": "deprecated",
38
- "Primer::FlashComponent": "beta",
39
39
  "Primer::FlexComponent": "deprecated",
40
40
  "Primer::FlexItemComponent": "deprecated",
41
41
  "Primer::HeadingComponent": "beta",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.76
4
+ version: 0.0.79
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2022-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -410,6 +410,8 @@ files:
410
410
  - app/components/primer/beta/blankslate.rb
411
411
  - app/components/primer/beta/breadcrumbs.html.erb
412
412
  - app/components/primer/beta/breadcrumbs.rb
413
+ - app/components/primer/beta/flash.html.erb
414
+ - app/components/primer/beta/flash.rb
413
415
  - app/components/primer/beta/text.rb
414
416
  - app/components/primer/beta/truncate.html.erb
415
417
  - app/components/primer/beta/truncate.rb
@@ -445,8 +447,6 @@ files:
445
447
  - app/components/primer/dropdown/menu.ts
446
448
  - app/components/primer/dropdown_menu_component.html.erb
447
449
  - app/components/primer/dropdown_menu_component.rb
448
- - app/components/primer/flash_component.html.erb
449
- - app/components/primer/flash_component.rb
450
450
  - app/components/primer/flex_component.rb
451
451
  - app/components/primer/flex_item_component.rb
452
452
  - app/components/primer/heading_component.rb
@@ -462,7 +462,6 @@ files:
462
462
  - app/components/primer/label_component.rb
463
463
  - app/components/primer/layout_component.html.erb
464
464
  - app/components/primer/layout_component.rb
465
- - app/components/primer/link_component.erb
466
465
  - app/components/primer/link_component.rb
467
466
  - app/components/primer/local_time.d.ts
468
467
  - app/components/primer/local_time.js
@@ -537,7 +536,7 @@ files:
537
536
  - lib/primer/view_components/linters/button_component_migration_counter.rb
538
537
  - lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb
539
538
  - lib/primer/view_components/linters/close_button_component_migration_counter.rb
540
- - lib/primer/view_components/linters/flash_component_migration_counter.rb
539
+ - lib/primer/view_components/linters/flash_migration_counter.rb
541
540
  - lib/primer/view_components/linters/helpers/rubocop_helpers.rb
542
541
  - lib/primer/view_components/linters/label_component_migration_counter.rb
543
542
  - lib/primer/view_components/linters/subhead_component_migration_counter.rb
@@ -595,7 +594,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
595
594
  - !ruby/object:Gem::Version
596
595
  version: '0'
597
596
  requirements: []
598
- rubygems_version: 3.2.22
597
+ rubygems_version: 3.2.32
599
598
  signing_key:
600
599
  specification_version: 4
601
600
  summary: ViewComponents for the Primer Design System
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- # Use `Flash` to inform users of successful or pending actions.
5
- class FlashComponent < Primer::Component
6
- status :beta
7
-
8
- # Optional action content showed on the right side of the component.
9
- #
10
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
11
- renders_one :action, lambda { |**system_arguments|
12
- deny_tag_argument(**system_arguments)
13
- system_arguments[:tag] = :div
14
- system_arguments[:classes] = class_names(system_arguments[:classes], "flash-action")
15
-
16
- Primer::BaseComponent.new(**system_arguments)
17
- }
18
-
19
- DEFAULT_SCHEME = :default
20
- SCHEME_MAPPINGS = {
21
- DEFAULT_SCHEME => "",
22
- :warning => "flash-warn",
23
- :danger => "flash-error",
24
- :success => "flash-success"
25
- }.freeze
26
- # @example Schemes
27
- # <%= render(Primer::FlashComponent.new) { "This is a flash message!" } %>
28
- # <%= render(Primer::FlashComponent.new(scheme: :warning)) { "This is a warning flash message!" } %>
29
- # <%= render(Primer::FlashComponent.new(scheme: :danger)) { "This is a danger flash message!" } %>
30
- # <%= render(Primer::FlashComponent.new(scheme: :success)) { "This is a success flash message!" } %>
31
- #
32
- # @example Full width
33
- # <%= render(Primer::FlashComponent.new(full: true)) { "This is a full width flash message!" } %>
34
- #
35
- # @example Dismissible
36
- # <%= render(Primer::FlashComponent.new(dismissible: true)) { "This is a dismissible flash message!" } %>
37
- #
38
- # @example Icon
39
- # <%= render(Primer::FlashComponent.new(icon: :people)) { "This is a flash message with an icon!" } %>
40
- #
41
- # @example With actions
42
- # <%= render(Primer::FlashComponent.new) do |component| %>
43
- # This is a flash message with actions!
44
- # <% component.action do %>
45
- # <%= render(Primer::ButtonComponent.new(size: :small)) { "Take action" } %>
46
- # <% end %>
47
- # <% end %>
48
- #
49
- # @param full [Boolean] Whether the component should take up the full width of the screen.
50
- # @param spacious [Boolean] Whether to add margin to the bottom of the component.
51
- # @param dismissible [Boolean] Whether the component can be dismissed with an X button.
52
- # @param icon [Symbol] Name of Octicon icon to use.
53
- # @param scheme [Symbol] <%= one_of(Primer::FlashComponent::SCHEME_MAPPINGS.keys) %>
54
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
55
- def initialize(full: false, spacious: false, dismissible: false, icon: nil, scheme: DEFAULT_SCHEME, **system_arguments)
56
- @icon = icon
57
- @dismissible = dismissible
58
- @system_arguments = deny_tag_argument(**system_arguments)
59
- @system_arguments[:tag] = :div
60
- @system_arguments[:classes] = class_names(
61
- @system_arguments[:classes],
62
- "flash",
63
- SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)],
64
- "flash-full": full
65
- )
66
- @system_arguments[:mb] ||= spacious ? 4 : nil
67
- end
68
- end
69
- end
@@ -1 +0,0 @@
1
- <%= render Primer::BaseComponent.new(**@system_arguments) do -%><%= content -%><%= tooltip -%><% end %>