dsfr-view-components 5.0.1 → 5.0.2
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 +4 -4
- data/app/components/dsfr_component/badge_component.rb +21 -4
- data/lib/dsfr/components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aab49185db5dee4de6e32f79d10a3dd6866ad6d23b8876ecc97bd6f4305e0a12
|
|
4
|
+
data.tar.gz: 7af84ab6aa6fe038867c1100bfd8daa190ee82e56f43c75af0b377e28b5a1717
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9b187588c9246ae6f6c45363b50dc1d329d78a9d3b658ce413e6e40c94eff16793bc669dada0caecc8586c6f2e211f366839c40a816d0a789f4b12a4ba79150
|
|
7
|
+
data.tar.gz: 6a7317e0de48d0c434252284f6fb8c9e6fbf4accfb56beb79216f5544a88e954ec6930a7ca57a4f8aba1f35d8b09ce89592873c9b9526668102a24532cd16508
|
|
@@ -1,12 +1,15 @@
|
|
|
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
|
|
7
|
-
|
|
7
|
+
def initialize(status: nil, size: :md, html_attributes: {})
|
|
8
|
+
validate_status!(status)
|
|
9
|
+
validate_size!(size)
|
|
8
10
|
|
|
9
11
|
@status = status
|
|
12
|
+
@size = size
|
|
10
13
|
|
|
11
14
|
super(html_attributes: html_attributes)
|
|
12
15
|
end
|
|
@@ -19,10 +22,24 @@ module DsfrComponent
|
|
|
19
22
|
|
|
20
23
|
private
|
|
21
24
|
|
|
22
|
-
attr_reader :status
|
|
25
|
+
attr_reader :status, :size
|
|
23
26
|
|
|
24
27
|
def default_attributes
|
|
25
|
-
{
|
|
28
|
+
{
|
|
29
|
+
class: class_names(
|
|
30
|
+
'fr-badge',
|
|
31
|
+
"fr-badge--#{status}" => status.present?,
|
|
32
|
+
"fr-badge--sm" => size == :sm
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def validate_status!(status)
|
|
38
|
+
raise(ArgumentError, "`status` should be one of #{STATUSES}") if status.present? && !STATUSES.include?(status)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def validate_size!(size)
|
|
42
|
+
raise(ArgumentError, "`size` should be one of #{SIZES} (received: `#{status}`") if !SIZES.include?(size)
|
|
26
43
|
end
|
|
27
44
|
end
|
|
28
45
|
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.
|
|
4
|
+
version: 5.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- BetaGouv developers
|
|
@@ -420,7 +420,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
420
420
|
- !ruby/object:Gem::Version
|
|
421
421
|
version: '0'
|
|
422
422
|
requirements: []
|
|
423
|
-
rubygems_version: 4.0.
|
|
423
|
+
rubygems_version: 4.0.10
|
|
424
424
|
specification_version: 4
|
|
425
425
|
summary: Composants ViewComponent pour le Système de Design de l'État (DSFR)
|
|
426
426
|
test_files: []
|