dsfr-view-components 3.0.2 → 4.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: 218aeda33588aa0ccc5edc9b8b8e3a8d640119b897e56e9a40a7535b32e2473c
4
- data.tar.gz: efe6b590b77c6d4ab3c06be0135386d42b9ebdf15edb2cdf4e4ce2ba4c20dfbe
3
+ metadata.gz: 952489c459b0e459b926500dbd5dffa0ead338ddd8c5e7196546bcaf9627f09c
4
+ data.tar.gz: 60ea4e318eb64e00070ed7858ab53f4429d177489f3fab88379535f9dedda488
5
5
  SHA512:
6
- metadata.gz: afc50786a189f95b63dd71555e4d16e49a1624d1d4a03934f0834b126cbccdeecca95f9f8ebc86522bcfd80ece5763a11d469fa903e74b6c8326dfa9f214a70c
7
- data.tar.gz: f6d94b488b11f15e548f9147f6c7e582ef404687e771efb122db1f5b4de633a1482eccdf5626f1ab6a820e9a1f8bf0445b981f42d5089f3ff4bc763305c56c00
6
+ metadata.gz: e3cd015504d4b42841a05b7a2e0969906f7ca99abdf7dae1ec8f4441608ca54b99b4b41d6023da179618a773e6e346147844c0783e2514e88e64b3e059036f60
7
+ data.tar.gz: 2aa09072f0d92e5e6f3e21d315f5eb9bfff1f71e82dcae5f1db910e6721c965f0dccb5c555ebca471930d149cd9695026ea7ec50286218a9500b3bab80b99dd0
@@ -1,6 +1,7 @@
1
1
  <%= tag.section(**html_attributes) do %>
2
- <%= tag.send(starting_header_tag, class: "fr-accordion__title") do %>
2
+ <%= tag.send(header_tag, class: "fr-accordion__title") do %>
3
3
  <button
4
+ type="button"
4
5
  class="fr-accordion__btn"
5
6
  aria-expanded="<%= expanded? ? "true" : "false" %>"
6
7
  aria-controls="<%= id %>"
@@ -1,7 +1,7 @@
1
1
  class DsfrComponent::AccordionComponent::SectionComponent < DsfrComponent::Base
2
2
  include DsfrComponent::Traits::HeaderSizeable
3
3
 
4
- attr_reader :title, :expanded, :starting_header_level
4
+ attr_reader :title, :expanded
5
5
 
6
6
  alias_method :expanded?, :expanded
7
7
 
@@ -10,7 +10,7 @@ class DsfrComponent::AccordionComponent::SectionComponent < DsfrComponent::Base
10
10
  # @param id [String] the HTML id, optional if you want to reuse the anchor
11
11
  def initialize(
12
12
  title:,
13
- starting_header_level:,
13
+ header_level:,
14
14
  expanded: false,
15
15
  id: nil,
16
16
  html_attributes: {}
@@ -18,7 +18,7 @@ class DsfrComponent::AccordionComponent::SectionComponent < DsfrComponent::Base
18
18
  @title = title
19
19
  @expanded = expanded
20
20
  @id = id
21
- @starting_header_level = starting_header_level
21
+ self.header_level = header_level
22
22
 
23
23
  super(html_attributes: html_attributes)
24
24
  end
@@ -7,13 +7,13 @@ class DsfrComponent::AccordionComponent < DsfrComponent::Base
7
7
  html_attributes: html_attributes,
8
8
  title: title,
9
9
  id: id,
10
- starting_header_level: starting_header_level,
10
+ header_level: header_level,
11
11
  &block
12
12
  )
13
13
  end
14
14
 
15
- def initialize(html_attributes: {}, starting_header_level: nil)
16
- @starting_header_level = starting_header_level
15
+ def initialize(html_attributes: {}, header_level: nil)
16
+ self.header_level = header_level
17
17
 
18
18
  super(html_attributes: html_attributes)
19
19
  end
@@ -9,7 +9,7 @@ class DsfrComponent::AlertComponent < DsfrComponent::Base
9
9
  # @param size [AlertComponent::SIZES]
10
10
  # @param close_button [Boolean] contrôle l'affichage d'un bouton de fermeture
11
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
12
+ # @param header_level [Integer] Le niveau de titre
13
13
  # @note La taille `:md` requiert un titre mais le contenu est
14
14
  # optionel ; la taille `sm` requiert un contenu, mais pas de titre.
15
15
  def initialize(
@@ -18,7 +18,7 @@ class DsfrComponent::AlertComponent < DsfrComponent::Base
18
18
  size: :md,
19
19
  close_button: false,
20
20
  icon_name: nil,
21
- starting_header_level: nil,
21
+ header_level: nil,
22
22
  html_attributes: {}
23
23
  )
24
24
  @title = title
@@ -26,7 +26,7 @@ class DsfrComponent::AlertComponent < DsfrComponent::Base
26
26
  @size = size
27
27
  @close_button = close_button
28
28
  @icon_name = icon_name
29
- @starting_header_level = starting_header_level
29
+ self.header_level = header_level
30
30
 
31
31
  super(html_attributes: html_attributes)
32
32
  end
@@ -77,7 +77,7 @@ private
77
77
  def title_tag
78
78
  return nil if title.blank?
79
79
 
80
- tag.send(starting_header_tag, class: "fr-alert__title") { title }
80
+ tag.send(header_tag, class: "fr-alert__title") { title }
81
81
  end
82
82
 
83
83
  def content_tag
@@ -8,23 +8,23 @@ module DsfrComponent
8
8
 
