dsfr-view-components 3.0.1 → 3.1

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: 8780041bae859ed3e40f83a06d62b0cbec970d9d7e1e6d29a40d2b2a6b1f1f3b
4
- data.tar.gz: 300b8e5270fc91042b0e915b29cf477a9c4b7f1c609173856b7a9518c5c14d5b
3
+ metadata.gz: 6ad464710e4c2bcddb1c49cab5cbc7fe7dac3508dc90e09b55be83adaf0302fc
4
+ data.tar.gz: a2c78fd736e9a21d0953e7205c9c0d62c3d9027d256d60035b0556da0e3de72a
5
5
  SHA512:
6
- metadata.gz: 914f18a7ced8fdebc65797384cba976c8ed9586ba521b54020041e3a6c7653f6eb7ffca61c98bf4246564c0d2a4cecfce9f66fb404f8819c14232e53be4acb63
7
- data.tar.gz: 0f528525221c610318711fd2b7cb505e23f4a47d771137dd4d80ce8abbaff1b790c9e188c4beed20b5e02e42c87b95b472547bda7d3ecead11f36ca42b8e236f
6
+ metadata.gz: c3728eb72aeee052f246550071ec38f2f11dd7194a9ebfe001fe8dbef41e02494ec983626a262e9ef0b25dca64e1c2b48eecdd5be69260e9bb515f3f06ad6466
7
+ data.tar.gz: f08bdd10f57d02d956c128ff65304829488a4fe7d41138deeeafe8e15ac72bdd9f0d95803a6b08e1313aa1d9dff8c21bf69a3954d785f57aa3f4e3936ba48acd
@@ -1,18 +1,32 @@
1
1
  class DsfrComponent::AlertComponent < DsfrComponent::Base
2
+ include DsfrComponent::Traits::HeaderSizeable
3
+
2
4
  TYPES = %i[error success info warning].freeze
3
5
  SIZES = %i[sm md].freeze
4
6
 
5
- # @param type [Symbol] alert type (and matching color) `:success`, `:info`, `:warning` ou `:error`
6
- # @param title [String] alert title. cannot be set in size `:sm`
7
- # @param size [Symbol] alert size : `:md` (default) or `:sm`
8
- # @param close_button [Boolean] display a close button to remove the alert
9
- # @note in size MD the title is required but the content is optional. In size SM there should be not title but the content is required
10
- def initialize(type: nil, title: nil, size: :md, close_button: false, icon_name: nil, html_attributes: {})
7
+ # @param type [AlertComponent::TYPES]
8
+ # @param title [String] le titre de l'alerte, sauf pour la taille `:sm`
9
+ # @param size [AlertComponent::SIZES]
10
+ # @param close_button [Boolean] contrôle l'affichage d'un bouton de fermeture
11
+ # @param icon_name [String] un nom d'icône à afficher, seulement disponible pour le type par défaut
12
+ # @param starting_header_level [Integer] Le niveau de titre
13
+ # @note La taille `:md` requiert un titre mais le contenu est
14
+ # optionel ; la taille `sm` requiert un contenu, mais pas de titre.
15
+ def initialize(
16
+ type: nil,
17
+ title: nil,
18
+ size: :md,
19
+ close_button: false,
20
+ icon_name: nil,
21
+ starting_header_level: nil,
22
+ html_attributes: {}
23
+ )
11
24
  @title = title
12
25
  @type = type
13
26
  @size = size
14
27
  @close_button = close_button
15
28
  @icon_name = icon_name
29
+ @starting_header_level = starting_header_level
16
30
 
17
31
  super(html_attributes: html_attributes)
18
32
  end
@@ -63,7 +77,7 @@ private
63
77
  def title_tag
64
78
  return nil if title.blank?
65
79
 
66
- tag.h3(class: "fr-alert__title") { title }
80
+ tag.send(starting_header_tag, class: "fr-alert__title") { title }
67
81
  end
68
82
 
69
83
  def content_tag
@@ -12,7 +12,7 @@
12
12
  <%= operator_image %>
