dsfr-view-components 3.0.0 → 3.0.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: e5815a12f80af799bc086b67e9d0c5f601755542dd3784a834e39558f428956c
4
- data.tar.gz: 06f9c84f220447f51ced27871923d56cafd912b5e8ef8733f506526cddc6a4cd
3
+ metadata.gz: 8780041bae859ed3e40f83a06d62b0cbec970d9d7e1e6d29a40d2b2a6b1f1f3b
4
+ data.tar.gz: 300b8e5270fc91042b0e915b29cf477a9c4b7f1c609173856b7a9518c5c14d5b
5
5
  SHA512:
6
- metadata.gz: 7b884689f0a1daf9ed7d0de985a9c797e346b6cccf2e1cf650d28f85a6cfda0cdb82227c1197c71c358368d02ac2c19c3efc0a46c7ac93ceb788bfd420dfc703
7
- data.tar.gz: d8b63603599758abfc83fb404dd37290fb049ae94ae9803f6ac23a344669550349e67d7d3de1d0e1b70c7d0d063d428045a5d032deb5073c62ca1ef6408b1284
6
+ metadata.gz: 914f18a7ced8fdebc65797384cba976c8ed9586ba521b54020041e3a6c7653f6eb7ffca61c98bf4246564c0d2a4cecfce9f66fb404f8819c14232e53be4acb63
7
+ data.tar.gz: 0f528525221c610318711fd2b7cb505e23f4a47d771137dd4d80ce8abbaff1b790c9e188c4beed20b5e02e42c87b95b472547bda7d3ecead11f36ca42b8e236f
@@ -7,7 +7,7 @@ module DsfrComponent
7
7
  renders_one :action_zone
8
8
 
9
9
  # @param title [String] Le titre de la mise en avant
10
- # @param icon_name [String] Le nom de l’icône à afficher (exemple `arrow-right-line`) (optionnel)
10
+ # @param icon_name [String] Le nom de l’icône à afficher (exemple `arrow-right-line`), ou `:none` pour la désactiver (optionnel)
11
11
  # @param starting_header_level [Integer] Le niveau de titre (optionnel)
12
12
  def initialize(
13
13
  title:,
@@ -32,10 +32,14 @@ module DsfrComponent
32
32
  end
33
33
  end
34
34
 
35
- private
35
+ private
36
36
 
37
37
  def default_attributes
38
- { class: "fr-callout fr-icon-#{@icon_name}" }
38
+ classes = ["fr-callout"]
39
+
40
+ classes.push("fr-icon-#{@icon_name}") unless @icon_name == :none
41
+
42
+ { class: classes.join(" ") }
39
43
  end
40
44
  end
41
45
  end
@@ -2,19 +2,20 @@ module DsfrComponent
2
2
  class HighlightComponent < DsfrComponent::Base
3
3
  # @param text [String] Le contenu textuel du composant
4
4
  # @param size [Symbol] La taille de la mise en exergue
5
- def initialize(text:, size: :md, html_attributes: {})
5
+ def initialize(text: nil, size: :md, html_attributes: {})
6
6
  @text = text
7
7
  @size = size
8
8
 
9
- raise ArgumentError if not SIZES.include?(size)
10
-
11
9
  super(html_attributes: html_attributes)
12
10
  end
13
11
 
14
12
  def call
13
+ raise(ArgumentError, "You must provide either a text param or some block content") if no_content?
14
+ raise(ArgumentError, "Size '#{size}' is not allowed; possible values are #{SIZES}") if SIZES.exclude?(size)
15
+
15
16
  tag.div(**html_attributes) do
16
17
  tag.p(class: "fr-text--#{@size}") do
17
- @text
18
+ @text || content
18
19
  end
19
20
  end
20
21
  end
@@ -26,5 +27,9 @@ module DsfrComponent
26
27
  def default_attributes
27
28
  { class: 'fr-highlight' }
28
29
  end
30
+
31
+ def no_content?
32
+ text.blank? && !content?
33
+ end
29
34
  end
30
35
  end
@@ -1,5 +1,5 @@
1
1
  module Dsfr
2
2
  module Components
3
- VERSION = '3.0.0'.freeze
3
+ VERSION = '3.0.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.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - BetaGouv developers
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-24 00:00:00.000000000 Z
10
+ date: 2025-05-07 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: html-attributes-utils