9
9
  # @param title [String] Le titre de la mise en avant
10
10
  # @param icon_name [String] Le nom de l’icône à afficher (exemple `arrow-right-line`), ou `:none` pour la désactiver (optionnel)
11
- # @param starting_header_level [Integer] Le niveau de titre (optionnel)
11
+ # @param header_level [Integer] Le niveau de titre (optionnel)
12
12
  def initialize(
13
13
  title:,
14
14
  icon_name: "information-line",
15
- starting_header_level: nil,
15
+ header_level: nil,
16
16
  html_attributes: {}
17
17
  )
18
18
  @title = title
19
19
  @icon_name = icon_name
20
- @starting_header_level = starting_header_level
20
+ self.header_level = header_level
21
21
 
22
22
  super(html_attributes: html_attributes)
23
23
  end
24
24
 
25
25
  def call
26
26
  tag.div(**html_attributes) do
27
- concat content_tag(starting_header_tag, @title, class: 'fr-callout__title')
27
+ concat content_tag(header_tag, @title, class: 'fr-callout__title')
28
28
 
29
29
  concat content_tag(:p, content, class: 'fr-callout__text')
30
30
 
@@ -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
@@ -1,10 +1,10 @@
1
1
  <%= tag.div(**html_attributes) do %>
2
- <h2 class="fr-stepper__title">
2
+ <%= tag.send(header_tag, class: "fr-stepper__title") do %>
3
3
  <%= title %>
4
4
  <span class="fr-stepper__state">
5
5
  Étape <%= value %> sur <%= max %>
6
6
  </span>
7
- </h2>
7
+ <% end %>
8
8
  <div
9
9
  class="fr-stepper__steps"
10
10
  data-fr-current-step="<%= value %>"
@@ -1,14 +1,18 @@
1
1
  module DsfrComponent
2
2
  class StepperComponent < DsfrComponent::Base
3
+ include DsfrComponent::Traits::HeaderSizeable
4
+
3
5
  # @param title [String] Titre de l’étape en cours
4
6
  # @param value [Integer] Numéro de l’étape en cours (commence à 1)
5
7
  # @param max [Integer] Nombre d’étapes total
6
8
  # @param next_title [String] Titre de l’étape suivante (sauf pour la dernière étape)
7
- def initialize(title:, value:, max:, next_title: nil, html_attributes: {})
9
+ # @param header_level [Integer] Niveau du titre
10
+ def initialize(title:, value:, max:, next_title: nil, header_level: 2, html_attributes: {})
8
11
  @title = title
9
12
  @value = value
10
13
  @max = max
11
14
  @next_title = next_title
15
+ self.header_level = header_level
12
16
 
13
17
  raise ArgumentError, "Les étapes doivent aller de 1 jusqu´à 8 au maximum" if @value < 1 || @value > @max || @max > 8
14
18
 
@@ -3,22 +3,35 @@
3
3
  module DsfrComponent
4
4
  module Traits
5
5
  # HeaderSizeable is meant for every component that exhibits a
6
- # header, which level can be overriden via the
7
- # `default_header_level` method. Make sure you store the attribute
8
- # `@starting_header_level` in your component's constructor.
6
+ # header which level can be overriden. Make sure you use the
7
+ # setter (self.header_level) in your component's constructor.
9
8
  module HeaderSizeable
10
9
  DEFAULT_HEADER_LEVEL = 3
11
10
 
12
- def starting_header_level
13
- @starting_header_level || default_header_level
11
+ def header_level
12
+ @header_level || default_header_level
13
+ end
14
+
15
+ def header_level=(level)
16
+ return if level.nil?
17
+
18
+ raise ArgumentError, "Le niveau du titre doit être compris entre 1 et 6" if !correct?(level)
19
+
20
+ @header_level = level
14
21
  end
15
22
 
16
23
  def default_header_level
17
24
  DEFAULT_HEADER_LEVEL
18
25
  end
19
26
 
20
- def starting_header_tag
21
- ["h", starting_header_level].join
27
+ def header_tag
28
+ ["h", header_level].join
29
+ end
30
+
31
+ private
32
+
33
+ def correct?(level)
34
+ level.in?(DsfrComponent::Base::HEADING_LEVELS)
22
35
  end
23
36
  end
24
37
  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.2'.freeze
3
+ VERSION = '4.0'.freeze
4
4
  end
5
5
  end
@@ -10,4 +10,4 @@ title: <%= name %>
10
10
  :markdown
11
11
  Le rendu de base du <%= name %>Component
12
12
 
13
- = render('/partials/related-info.haml', links: dsfr_component_doc_links("doc-id", "storybook-id"))
13
+ = render('/partials/related-info.haml', links: dsfr_component_doc_links("doc-id"))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsfr-view-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: '4.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - BetaGouv developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-27 00:00:00.000000000 Z
11
+ date: 2025-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-attributes-utils
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.13'
47
+ version: 1.13.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.13'
54
+ version: 1.13.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: deep_merge
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -353,6 +353,8 @@ files:
353
353
  - app/components/dsfr_component/modal_component.rb
354
354
  - app/components/dsfr_component/notice_component.html.erb
355
355
  - app/components/dsfr_component/notice_component.rb
356
+ - app/components/dsfr_component/proconnect_button_component.html.erb
357
+ - app/components/dsfr_component/proconnect_button_component.rb
356
358
  - app/components/dsfr_component/search_component.html.erb
357
359
  - app/components/dsfr_component/search_component.rb
358
360
  - app/components/dsfr_component/skiplink_component.html.erb