13
13
  <% end %>
14
14
 
15
- <% if search? || tool_links? || direct_links? %>
15
+ <% if with_navbar? %>
16
16
  <div class="fr-header__navbar">
17
17
  <% if search? %>
18
18
  <button class="fr-btn--search fr-btn" data-fr-opened="false" aria-controls="modal-header-search" id="button-header-search" title="Rechercher">
@@ -20,7 +20,7 @@
20
20
  </button>
21
21
  <% end %>
22
22
 
23
- <% if tool_links? || direct_links? %>
23
+ <% if with_menu? %>
24
24
  <button class="fr-btn--menu fr-btn" data-fr-opened="false" aria-controls="modal-header-menu" aria-haspopup="menu" id="button-header-menu" title="Menu">
25
25
  Menu
26
26
  </button>
@@ -41,9 +41,9 @@
41
41
  <% end %>
42
42
  </div>
43
43
 
44
- <% if tool_links? || search? %>
44
+ <% if with_tools? %>
45
45
  <div class="fr-header__tools">
46
- <% if tool_links? %>
46
+ <% if tool_links? || custom_tool_links? %>
47
47
  <div class="fr-header__tools-links">
48
48
  <ul class="fr-btns-group">
49
49
  <% tool_links.each do |tool_link| %>
@@ -51,6 +51,11 @@
51
51
  <%= tool_link %>
52
52
  </li>
53
53
  <% end %>
54
+ <% custom_tool_links.each do |custom_tool_link| %>
55
+ <li>
56
+ <%= custom_tool_link %>
57
+ </li>
58
+ <% end %>
54
59
  </ul>
55
60
  </div>
56
61
  <% end %>
@@ -73,7 +78,7 @@
73
78
  </div>
74
79
  </div>
75
80
 
76
- <% if tool_links? || direct_links? %>
81
+ <% if with_menu? %>
77
82
  <div class="fr-header__menu fr-modal" id="modal-header-menu" aria-labelledby="button-header-menu" role="navigation">
78
83
  <div class="fr-container">
79
84
  <button class="fr-btn--close fr-btn" aria-controls="modal-header-menu" title="Fermer">
@@ -2,6 +2,7 @@ class DsfrComponent::HeaderComponent < DsfrComponent::Base
2
2
  renders_one :search
3
3
  renders_one :operator_image, "DsfrComponent::HeaderComponent::OperatorImageComponent"
4
4
  renders_many :tool_links, "DsfrComponent::HeaderComponent::ToolLinkComponent"
