dsfr-view-components 2.0.1 → 2.1.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 +4 -4
- data/README.md +3 -3
- data/app/components/dsfr_component/accordion_component/section_component.html.erb +5 -5
- data/app/components/dsfr_component/accordion_component/section_component.rb +10 -2
- data/app/components/dsfr_component/accordion_component.rb +8 -1
- data/app/components/dsfr_component/base.rb +2 -0
- data/app/components/dsfr_component/highlight_component.rb +30 -0
- data/app/components/dsfr_component/skiplink_component.html.erb +11 -0
- data/app/components/dsfr_component/skiplink_component.rb +20 -0
- data/app/helpers/dsfr_components_helper.rb +2 -0
- data/lib/dsfr/components/version.rb +1 -1
- data/lib/dsfr/components.rb +0 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fd43d49e7920aa1ae37d143b9503c68b1d44aad46e5a3acde610b7a0ae9da96
|
4
|
+
data.tar.gz: b3a7d11b90ff73cad4023f517bd3d567141648e25cdf200b1204daf2dcde8db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4508aef35cb1afd72ca39df0e89c74290f8a4f9ebfe47c8ff2b7ce8fbcb4fba3ff2d647ecfcc41eb585b515ef378716496c1355e917d2a7b59fc38ba3faa93a5
|
7
|
+
data.tar.gz: f9391b2ef8ddfcdd985305d823ded7fb73add4d05eb05c8be8d30cec1a7cdf2d07b6d1df44bbd5ae18a609b5fb7d9934b54c192715449321ff2493638919f570
|
data/README.md
CHANGED
@@ -25,6 +25,8 @@ Pour utiliser cette gem dans votre application Rails, il faut ajouter cette lign
|
|
25
25
|
require "dsfr/components"
|
26
26
|
```
|
27
27
|
|
28
|
+
**NOTE:** depuis la version 2.1, la gem dépend de [`dsfr-assets`](https://github.com/betagouv/dsfr-assets) qui embarque les assets du DSFR pour vous. Pour laisser au temps aux équipes de vérifier cette intégration, l'inclusion des assets est optionnelle mais peut se faire en suivant [les instructions dans le README de dsfr-assets](https://github.com/betagouv/dsfr-assets?tab=readme-ov-file#installation).
|
29
|
+
|
28
30
|
## Composants disponibles
|
29
31
|
|
30
32
|
Cette gem a pour but de supporter tous les composants proposés par le Design Système de l'État hormis ceux concernant les formulaires. Ceux-ci seront fournis dans une gem indépendante dans le futur.
|
@@ -75,12 +77,11 @@ Utilisez le générateur pour créer un nouveau composant :
|
|
75
77
|
bin/rails g dsfr_component FancyButton --params title:String count:Integer
|
76
78
|
```
|
77
79
|
|
78
|
-
|
79
80
|
Lancer la dummy app pour itérer sur les composants :
|
80
81
|
|
81
82
|
```sh
|
82
83
|
cd spec/dummy
|
83
|
-
bundle install
|
84
|
+
bundle install
|
84
85
|
bundle exec rails server
|
85
86
|
```
|
86
87
|
|
@@ -90,7 +91,6 @@ Déployer une nouvelle version de la gem :
|
|
90
91
|
VERSION=1.3.2 make deploy_gem
|
91
92
|
```
|
92
93
|
|
93
|
-
|
94
94
|
## Licence
|
95
95
|
|
96
96
|
Le code source et la gem sont ouverts sous la licence [MIT](https://opensource.org/licenses/MIT).
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<%= tag.section(**html_attributes) do %>
|
2
|
-
|
2
|
+
<%= tag.send("h#{starting_header_level}", class: "fr-accordion__title") do %>
|
3
3
|
<button
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class="fr-accordion__btn"
|
5
|
+
aria-expanded="<%= expanded? ? "true" : "false" %>"
|
6
|
+
aria-controls="<%= id %>"
|
7
7
|
>
|
8
8
|
<%= title %>
|
9
9
|
</button>
|
10
|
-
|
10
|
+
<% end %>
|
11
11
|
<div
|
12
12
|
id="<%= id %>"
|
13
13
|
class="fr-collapse <%= "fr-collapse--expanded" if expanded? %>"
|
@@ -1,15 +1,23 @@
|
|
1
1
|
class DsfrComponent::AccordionComponent::SectionComponent < DsfrComponent::Base
|
2
|
-
attr_reader :title, :expanded
|
2
|
+
attr_reader :title, :expanded, :starting_header_level
|
3
3
|
|
4
4
|
alias_method :expanded?, :expanded
|
5
5
|
|
6
6
|
# @param title [String] section title
|
7
7
|
# @param expanded [Boolean] toggles section folding
|
8
8
|
# @param id [String] the HTML id, optional if you want to reuse the anchor
|
9
|
-
def initialize(
|
9
|
+
def initialize(
|
10
|
+
title:,
|
11
|
+
starting_header_level:,
|
12
|
+
expanded: false,
|
13
|
+
id: nil,
|
14
|
+
classes: [],
|
15
|
+
html_attributes: {}
|
16
|
+
)
|
10
17
|
@title = title
|
11
18
|
@expanded = expanded
|
12
19
|
@id = id
|
20
|
+
@starting_header_level = starting_header_level
|
13
21
|
|
14
22
|
super(classes: classes, html_attributes: html_attributes)
|
15
23
|
end
|
@@ -1,4 +1,8 @@
|
|
1
1
|
class DsfrComponent::AccordionComponent < DsfrComponent::Base
|
2
|
+
DEFAULT_HEADER_LEVEL = 3
|
3
|
+
|
4
|
+
attr_reader :starting_header_level
|
5
|
+
|
2
6
|
renders_many :sections, ->(title: nil, expanded: false, id: nil, classes: [], html_attributes: {}, &block) do
|
3
7
|
DsfrComponent::AccordionComponent::SectionComponent.new(
|
4
8
|
classes: classes,
|
@@ -6,11 +10,14 @@ class DsfrComponent::AccordionComponent < DsfrComponent::Base
|
|
6
10
|
html_attributes: html_attributes,
|
7
11
|
title: title,
|
8
12
|
id: id,
|
13
|
+
starting_header_level: starting_header_level,
|
9
14
|
&block
|
10
15
|
)
|
11
16
|
end
|
12
17
|
|
13
|
-
def initialize(classes: [], html_attributes: {})
|
18
|
+
def initialize(classes: [], html_attributes: {}, starting_header_level: DEFAULT_HEADER_LEVEL)
|
19
|
+
@starting_header_level = starting_header_level
|
20
|
+
|
14
21
|
super(classes: classes, html_attributes: html_attributes)
|
15
22
|
end
|
16
23
|
|
@@ -7,6 +7,8 @@ class DsfrComponent::Base < ViewComponent::Base
|
|
7
7
|
|
8
8
|
HEADING_LEVELS = [1, 2, 3, 4, 5, 6].freeze
|
9
9
|
|
10
|
+
SIZES = %i[sm md lg].freeze
|
11
|
+
|
10
12
|
def initialize(classes:, html_attributes:)
|
11
13
|
if classes.nil?
|
12
14
|
Rails.logger.warn("classes is nil, if no custom classes are needed omit the param")
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module DsfrComponent
|
2
|
+
class HighlightComponent < DsfrComponent::Base
|
3
|
+
# @param text [String] Le contenu textuel du composant
|
4
|
+
# @param size [Symbol] La taille de la mise en exergue
|
5
|
+
def initialize(text:, size: :md, classes: [], html_attributes: {})
|
6
|
+
@text = text
|
7
|
+
@size = size
|
8
|
+
|
9
|
+
raise ArgumentError if not SIZES.include?(size)
|
10
|
+
|
11
|
+
super(classes: classes, html_attributes: html_attributes)
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
tag.div(**html_attributes) do
|
16
|
+
tag.p(class: "fr-text--#{@size}") do
|
17
|
+
@text
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :text, :size
|
25
|
+
|
26
|
+
def default_attributes
|
27
|
+
{ class: 'fr-highlight' }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DsfrComponent
|
2
|
+
class SkiplinkComponent < DsfrComponent::Base
|
3
|
+
# @param label [String] le texte utilisé pour le aria-label de la nav qui affiche les liens d’évitement (par exemple « Accès rapide »)
|
4
|
+
# @param links [Array] liste de liens HTML
|
5
|
+
def initialize(label:, links:, classes: [], html_attributes: {})
|
6
|
+
@label = label
|
7
|
+
@links = links
|
8
|
+
|
9
|
+
super(classes: classes, html_attributes: html_attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :label, :links
|
15
|
+
|
16
|
+
def default_attributes
|
17
|
+
{ class: 'fr-skiplinks' }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -16,6 +16,8 @@ module DsfrComponentsHelper
|
|
16
16
|
dsfr_header_direct_link: 'DsfrComponent::HeaderComponent::DirectLinkComponent',
|
17
17
|
dsfr_header_direct_dropdown_link: 'DsfrComponent::HeaderComponent::DirectLinkDropdownComponent',
|
18
18
|
dsfr_tabs: 'DsfrComponent::TabsComponent',
|
19
|
+
dsfr_highlight: 'DsfrComponent::HighlightComponent',
|
20
|
+
dsfr_skiplink: 'DsfrComponent::SkiplinkComponent',
|
19
21
|
# DO NOT REMOVE: new component mapping here
|
20
22
|
}.freeze
|
21
23
|
HELPER_NAME_TO_CLASS_NAME.each do |name, klass|
|
data/lib/dsfr/components.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsfr-view-components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BetaGouv developers
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-02-03 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: html-attributes-utils
|
@@ -25,33 +24,33 @@ dependencies:
|
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '1'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
27
|
+
name: view_component
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
32
|
+
version: '3'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
39
|
+
version: '3'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
41
|
+
name: dsfr-assets
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
46
|
+
version: '1.13'
|
48
47
|
type: :runtime
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
53
|
+
version: '1.13'
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: deep_merge
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -375,8 +374,11 @@ files:
|
|
375
374
|
- app/components/dsfr_component/header_component/direct_link_dropdown_component.rb
|
376
375
|
- app/components/dsfr_component/header_component/operator_image_component.rb
|
377
376
|
- app/components/dsfr_component/header_component/tool_link_component.rb
|
377
|
+
- app/components/dsfr_component/highlight_component.rb
|
378
378
|
- app/components/dsfr_component/modal_component.html.erb
|
379
379
|
- app/components/dsfr_component/modal_component.rb
|
380
|
+
- app/components/dsfr_component/skiplink_component.html.erb
|
381
|
+
- app/components/dsfr_component/skiplink_component.rb
|
380
382
|
- app/components/dsfr_component/stepper_component.html.erb
|
381
383
|
- app/components/dsfr_component/stepper_component.rb
|
382
384
|
- app/components/dsfr_component/tabs_component.html.erb
|
@@ -408,7 +410,6 @@ licenses:
|
|
408
410
|
- MIT
|
409
411
|
metadata:
|
410
412
|
rubygems_mfa_required: 'true'
|
411
|
-
post_install_message:
|
412
413
|
rdoc_options: []
|
413
414
|
require_paths:
|
414
415
|
- lib
|
@@ -423,8 +424,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
423
424
|
- !ruby/object:Gem::Version
|
424
425
|
version: '0'
|
425
426
|
requirements: []
|
426
|
-
rubygems_version: 3.
|
427
|
-
signing_key:
|
427
|
+
rubygems_version: 3.6.2
|
428
428
|
specification_version: 4
|
429
429
|
summary: Composants ViewComponent pour le Système de Design de l'État (DSFR)
|
430
430
|
test_files: []
|