dsfr-view-components 5.0.1 → 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: 5095d1305a3f94fe5a01ee178af11833e291ad6ec0119b59e94b9170ee0acb0b
4
- data.tar.gz: acf69b43c9330f356754a8592772287b5b2bdeb0db174cba46f5e2a35f780144
3
+ metadata.gz: 21e22399b4567acc732e6e9342628199bcb79a955e62d290e61ceb38155b5e35
4
+ data.tar.gz: 057c755a202b248f06db84e28dc4610a11ebf2b64b9c4cf1e8fd69dbc3948707
5
5
  SHA512:
6
- metadata.gz: 773981869125a91a17f51f3bcef476a59777e328157d0142ebff7ec0d54e4029a5922b5e987032ec34be0dce70bc54b5418bbb3ddb31ffeb72bc4c41e2e5b970
7
- data.tar.gz: 1df1573b2231bb50d66c58e3e04adf1d4ba3f51ed21792810f0018e159d72ffd6a2fb5f1cea6c9beaebb20eb40ef07e8ecbd943aed2e568840457c21c76f982d
6
+ metadata.gz: 925d4e06a574a2a2a682a0d0f3e742323aed826d830055497084a293dd79d745ce4200c8a88776aaa81ae51930686e529a32e537125fc3134ed80ca570faa63b
7
+ data.tar.gz: bf238c5a514fb9a4672928235b70b53bc2a57fc76fceb24c50d25540b56239ed62429bc42e670baf4bf4b426a8693b9e9fe5b7b733119c6c28db4ba7d23f2992
@@ -1,28 +1,56 @@
1
1
  module DsfrComponent
2
2
  class BadgeComponent < DsfrComponent::Base
3
3
  STATUSES = %i[success error info warning new].freeze
4
+ SIZES = %i[md sm].freeze
4
5
 
5
6
  # @param status [BadgeComponent::STATUSES]
6
- def initialize(status:, html_attributes: {})
7
- raise(ArgumentError, "`status` should be one of #{STATUSES}") unless STATUSES.include?(status)
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: {})
11
+ validate_status!(status)
12
+ validate_size!(size)
13
+ validate_has_icon!(has_icon, status)
8
14
 
9
15
  @status = status
16
+ @size = size
17
+ @has_icon = has_icon
18
+ @ellipsis = ellipsis
10
19
 
11
20
  super(html_attributes: html_attributes)
12
21
  end
13
22
 
14
23
  def call
15
- tag.div(**html_attributes) do
16
- content
24
+ tag.p(**html_attributes) do
25
+ ellipsis ? tag.span(content, class: 'fr-ellipsis') : content
17
26
  end
18
27
  end
19
28
 
20
29
  private
21
30
 
22
- attr_reader :status
31
+ attr_reader :status, :size, :has_icon, :ellipsis
23
32
 
24
33
  def default_attributes
25
- { class: ['fr-badge', "fr-badge--#{status}"] }
34
+ {
35
+ class: class_names(
36
+ 'fr-badge',
37
+ "fr-badge--#{status}" => status.present?,
38
+ "fr-badge--sm" => size == :sm,
39
+ "fr-badge--no-icon" => !has_icon
40
+ )
41
+ }
42
+ end
43
+
44
+ def validate_status!(status)
45
+ raise(ArgumentError, "`status` should be one of #{STATUSES}") if status.present? && !STATUSES.include?(status)
46
+ end
47
+
48
+ def validate_size!(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?
26
54
  end
27
55
  end
28
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.1'.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.1
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
@@ -420,7 +416,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
420
416
  - !ruby/object:Gem::Version
421
417
  version: '0'
422
418
  requirements: []
423
- rubygems_version: 4.0.6
419
+ rubygems_version: 4.0.10
424
420
  specification_version: 4
425
421
  summary: Composants ViewComponent pour le Système de Design de l'État (DSFR)
426
422
  test_files: []