5
+ renders_many :custom_tool_links
5
6
  renders_many :direct_links, types: {
6
7
  simple: "DsfrComponent::HeaderComponent::DirectLinkComponent",
7
8
  dropdown: "DsfrComponent::HeaderComponent::DirectLinkDropdownComponent"
@@ -25,4 +26,16 @@ private
25
26
  def default_attributes
26
27
  { class: 'fr-header', role: 'banner' }
27
28
  end
29
+
30
+ def with_tools?
31
+ tool_links? || search? || custom_tool_links?
32
+ end
33
+
34
+ def with_navbar?
35
+ with_tools? || direct_links?
36
+ end
37
+
38
+ def with_menu?
39
+ tool_links? || direct_links?
40
+ end
28
41
  end
@@ -1,6 +1,6 @@
1
1
  module DsfrComponent
2
2
  class NoticeComponent < DsfrComponent::Base
3
- GENERIC_TYPES = %w[info waring alert].freeze
3
+ GENERIC_TYPES = %w[info warning alert].freeze
4
4
  WEATHER_TYPES = %w[weather-orange weather-red weather-purple].freeze
5
5
  ALERT_TYPES = %w[kidnapping cyberattack attack witness].freeze
6
6
  TYPES = GENERIC_TYPES + WEATHER_TYPES + ALERT_TYPES
@@ -11,7 +11,7 @@ module DsfrComponent
11
11
 
12
12
  # @param title [String] Titre du bandeau
13
13
  # @param description [String] Description du bandeau pour apporter du contexte (optionnel)
14
- # @param type [String] Type de bandeau (info, waring, alert, weather-orange, weather-red, weather-purple, kidnapping, cyberattack, attack, witness)
14
+ # @param type [String] Type de bandeau (info, warning, alert, weather-orange, weather-red, weather-purple, kidnapping, cyberattack, attack, witness)
15
15
  # @param description_tag [Symbol] Balise HTML à utiliser pour la description (p, h1, h2, h3, h4, h5, h6)
16
16
  # @param use_icon [Boolean] Afficher ou non une icône, uniquement pour les bandeaux génériques
17
17
  # @param icon_name [String] Nom de l'icône à afficher
@@ -0,0 +1,10 @@
1
+ <%= content_tag(:div, class: "fr-connect-group", **html_attributes) do %>
2
+ <%= button_to(target, button_attributes) do %>
3
+ <span class="fr-connect__login">S'identifier avec</span>
4
+ <span class="fr-connect__brand">ProConnect</span>
5
+ <% end %>
6
+
7
+ <p>
8
+ <%= link_to "Qu'est-ce que ProConnect ?", "https://www.proconnect.gouv.fr/", target: "_blank", rel: "noopener", title: "Qu’est-ce que ProConnect ? - nouvelle fenêtre" %>
9
+ </p>
10
+ <% end %>
@@ -0,0 +1,36 @@
1
+ module DsfrComponent
2
+ class ProconnectButtonComponent < DsfrComponent::Base
3
+ using HTMLAttributesUtils
4
+
5
+ # @param target [String] la cible où POST le formulaire/bouton
6
+ # @param button_overrides [Hash] attributs pour surcharger le bouton
7
+ def initialize(target:, button_overrides: {}, html_attributes: {})
8
+ @target = target
9
+ @button_overrides = button_overrides
10
+
11
+ super(html_attributes: html_attributes)
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :target, :button_overrides
17
+
18
+ def button_attributes
19
+ default_button_attributes
20
+ .deep_merge_html_attributes(button_overrides)
21
+ end
22
+
23
+ def default_button_attributes
24
+ {
25
+ method: :post,
26
+ remote: false,
27
+ class: "fr-connect fr-proconnect",
28
+ data: { turbo: false }
29
+ }
30
+ end
31
+
32
+ def default_attributes
33
+ { class: "fr-connect-group" }
34
+ end
35
+ end
36
+ end
@@ -21,6 +21,7 @@ module DsfrComponentsHelper
21
21
  dsfr_callout: 'DsfrComponent::CalloutComponent',
22
22
  dsfr_notice: 'DsfrComponent::NoticeComponent',
23
23
  dsfr_search: 'DsfrComponent::SearchComponent',
24
+ dsfr_proconnect_button: 'DsfrComponent::ProconnectButtonComponent',
24
25
  # DO NOT REMOVE: new component mapping here
25
26
  }.freeze
26
27
  HELPER_NAME_TO_CLASS_NAME.each do |name, klass|
@@ -1,5 +1,5 @@
1
1
  module Dsfr
2
2
  module Components
3
- VERSION = '3.0.1'.freeze
3
+ VERSION = '3.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsfr-view-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: '3.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - BetaGouv developers
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-07 00:00:00.000000000 Z
10
+ date: 2025-06-03 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: html-attributes-utils
@@ -43,14 +43,14 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.13'
46
+ version: 1.13.2
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1.13'
53
+ version: 1.13.2
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: deep_merge
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -352,6 +352,8 @@ files:
352
352
  - app/components/dsfr_component/modal_component.rb
353
353
  - app/components/dsfr_component/notice_component.html.erb
354
354
  - app/components/dsfr_component/notice_component.rb
355
+ - app/components/dsfr_component/proconnect_button_component.html.erb
356
+ - app/components/dsfr_component/proconnect_button_component.rb
355
357
  - app/components/dsfr_component/search_component.html.erb
356
358
  - app/components/dsfr_component/search_component.rb
357
359
  - app/components/dsfr_component/skiplink_component.html.erb