dsfr-view-components 0.2.1 → 0.4.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: 26127e695550fca9861568104cb2e15f13f81c77d8ab97788db823215bdcd43e
4
- data.tar.gz: 90059e2796a0b0e63f6fed13bb9183866dd01ec796d190e342fd9f458d5a1bdf
3
+ metadata.gz: ef54774bdcf1ad2c6169da53867dc97bc45ee11759826a6892bde1f48d8d3928
4
+ data.tar.gz: 3fea1dab55f0be17c46214bd45c1cf93f9c0cd967d8b27a754a8c7dda9db46c8
5
5
  SHA512:
6
- metadata.gz: f14bbd9482cf8dfa9473d024c388a30db71225c31fcee52bf69d2dfed43802892dc3cfb56e21f1273d187378cf0e905e801ed9092958839ed3ec9329fc58ece9
7
- data.tar.gz: 30e838fb64e6e0fb1fb11adea4967aaf4cdeed2fc8763d8e46ffe4823f1e3a98c4512e974a001e86fcefe47b113dec303e49e3e7e4517727098edda9439c498f
6
+ metadata.gz: e82dac0aecf55ef15275bab28fc97dd345b22911292b451d5f5a390d4c99f8169708b1261a52db629cca7b1c59c420632f9b1e67ae829c75f52c6328b13eb488
7
+ data.tar.gz: ba573c5bf3ce60a132be6155047435fd32f98f0d55309269a1f37704e361154a100117746c978c80c70a8c1ab42580959d0ced78ee6a12a4e8ed2542fca47e3a
data/README.md CHANGED
@@ -13,19 +13,6 @@ Cette gem fournit des composants pour le Design Système de l'État (DSFR) en s'
13
13
 
14
14
  C'est un fork de [govuk-components](https://github.com/DFE-Digital/govuk-components) qui propose l'équivalent pour le GOV.UK Design System.
15
15
 
16
-
17
- ## Développement en cours ⚠️
18
-
19
- Cette gem est en cours de développement et n'est pas encore
20
- recommandée pour un usage en production.
21
-
22
- N'hésitez pas à contribuer pour nous aider à avancer, un générateur de
23
- composant est même fourni pour vous faciliter la tâche :
24
-
25
- ```sh
26
- bin/rails g dsfr_component FancyButton --params title:String count:Integer
27
- ```
28
-
29
16
  ## Documentation
30
17
 
