dsfr-view-components 5.0.2 → 5.1.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: aab49185db5dee4de6e32f79d10a3dd6866ad6d23b8876ecc97bd6f4305e0a12
4
- data.tar.gz: 7af84ab6aa6fe038867c1100bfd8daa190ee82e56f43c75af0b377e28b5a1717
3
+ metadata.gz: 21e22399b4567acc732e6e9342628199bcb79a955e62d290e61ceb38155b5e35
4
+ data.tar.gz: 057c755a202b248f06db84e28dc4610a11ebf2b64b9c4cf1e8fd69dbc3948707
5
5
  SHA512:
6
- metadata.gz: f9b187588c9246ae6f6c45363b50dc1d329d78a9d3b658ce413e6e40c94eff16793bc669dada0caecc8586c6f2e211f366839c40a816d0a789f4b12a4ba79150
7
- data.tar.gz: 6a7317e0de48d0c434252284f6fb8c9e6fbf4accfb56beb79216f5544a88e954ec6930a7ca57a4f8aba1f35d8b09ce89592873c9b9526668102a24532cd16508
6
+ metadata.gz: 925d4e06a574a2a2a682a0d0f3e742323aed826d830055497084a293dd79d745ce4200c8a88776aaa81ae51930686e529a32e537125fc3134ed80ca570faa63b
7
+ data.tar.gz: bf238c5a514fb9a4672928235b70b53bc2a57fc76fceb24c50d25540b56239ed62429bc42e670baf4bf4b426a8693b9e9fe5b7b733119c6c28db4ba7d23f2992
@@ -4,32 +4,39 @@ module DsfrComponent
4
4
  SIZES = %i[md sm].freeze
5
5
 
6
6
  # @param status [BadgeComponent::STATUSES]
7
- def initialize(status: nil, size: :md, html_attributes: {})
7
+ # @param size [BadgeComponent::SIZES] taille du badge : `:md` (par défaut) ou `:sm` (optionnel)
8
+ # @param has_icon [Boolean] `false` retire l'icône d'un badge système, nécessite un `status` (optionnel)
9
+ # @param ellipsis [Boolean] tronque le libellé avec une ellipse s'il est trop long (optionnel)
10
+ def initialize(status: nil, size: :md, has_icon: true, ellipsis: false, html_attributes: {})
8
11
  validate_status!(status)
9
12
  validate_size!(size)
13
+ validate_has_icon!(has_icon, status)
10
14
 
11
15
  @status = status
12
16
  @size = size
17
+ @has_icon = has_icon
18
+ @ellipsis = ellipsis
13
19
 
14
20
  super(html_attributes: html_attributes)
15
21
  end
16
22
 
17
23
  def call
18
- tag.div(**html_attributes) do
19
- content
24
+ tag.p(**html_attributes) do
25
+ ellipsis ? tag.span(content, class: 'fr-ellipsis') : content
20
26
  end
21
27
  end
22
28
 
23
29
  private
24
30
 
25
- attr_reader :status, :size
31
+ attr_reader :status, :size, :has_icon, :ellipsis
26
32
 
27
33
  def default_attributes
28
34
  {
29
35
  class: class_names(
30
36
  'fr-badge',
31
37
  "fr-badge--#{status}" => status.present?,
32
- "fr-badge--sm" => size == :sm
38
+ "fr-badge--sm" => size == :sm,
39
+ "fr-badge--no-icon" => !has_icon
33
40
  )
34
41
  }
35
42
  end
@@ -39,7 +46,11 @@ module DsfrComponent
39
46
  end
40
47
 
41
48
  def validate_size!(size)
42
- raise(ArgumentError, "`size` should be one of #{SIZES} (received: `#{status}`") if !SIZES.include?(size)
49
+ raise(ArgumentError, "`size` should be one of #{SIZES} (received: `#{size}`)") if !SIZES.include?(size)
50
+ end
51
+
52
+ def validate_has_icon!(has_icon, status)
53
+ raise(ArgumentError, "`has_icon: false` can only be used with a `status`") if !has_icon && status.blank?
43
54
  end
44
55
  end
45
56
  end
