primer_view_components 0.42.0 → 0.43.0

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: 3cecb9c07526e9ed4c595b81ab2407709d46e00be974ce5ea60023f1091ff1c1
4
- data.tar.gz: a4d50670d1294e10aaa8d249c87c8bea4d879bd1b9ca3cbe43ca4a082f265784
3
+ metadata.gz: 8b8def83f2582f5a2ac49a275b6f0262473510b6bc9f3931cb72115bb91e1b8d
4
+ data.tar.gz: ea003aff30f6d1b2570c432c2921a93e8ec9bdb9a682d39fb5d5bf4e29729418
5
5
  SHA512:
6
- metadata.gz: 4d8c7cdb2e70078106522c2fe88a4ea8205dfbc0416a008f5bd8c9005305ea670b767a4ab26b9772392be13107136c26de8e840e999b23368f27d4d5a429072a
7
- data.tar.gz: 73cf2a36f12cafabe4cdbfb6af9e720fabccdfcb8fb26eb9a6aeb5e18854e7cf0c6b49274bc03698b335273507d339046314e70a349cdd3a63f5d2126b1fab1c
6
+ metadata.gz: 314b33264d58ea808b7db78d0137cc03d151a4e6f3aab8a363a8ea4c0fecd622edfcdb6df81499f02807d0616298978e80b94865ac4b435109911056073f9503
7
+ data.tar.gz: 83449ea51244eec9fa28f361221b66a9bb0e6450e2a025f30e9adc5e8f848af08eb4f9057c5f0b583128799d07f8d1877659708350c59363feeea1a9ead0b31e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.43.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#3466](https://github.com/primer/view_components/pull/3466) [`57f6c41`](https://github.com/primer/view_components/commit/57f6c41025de70dfcd6880dab7e881d182e3cbd9) Thanks [@manuelpuyol](https://github.com/manuelpuyol)! - Create Primer::CurrentAttributes allowing apps to set request specific context to components. Update IncludeFragment to add data-nonce when a current nonce is present.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#3447](https://github.com/primer/view_components/pull/3447) [`c2b88cb`](https://github.com/primer/view_components/commit/c2b88cb1d75e86fc0b410e3fc597e48326f471a5) Thanks [@bsatarnejad](https://github.com/bsatarnejad)! - Add a new custom label for close button in dialog header
12
+
13
+ - [#3450](https://github.com/primer/view_components/pull/3450) [`5e86bf4`](https://github.com/primer/view_components/commit/5e86bf422b13a3818def5ceab464f8e362f9021b) Thanks [@francinelucca](https://github.com/francinelucca)! - Fix(SelectPanel): incorrect padding when no filter
14
+
3
15
  ## 0.42.0
4
16
 
5
17
  ### Minor Changes
@@ -13,7 +13,7 @@
13
13
  <% end %>
14
14
  </div>
15
15
  <div class="Overlay-actionWrap">
16
- <%= render Primer::Beta::CloseButton.new(classes: "Overlay-closeButton", "data-close-dialog-id": @id) %>
16
+ <%= render Primer::Beta::CloseButton.new(classes: "Overlay-closeButton", "data-close-dialog-id": @id, aria: { label: @close_label }) %>
17
17
  </div>
18
18
  </div>
19
19
  <%= filter %>
@@ -16,6 +16,8 @@ module Primer
16
16
  }.freeze
17
17
  VARIANT_OPTIONS = VARIANT_MAPPINGS.keys
18
18
 
19
+ DEFAULT_CLOSE_LABEL = "Close"
20
+
19
21
  # Optional filter slot for adding a filter input to the header.
20
22
  #
21
23
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -48,6 +50,7 @@ module Primer
48
50
  # @param show_divider [Boolean] Show a divider between the header and body.
49
51
  # @param visually_hide_title [Boolean] Visually hide the `title` while maintaining a label for assistive technologies.
50
52
  # @param variant [Symbol] <%= one_of(Primer::Alpha::Dialog::Header::VARIANT_OPTIONS) %>
53
+ # @param close_label [String] The aria-label text of the close "x" button.
51
54
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
52
55
  def initialize(
53
56
  id:,
@@ -56,12 +59,14 @@ module Primer
56
59
  show_divider: false,
57
60
  visually_hide_title: false,
58
61
  variant: DEFAULT_VARIANT,
62
+ close_label: DEFAULT_CLOSE_LABEL,
59
63
  **system_arguments
60
64
  )
61
65
  @id = id
62
66
  @title = title
63
67
  @subtitle = subtitle
64
68
  @visually_hide_title = visually_hide_title
69
+ @close_label = close_label
65
70
  @system_arguments = deny_tag_argument(**system_arguments)
66
71
  @system_arguments[:tag] = :div
67
72
 
@@ -8,14 +8,27 @@ module Primer
8
8
  class IncludeFragment < Primer::Component
9
9
  status :alpha
10
10
 
11
+ ALLOWED_LOADING_VALUES = [:lazy, :eager].freeze
12
+ DEFAULT_LOADING = :eager
13
+
11
14
  # @param src [String] The URL from which to retrieve an HTML element fragment.
12
15
  # @param loading [Symbol] <%= one_of([:lazy, :eager]) %>
16
+ # @param accept [String] What to send as the Accept header.
13
17
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
14
- def initialize(src: nil, loading: :eager, **system_arguments)
18
+ def initialize(src: nil, loading: nil, accept: nil, **system_arguments)
15
19
  @system_arguments = system_arguments
