dsfr_accessible_skip_links 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 794bc710db3516cb3b73043093d4a8e25c5aa2678897e79d0a4e011ae2367cf9
4
+ data.tar.gz: a4d345e260e6557364cc9bffc3931986a1e1755f2604b324afba0f1fecfb8076
5
+ SHA512:
6
+ metadata.gz: 1e4ffb3bd674953927839fa4957b343d3a5df68ef91166267be12a288ac0a18c0d461adb52ab869d01a7443b80978f43d2614fdd30e4b37c5997618ec209fcf9
7
+ data.tar.gz: 6534795c4a521680b1cb06cf4f336f9f0ea767cad92a4c54eab9eda1a2fa6a70882b5b7ed8e9d42e95cccbff6efdce6c5fa656d7f2a518128d86c90e6dea7068
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.6
5
+ NewCops: enable
6
+ SuggestExtensions: false
7
+ Exclude:
8
+ - 'vendor/**/*'
9
+ - 'tmp/**/*'
10
+
11
+ Layout/LineLength:
12
+ Max: 120
13
+
14
+ Metrics/BlockLength:
15
+ Exclude:
16
+ - 'spec/**/*.rb'
17
+ - '*.gemspec'
18
+
19
+ Style/Documentation:
20
+ Enabled: false
21
+
22
+ Style/StringLiterals:
23
+ EnforcedStyle: double_quotes
24
+
25
+ Naming/PredicateMethod:
26
+ Enabled: false
27
+
28
+ Gemspec/DevelopmentDependencies:
29
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2025-08-27
11
+
12
+ ### Added
13
+ - Initial release
14
+ - Skip links helper methods for Rails applications
15
+ - DSFR-compliant CSS classes and HTML structure
16
+ - Configuration system for customizing default behavior
17
+ - Accessibility features following WCAG 2.2 guidelines
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "rake", "~> 13.0"
8
+ gem "rspec", "~> 3.0"
9
+ gem "rubocop", "~> 1.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Isabelle Lafont
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # DsfrAccessibleSkipLinks
2
+
3
+ A Ruby gem that helps projects implement accessible skip links according to the French government design system (DSFR - Système de design de l'État français). This gem provides helpers and utilities for creating navigation skip links that improve web accessibility.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'dsfr_accessible_skip_links'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install dsfr_accessible_skip_links
20
+
21
+ ## Usage
22
+
23
+ ### Rails Integration
24
+
25
+ The gem automatically integrates with Rails through a Rails Engine. The `SkipLinks` module is automatically included in `ApplicationController`.
26
+
27
+ In your layout file (e.g., `app/views/layouts/application.html.erb`), add the skip links at the top:
28
+
29
+ ```erb
30
+ <!DOCTYPE html>
31
+ <html>
32
+ <head>
33
+ <!-- head content -->
34
+ </head>
35
+ <body>
36
+ <%= render partial: 'shared/skip_links' %>
37
+
38
+ <!-- rest of your layout -->
39
+ <header id="header">
40
+ <!-- your navigation -->
41
+ </header>
42
+
43
+ <main id="content">
44
+ <%= yield %>
45
+ </main>
46
+
47
+ <footer id="footer">
48
+ <!-- your footer -->
49
+ </footer>
50
+ </body>
51
+ </html>
52
+ ```
53
+
54
+ ### Default Skip Links
55
+
56
+ By default, the gem provides three skip links:
57
+ - **"Aller au contenu"** → `#content`
58
+ - **"Menu"** → `#header`
59
+ - **"Pied de page"** → `#footer`
60
+
61
+ ### Custom Skip Links
62
+
63
+ You can customize skip links on a per-page basis using Rails' `content_for`:
64
+
65
+ ```erb
66
+ <% content_for :skip_links do %>
67
+ <%= skip_link('Aller au contenu principal', 'main-section') %>
68
+ <%= skip_link('Aller à la navigation spéciale', 'special-nav') %>
69
+ <%= skip_link('Aller aux résultats', 'results') %>
70
+ <% end %>
71
+ ```
72
+
73
+ ### Custom Content Link Text
74
+
75
+ You can customize the main content link text:
76
+
77
+ ```erb
78
+ <% content_for :content_skip_link_text, 'Go to main content' %>
79
+ ```
80
+
81
+ ### Tab-Prefixed Links
82
+
83
+ For links that need JavaScript interaction, use the `tab-` prefix:
84
+
85
+ ```erb
86
+ <%= skip_link('Tab Navigation', 'tab-special-section') %>
87
+ ```
88
+
89
+ This will add a `data-anchor` attribute for JavaScript handling.
90
+
91
+ ### Helper Methods
92
+
93
+ The gem provides these helper methods (automatically available in controllers and views):
94
+
95
+ - `skip_link(text, anchor)` - Creates a single skip link
96
+ - `default_skip_links` - Returns the default set of skip links
97
+ - `skip_links_content` - Returns either custom or default skip links
98
+ - `content_skip_link_text` - Returns the content link text
99
+
100
+ ### CSS Classes
101
+
102
+ The gem uses official DSFR CSS classes:
103
+ - `.fr-skiplinks` - Main container
104
+ - `.fr-container` - DSFR container wrapper
105
+ - `.fr-skiplinks__list` - List container
106
+ - `.fr-link` - Individual link styling
107
+
108
+ ### HTML Structure
109
+
110
+ The generated HTML follows this structure:
111
+
112
+ ```html
113
+ <div class="fr-skiplinks">
114
+ <nav class="fr-container" role="navigation" aria-label="Accès rapide">
115
+ <ul class="fr-skiplinks__list">
116
+ <li><a class="fr-link" href="#content">Aller au contenu</a></li>
117
+ <li><a class="fr-link" href="#header">Menu</a></li>
118
+ <li><a class="fr-link" href="#footer">Pied de page</a></li>
119
+ </ul>
120
+ </nav>
121
+ </div>
122
+ ```
123
+
124
+ ## Accessibility Features
125
+
126
+ This gem implements skip links following WCAG 2.2 guidelines and DSFR specifications:
127
+
128
+ - Proper semantic HTML structure with `nav` element and `role="navigation"`
129
+ - Descriptive `aria-label` for screen readers
130
+ - Keyboard navigation support
131
+ - Focus management
132
+ - Compatible with DSFR CSS for visual styling
133
+
134
+ ## Development
135
+
136
+ After checking out the repo, run `bundle install` to install dependencies.
137
+
138
+ Run the test suite:
139
+ ```bash
140
+ bundle exec rake spec
141
+ ```
142
+
143
+ Run RuboCop for code quality checks:
144
+ ```bash
145
+ bundle exec rake rubocop
146
+ ```
147
+
148
+ Run both tests and RuboCop:
149
+ ```bash
150
+ bundle exec rake
151
+ ```
152
+
153
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
154
+
155
+ ## Contributing
156
+
157
+ Bug reports and pull requests are welcome on GitHub at https://github.com/etalab/dsfr_accessible_skip_links.
158
+
159
+ ## License
160
+
161
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ desc "Run RuboCop"
9
+ task :rubocop do
10
+ sh "bundle exec rubocop"
11
+ end
12
+
13
+ task default: %i[rubocop spec]
@@ -0,0 +1,7 @@
1
+ <div class="fr-skiplinks">
2
+ <nav class="fr-container" role="navigation" aria-label="Accès rapide">
3
+ <ul class="fr-skiplinks__list">
4
+ <%= skip_links_content %>
5
+ </ul>
6
+ </nav>
7
+ </div>
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/dsfr_accessible_skip_links/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "dsfr_accessible_skip_links"
7
+ spec.version = DsfrAccessibleSkipLinks::VERSION
8
+ spec.authors = ["Isabelle Lafont"]
9
+ spec.email = ["isalafont@gmail.com"]
10
+ spec.summary = "Accessible skip links implementation following DSFR (Système de design de l'État français) guidelines"
11
+ spec.description = "A Ruby gem that helps projects implement accessible skip links according to " \
12
+ "the French government design system (DSFR). Provides helpers and utilities " \
13
+ "for creating navigation skip links that improve accessibility."
14
+ spec.homepage = "https://github.com/Isalafont/dsfr_accessible_skip_links"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 2.6.0"
17
+
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/Isalafont/dsfr_accessible_skip_links"
21
+ spec.metadata["changelog_uri"] = "https://github.com/Isalafont/dsfr_accessible_skip_links/blob/main/CHANGELOG.md"
22
+ spec.metadata["rubygems_mfa_required"] = "true"
23
+
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z 2>/dev/null`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 2.0"
34
+ spec.add_development_dependency "rake", "~> 13.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "rubocop", "~> 1.0"
37
+ spec.add_development_dependency "rubocop-rake", "~> 0.6"
38
+ spec.add_development_dependency "rubocop-rspec", "~> 2.0"
39
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DsfrAccessibleSkipLinks
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace DsfrAccessibleSkipLinks
6
+
7
+ config.to_prepare do
8
+ ApplicationController.include(DsfrAccessibleSkipLinks::SkipLinks) if defined?(ApplicationController)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DsfrAccessibleSkipLinks
4
+ module SkipLinks
5
+ TAB_PREFIX = "tab-"
6
+
7
+ def skip_link(text, anchor)
8
+ anchor_str = anchor.to_s
9
+ content_tag(:li) do
10
+ if anchor_str.start_with?(TAB_PREFIX)
11
+ link_to(text, "##{anchor_str}", class: "fr-link", data: { anchor: anchor_str })
12
+ else
13
+ link_to(text, "##{anchor_str}", class: "fr-link")
14
+ end
15
+ end
16
+ end
17
+
18
+ def default_skip_links
19
+ result = [
20
+ skip_link(content_skip_link_text, "content"),
21
+ skip_link("Menu", "header"),
22
+ skip_link("Pied de page", "footer")
23
+ ].join
24
+
25
+ result.respond_to?(:html_safe) ? result.html_safe : result
26
+ end
27
+
28
+ def skip_links_content
29
+ return content_for(:skip_links) if content_for?(:skip_links)
30
+
31
+ validate_skip_links_in_test! if defined?(Rails) && Rails.env.test?
32
+ default_skip_links
33
+ end
34
+
35
+ def content_skip_link_text
36
+ return content_for(:content_skip_link_text) if content_for?(:content_skip_link_text)
37
+
38
+ "Aller au contenu"
39
+ end
40
+
41
+ private
42
+
43
+ def validate_skip_links_in_test!
44
+ # This would be implemented to validate skip links in test environment
45
+ # For now, just a placeholder
46
+ true
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DsfrAccessibleSkipLinks
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "dsfr_accessible_skip_links/version"
4
+ require_relative "dsfr_accessible_skip_links/engine" if defined?(Rails)
5
+ require_relative "dsfr_accessible_skip_links/skip_links"
6
+
7
+ module DsfrAccessibleSkipLinks
8
+ class Error < StandardError; end
9
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dsfr_accessible_skip_links
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Isabelle Lafont
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-08-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
97
+ description: A Ruby gem that helps projects implement accessible skip links according
98
+ to the French government design system (DSFR). Provides helpers and utilities for
99
+ creating navigation skip links that improve accessibility.
100
+ email:
101
+ - isalafont@gmail.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".rspec"
107
+ - ".rubocop.yml"
108
+ - CHANGELOG.md
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - app/views/shared/_skip_links.html.erb
114
+ - dsfr_accessible_skip_links.gemspec
115
+ - lib/dsfr_accessible_skip_links.rb
116
+ - lib/dsfr_accessible_skip_links/engine.rb
117
+ - lib/dsfr_accessible_skip_links/skip_links.rb
118
+ - lib/dsfr_accessible_skip_links/version.rb
119
+ homepage: https://github.com/Isalafont/dsfr_accessible_skip_links
120
+ licenses:
121
+ - MIT
122
+ metadata:
123
+ allowed_push_host: https://rubygems.org
124
+ homepage_uri: https://github.com/Isalafont/dsfr_accessible_skip_links
125
+ source_code_uri: https://github.com/Isalafont/dsfr_accessible_skip_links
126
+ changelog_uri: https://github.com/Isalafont/dsfr_accessible_skip_links/blob/main/CHANGELOG.md
127
+ rubygems_mfa_required: 'true'
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: 2.6.0
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubygems_version: 3.5.9
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Accessible skip links implementation following DSFR (Système de design de
147
+ l'État français) guidelines
148
+ test_files: []