@@ -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">FranceConnect</span>
5
+ <% end %>
6
+
7
+ <p>
8
+ <%= link_to info_link_label, info_link_href, target: "_blank", rel: "noopener", title: "#{info_link_label} - nouvelle fenêtre" %>
9
+ </p>
10
+ <% end %>
@@ -0,0 +1,50 @@
1
+ module DsfrComponent
2
+ class FranceConnectButtonComponent < DsfrComponent::Base
3
+ using HTMLAttributesUtils
4
+
5
+ # @param target [String] la cible où POST le formulaire/bouton
6
+ # @param use_plus_version [Boolean] utiliser la variante FranceConnect+
7
+ # @param button_overrides [Hash] attributs pour surcharger le bouton
8
+ def initialize(target:, use_plus_version: false, button_overrides: {}, html_attributes: {})
9
+ @target = target
10
+ @use_plus_version = use_plus_version
11
+ @button_overrides = button_overrides
12
+
13
+ super(html_attributes: html_attributes)
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :target, :use_plus_version, :button_overrides
19
+
20
+ def use_plus_version?
21
+ use_plus_version
22
+ end
23
+
24
+ def info_link_href
25
+ use_plus_version? ? "https://www.franceconnect.gouv.fr/franceconnect-plus/" : "https://www.franceconnect.gouv.fr/"
26
+ end
27
+
28
+ def info_link_label
29
+ use_plus_version? ? "Qu’est-ce que FranceConnect+ ?" : "Qu’est-ce que FranceConnect ?"
30
+ end
31
+
32
+ def button_attributes
33
+ default_button_attributes
34
+ .deep_merge_html_attributes(button_overrides)
35
+ end
36
+
37
+ def default_button_attributes
38
+ {
39
+ method: :post,
40
+ remote: false,
41
+ class: use_plus_version? ? "fr-connect fr-connect--plus" : "fr-connect",
42
+ data: { turbo: false }
43
+ }
44
+ end
45
+
46
+ def default_attributes
47
+ { class: "fr-connect-group" }
48
+ end
49
+ end
50
+ end
@@ -5,6 +5,6 @@
5
5
  <% end %>
6
6
 
7
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" %>
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
9
  </p>
10
10
  <% end %>
@@ -24,7 +24,7 @@ module DsfrComponent
24
24
  {
25
25
  method: :post,
26
26
  remote: false,
27
- class: "fr-connect fr-proconnect",
27
+ class: "fr-connect fr-connect--pro",
28
28
  data: { turbo: false }
29
29
  }
30
30
  end
@@ -22,6 +22,7 @@ module DsfrComponentsHelper
22
22
  dsfr_notice: 'DsfrComponent::NoticeComponent',
23
23
  dsfr_search: 'DsfrComponent::SearchComponent',
24
24
  dsfr_proconnect_button: 'DsfrComponent::ProconnectButtonComponent',
25
+ dsfr_france_connect_button: 'DsfrComponent::FranceConnectButtonComponent',
25
26
  dsfr_side_menu: 'DsfrComponent::SideMenuComponent',
26
27
  dsfr_side_menu_item: 'DsfrComponent::SideMenuComponent::ItemComponent',
27
28
  dsfr_card: 'DsfrComponent::CardComponent',
@@ -52,12 +52,9 @@ private
52
52
  end
53
53
 
54
54
  def add_size(opts)
55
- size = opts['size']
55
+ size = opts.delete(:size)
56
56
 
57
- if size.present? && size.in?(SIZES)
58
- opts = inject_class(opts, class_name: "fr-link--#{size}")
59
- opts.delete(:size)
60
- end
57
+ opts = inject_class(opts, class_name: "fr-link--#{size}") if size.present? && size.to_s.in?(SIZES)
61
58
 
62
59
  opts
63
60
  end
@@ -1,5 +1,5 @@
1
1
  module Dsfr
2
2
  module Components
3
- VERSION = '5.0.2'.freeze
3
+ VERSION = '5.1.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsfr-view-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BetaGouv developers
@@ -41,20 +41,14 @@ dependencies:
41
41
  name: dsfr-assets
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 1.13.2
47
- - - "<"
44
+ - - "~>"
48
45
  - !ruby/object:Gem::Version
49
46
  version: '1.15'
50
47
  type: :runtime
51
48
  prerelease: false
52
49
  version_requirements: !ruby/object:Gem::Requirement
53
50
  requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 1.13.2
57
- - - "<"
51
+ - - "~>"
58
52
  - !ruby/object:Gem::Version
59
53
  version: '1.15'
60
54
  - !ruby/object:Gem::Dependency
@@ -131,16 +125,16 @@ dependencies:
131
125
  name: rubocop
132
126
  requirement: !ruby/object:Gem::Requirement
133
127
  requirements:
134
- - - ">="
128
+ - - "~>"
135
129
  - !ruby/object:Gem::Version
136
- version: '0'
130
+ version: '1.90'
137
131
  type: :development
138
132
  prerelease: false
139
133
  version_requirements: !ruby/object:Gem::Requirement
140
134
  requirements:
141
- - - ">="
135
+ - - "~>"
142
136
  - !ruby/object:Gem::Version
143
- version: '0'
137
+ version: '1.90'
144
138
  - !ruby/object:Gem::Dependency
145
139
  name: simplecov
146
140
  requirement: !ruby/object:Gem::Requirement
@@ -349,6 +343,8 @@ files:
349
343
  - app/components/dsfr_component/callout_component.rb
350
344
  - app/components/dsfr_component/card_component.html.erb
351
345
  - app/components/dsfr_component/card_component.rb
346
+ - app/components/dsfr_component/france_connect_button_component.html.erb
347
+ - app/components/dsfr_component/france_connect_button_component.rb
352
348
  - app/components/dsfr_component/header_component.html.erb
353
349
  - app/components/dsfr_component/header_component.rb
354
350
  - app/components/dsfr_component/header_component/direct_link_component.rb