31
18
  Un [guide complet est disponible](https://betagouv.github.io/dsfr-view-components/). Il contient des instructions pour l'installation et l'usage de cette gem. Les exemples présents éxecutent le code et seront donc toujours à jour.
@@ -42,44 +29,7 @@ require "dsfr/components"
42
29
 
43
30
  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.
44
31
 
45
- 10/36 composants sont disponibles :
46
-
47
- - [x] Accordéon - Accordion
48
- - [x] Alertes - Alert
49
- - [x] Badge
50
- - [ ] Bandeau d'information importante
51
- - [ ] Barre de recherche - Search bar
52
- - [x] Boutons - Buttons
53
- - [ ] Groupe de bouton
54
- - [ ] Bouton FranceConnect
55
- - [ ] Cartes - Cards
56
- - [ ] Citation - Quote
57
- - [ ] Contenu médias - Responsive médias
58
- - [x] En-tête - Header
59
- - [ ] Fil d'Ariane - Breadcrumb
60
- - [ ] Gestionnaire de consentement - Consent banner
61
- - [ ] Icônes de favoris - Favicons
62
- - [x] Indicateur d'étape - Stepper
63
- - [ ] Interrupteur - Toggle switch
64
- - [ ] Lettre d'information et réseaux sociaux - Newsletter & Follow us
65
- - [x] Liens - Links
66
- - [ ] Liens d'évitement - Skiplinks
67
- - [ ] Menu latéral - Side menu
68
- - [ ] Mise en avant - Call out
69
- - [ ] Mise en exergue - Highlight
70
- - [x] Modale - Modal
71
- - [ ] Navigation principale - Main navigation
72
- - [ ] Onglets - Tabs
73
- - [ ] Pagination
74
- - [ ] Paramètres d'affichage - Display
75
- - [ ] Partage - Share
76
- - [ ] Pied de page - Footer
77
- - [ ] Sélecteur de langue
78
- - [ ] Sommaire - Summary
79
- - [ ] Tableau - Table
80
- - [x] Tag
81
- - [ ] Téléchargement de fichier
82
- - [x] Tuile - Tile
32
+ La [liste des composants implémentés ou restants est consultable grâce au label `composant`](https://github.com/betagouv/dsfr-view-components/issues?page=2&q=is%3Aissue+label%3Acomposant) sur ce même dépôt.
83
33
 
84
34
  <!--
85
35
  This library also provides helpers for creating [links](https://govuk-components.netlify.app/helpers/link),
@@ -108,6 +58,7 @@ bundle exec rspec spec
108
58
  ```
109
59
 
110
60
  Pour développer avec les tests en continu :
61
+
111
62
  ```sh
112
63
  bundle exec guard
113
64
  ```
@@ -118,6 +69,13 @@ Lancer le guide de documentation :
118
69
  make watch-guide
119
70
  ```
120
71
 
72
+ Utilisez le générateur pour créer un nouveau composant :
73
+
74
+ ```sh
75
+ bin/rails g dsfr_component FancyButton --params title:String count:Integer
76
+ ```
77
+
78
+
121
79
  Lancer la dummy app pour itérer sur les composants :
122
80
 
123
81
  ```sh
@@ -0,0 +1,17 @@
1
+ <%= tag.nav(**html_attributes) do %>
2
+ <button
3
+ class="fr-breadcrumb__button"
4
+ aria-expanded="false"
5
+ aria-controls="breadcrumbs">
6
+ Voir le fil d’Ariane
7
+ </button>
8
+ <div class="fr-collapse" id="breadcrumbs">
9
+ <ol class="fr-breadcrumb__list">
10
+ <% breadcrumbs.each do |crumb| %>
11
+ <li>
12
+ <%= crumb %>
13
+ </li>
14
+ <% end %>
15
+ </ol>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,25 @@
1
+ class DsfrComponent::BreadcrumbsComponent < DsfrComponent::Base
2
+ renders_many :breadcrumbs, ->(label:, href: nil) do
3
+ attributes = if href.nil?
4
+ { aria: { current: true } }
5
+ else
6
+ { href: href }
7
+ end
8
+
9
+ content_tag(:a, class: 'fr-breadcrumb__link', **attributes) { label }
10
+ end
11
+
12
+ def initialize(classes: [], html_attributes: {})
13
+ super(classes: classes, html_attributes: html_attributes)
14
+ end
15
+
16
+ private
17
+
18
+ def default_attributes
19
+ {
20
+ class: 'fr-breadcrumb',
21
+ aria: { label: 'vous êtes ici :' },
22
+ role: "navigation"
23
+ }
24
+ end
25
+ end
@@ -0,0 +1,58 @@
1
+ class DsfrComponent::TabsComponent::TabComponent < DsfrComponent::Base
2
+ # @param title [String] Le titre de l’onglet affiché dans la barre d’onglets
3
+ # @param active [Boolean] Définit si l’onglet est actif ou non
4
+ # @param path [String] (optionnel) chemin vers lequel l’onglet pointe, utilisable avec Turbo Drive, transforme le bouton en lien, avec une turbo action `advance`
5
+ # @param icon [String] (optionnel) icône affichée à gauche du titre de l’onglet (sans le préfixe `fr-icon-`)
6
+ def initialize(title:, active: false, path: nil, icon: nil, classes: [], html_attributes: {})
7
+ @title = title
8
+ @active = active
9
+ @path = path
10
+ @icon = icon
11
+
12
+ super(classes: classes, html_attributes: html_attributes)
13
+ end
14
+
15
+ def nav_id
16
+ @nav_id ||= "tab-#{title_slug}-nav"
17
+ end
18
+
19
+ def panel_id
20
+ @panel_id ||= "tab-#{title_slug}-panel"
21
+ end
22
+
23
+ def nav_item
24
+ path ? nav_link : nav_button
25
+ end
26
+
27
+ def call
28
+ tag.div(**html_attributes) { content }
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :title, :active, :path, :icon
34
+
35
+ def default_attributes
36
+ classes = ['fr-tabs__panel']
37
+ classes << "fr-tabs__panel--selected" if active
38
+ { id: panel_id, class: classes, role: 'tabpanel', "aria-labelledby": nav_id }
39
+ end
40
+
41
+ def title_slug
42
+ @title_slug ||= title.parameterize
43
+ end
44
+
45
+ def nav_button
46
+ tag.button(title, **nav_html_attributes)
47
+ end
48
+
49
+ def nav_link
50
+ tag.a(title, href: path, data: { turbo_action: "advance" }, **nav_html_attributes)
51
+ end
52
+
53
+ def nav_html_attributes
54
+ classes = ["fr-tabs__tab"]
55
+ classes += ["fr-icon-#{icon}", "fr-tabs__tab--icon-left"] if icon.present?
56
+ { id: nav_id, class: classes, role: 'tab', "aria-selected": active ? "true" : "false", "aria-controls": panel_id }
57
+ end
58
+ end
@@ -0,0 +1,12 @@
1
+ <%= tag.div(**html_attributes) do %>
2
+ <ul class="fr-tabs__list" role="tablist" aria-label="<%= label %>">
3
+ <% tabs.each do |tab| %>
4
+ <li role="presentation">
5
+ <%= tab.nav_item %>
6
+ </li>
7
+ <% end %>
8
+ </ul>
9
+ <% tabs.each do |tab| %>
10
+ <%= tab %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,19 @@
1
+ class DsfrComponent::TabsComponent < DsfrComponent::Base
2
+ renders_many :tabs, "DsfrComponent::TabsComponent::TabComponent"
3
+
4
+ # @param label [String] Le nom du système d’onglets, sera uniquement affiché comme aria-label (optionnel)
5
+ def initialize(label: nil, classes: [], html_attributes: {})
6
+ @label = label
7
+ @tabs = []
8
+
9
+ super(classes: classes, html_attributes: html_attributes)
10
+ end
11
+
12
+ private
13
+
14
+ attr_reader :label
15
+
16
+ def default_attributes
17
+ { class: 'fr-tabs' }
18
+ end
19
+ end
@@ -4,6 +4,7 @@ module DsfrComponentsHelper
4
4
  dsfr_alert: 'DsfrComponent::AlertComponent',
5
5
  dsfr_accordion: 'DsfrComponent::AccordionComponent',
6
6
  dsfr_accordion_section: 'DsfrComponent::AccordionComponent::SectionComponent',
7
+ dsfr_breadcrumbs: 'DsfrComponent::BreadcrumbsComponent',
7
8
  dsfr_tile: 'DsfrComponent::TileComponent',
8
9
  dsfr_badge: 'DsfrComponent::BadgeComponent',
9
10
  dsfr_tag: 'DsfrComponent::TagComponent',
@@ -14,6 +15,7 @@ module DsfrComponentsHelper
14
15
  dsfr_header_tool_link: 'DsfrComponent::HeaderComponent::ToolLinkComponent',
15
16
  dsfr_header_direct_link: 'DsfrComponent::HeaderComponent::DirectLinkComponent',
16
17
  dsfr_header_direct_dropdown_link: 'DsfrComponent::HeaderComponent::DirectLinkDropdownComponent',
18
+ dsfr_tabs: 'DsfrComponent::TabsComponent',
17
19
  # DO NOT REMOVE: new component mapping here
18
20
  }.freeze
19
21
  HELPER_NAME_TO_CLASS_NAME.each do |name, klass|
@@ -1,5 +1,5 @@
1
1
  module Dsfr
2
2
  module Components
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsfr-view-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BetaGouv developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-17 00:00:00.000000000 Z
11
+ date: 2023-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: actionpack
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '6.1'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '6.1'
27
- - !ruby/object:Gem::Dependency
28
- name: activemodel
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '6.1'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '6.1'
41
- - !ruby/object:Gem::Dependency
42
- name: railties
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '6.1'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '6.1'
55
13
  - !ruby/object:Gem::Dependency
56
14
  name: html-attributes-utils
57
15
  requirement: !ruby/object:Gem::Requirement
@@ -451,6 +409,8 @@ files:
451
409
  - app/components/dsfr_component/alert_component.rb
452
410
  - app/components/dsfr_component/badge_component.rb
453
411
  - app/components/dsfr_component/base.rb
412
+ - app/components/dsfr_component/breadcrumbs_component.html.erb
413
+ - app/components/dsfr_component/breadcrumbs_component.rb
454
414
  - app/components/dsfr_component/button_component.rb
455
415
  - app/components/dsfr_component/header_component.html.erb
456
416
  - app/components/dsfr_component/header_component.rb
@@ -461,6 +421,9 @@ files:
461
421
  - app/components/dsfr_component/modal_component.rb
462
422
  - app/components/dsfr_component/stepper_component.html.erb
463
423
  - app/components/dsfr_component/stepper_component.rb
424
+ - app/components/dsfr_component/tabs_component.html.erb
425
+ - app/components/dsfr_component/tabs_component.rb
426
+ - app/components/dsfr_component/tabs_component/tab_component.rb
464
427
  - app/components/dsfr_component/tag_component.rb
465
428
  - app/components/dsfr_component/tile_component.html.erb
466
429
  - app/components/dsfr_component/tile_component.rb