16
20
  @system_arguments[:tag] = "include-fragment"
17
21
  @system_arguments[:loading] = loading
18
22
  @system_arguments[:src] = src
23
+ @system_arguments[:accept] = accept if accept
24
+
25
+ if loading
26
+ @system_arguments[:loading] = fetch_or_fallback(ALLOWED_LOADING_VALUES, loading.to_sym, DEFAULT_LOADING)
27
+ end
28
+
29
+ if Primer::CurrentAttributes.nonce
30
+ @system_arguments[:"data-nonce"] = Primer::CurrentAttributes.nonce
31
+ end
19
32
  end
20
33
 
21
34
  def call
@@ -50,7 +50,7 @@
50
50
  <% end %>
51
51
  <% end %>
52
52
  <% end %>
53
- <%= render Primer::Alpha::Dialog::Body.new(mt: show_filter? ? 0 : 2, p: 0) do %>
53
+ <%= render Primer::Alpha::Dialog::Body.new(p: 0) do %>
54
54
  <focus-group direction="vertical" mnemonics retain>
55
55
  <live-region data-target="select-panel.liveRegion"></live-region>
56
56
  <%= render(Primer::BaseComponent.new(
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # `Primer::CurrentAttributes` can be used by controllers to set request-bound data
5
+ # that can be propagated to components.
6
+ class CurrentAttributes < ActiveSupport::CurrentAttributes
7
+ attribute :nonce
8
+ end
9
+ end
@@ -5,7 +5,7 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 42
8
+ MINOR = 43
9
9
  PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
@@ -0,0 +1,5 @@
1
+ <%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: title, subtitle: subtitle, visually_hide_title: false)) do |dialog| %>
2
+ <% dialog.with_header(show_divider: show_divider, close_label: close_label) %>
3
+ <% dialog.with_show_button_content(button_text) %>
4
+ <% dialog.with_body_content("Hello World") %>
5
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: title, subtitle: subtitle, visually_hide_title: false)) do |dialog| %>
2
+ <% dialog.with_header(show_divider: show_divider, close_scheme: :none) %>
3
+ <% dialog.with_show_button_content(button_text) %>
4
+ <% dialog.with_body_content("Hello World") %>
5
+ <% dialog.with_footer do %>
6
+ <%= render(Primer::Beta::Button.new(data: { "close-dialog-id": "my-dialog" })) { "Close" } %>
7
+ <% end %>
8
+ <% end %>
@@ -302,6 +302,38 @@ module Primer
302
302
  def with_header_filter
303
303
  render_with_template(locals: {})
304
304
  end
305
+
306
+ # @label With custom label for close button of header
307
+ #
308
+ # @param title [String] text
309
+ # @param subtitle [String] text
310
+ # @param button_text [String] text
311
+ # @param show_divider [Boolean] toggle
312
+ # @param close_label [String] text
313
+ def with_header_close_button_label(title: "Test Dialog", subtitle: nil, button_text: "Show Dialog", show_divider: true, close_label: "Close me!")
314
+ render_with_template(locals: {
315
+ title: title,
316
+ subtitle: subtitle,
317
+ button_text: button_text,
318
+ show_divider: show_divider,
319
+ close_label: close_label
320
+ })
321
+ end
322
+
323
+ # @label Without custom label for close button of header
324
+ #
325
+ # @param title [String] text
326
+ # @param subtitle [String] text
327
+ # @param button_text [String] text
328
+ # @param show_divider [Boolean] toggle
329
+ def without_header_close_button_label(title: "Test Dialog", subtitle: nil, button_text: "Show Dialog", show_divider: true)
330
+ render_with_template(locals: {
331
+ title: title,
332
+ subtitle: subtitle,
333
+ button_text: button_text,
334
+ show_divider: show_divider
335
+ })
336
+ end
305
337
  end
306
338
  end
307
339
  end
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.42.0
4
+ version: 0.43.0
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: 2025-04-15 00:00:00.000000000 Z
11
+ date: 2025-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -551,6 +551,7 @@ files:
551
551
  - app/lib/primer/css/layout.css.json
552
552
  - app/lib/primer/css/utilities.css
553
553
  - app/lib/primer/css/utilities.css.json
554
+ - app/lib/primer/current_attributes.rb
554
555
  - app/lib/primer/experimental_render_helpers.rb
555
556
  - app/lib/primer/experimental_slot_helpers.rb
556
557
  - app/lib/primer/fetch_or_fallback_helper.rb
@@ -782,8 +783,10 @@ files:
782
783
  - previews/primer/alpha/dialog_preview/with_footer.html.erb
783
784
  - previews/primer/alpha/dialog_preview/with_form.html.erb
784
785
  - previews/primer/alpha/dialog_preview/with_header.html.erb
786
+ - previews/primer/alpha/dialog_preview/with_header_close_button_label.html.erb
785
787
  - previews/primer/alpha/dialog_preview/with_header_filter.html.erb
786
788
  - previews/primer/alpha/dialog_preview/with_text_input.html.erb
789
+ - previews/primer/alpha/dialog_preview/without_header_close_button_label.html.erb
787
790
  - previews/primer/alpha/dropdown_preview.rb
788
791
  - previews/primer/alpha/form_control_preview.rb
789
792
  - previews/primer/alpha/form_control_preview/playground.html.erb