Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility fixes #112

Open
wants to merge 30 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0ff7814
Using Rspack
felixgirault Sep 5, 2024
3b7d3a2
Improved tests performance
felixgirault Sep 5, 2024
fb01af6
Improved bundle size with swc helpers
felixgirault Sep 6, 2024
295c5f4
Improved loading process
felixgirault Sep 9, 2024
25491cf
Fixed commonjs and esm builds
felixgirault Sep 9, 2024
81c6f0a
Fixed accessible names on tiles
felixgirault Sep 9, 2024
8595c7c
Improved footer styles of default theme
felixgirault Sep 9, 2024
8bd82bc
Fixed type declarations for translations
felixgirault Sep 10, 2024
409a9d6
Improved documentation
felixgirault Sep 10, 2024
bb9ebb2
Fixed missing component keys
felixgirault Sep 10, 2024
68eb808
Exposed the core manager
felixgirault Sep 12, 2024
2e54969
Fixed migrations
felixgirault Sep 12, 2024
51b4d35
Fixed code splitting
felixgirault Sep 13, 2024
9e3af0d
Fixed props aliasing
felixgirault Sep 13, 2024
e15f795
Fixed initial rendering
felixgirault Sep 13, 2024
146c99e
Fixed focus handling with modals
felixgirault Sep 16, 2024
dbf4db2
Improved default styles
felixgirault Sep 16, 2024
f4c8775
Fixed GitHub link contrast
felixgirault Oct 11, 2024
0939c5a
Fixed button groups markup
felixgirault Oct 11, 2024
3bbb002
Added missing landmark role
felixgirault Oct 11, 2024
cc6c140
Fixed header link
felixgirault Oct 11, 2024
a850173
Fixed callout title
felixgirault Oct 11, 2024
6d09cc1
Improved disabled buttons style
felixgirault Oct 11, 2024
3d7be84
Prevented unwanted form submissions
felixgirault Oct 11, 2024
abb1f0d
Improved focus handling on the banner
felixgirault Oct 11, 2024
fd2215a
Improved child purposes grouping
felixgirault Oct 11, 2024
4865f55
Fixed navigation flow in DSFR banner
felixgirault Oct 11, 2024
1b0c9a0
Fixed banner button titles
felixgirault Oct 11, 2024
8bb5094
Added missing doctype on demo page
felixgirault Oct 11, 2024
f955ce9
fixup! Fixed banner button titles
felixgirault Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .babelrc

This file was deleted.

10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/node_modules
/dist/*.js
/dist/*.cjs
/dist/*.mjs
/dist/*.css
/dist/*.scss
/dist/*.LICENSE.txt
/dist/*.ts
/dist/*.cts
/dist/*.mts
/dist/stats.json
/dist/example-assets/migrations.js
/lib
/es
/stats.json
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*
!/dist/*.js
!/dist/*.cjs
!/dist/*.mjs
!/dist/*.d.ts
!/dist/*.css
!/dist/*.scss
!/dist/*.LICENSE.txt
90 changes: 69 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ For external scripts or img tags (for tracking pixels), do the same, and rename

You need to pass Orejime 🍪 a configuration object with, at the very least, `purposes` and `privacyPolicyUrl` properties. Each purpose listed in `purposes` must itself have at least `id`, `title` and `cookies`.

<details open>
<details>
<summary>Here is a fully-detailed annotated example of a configuration object:</summary>
&nbsp;

Expand Down Expand Up @@ -140,8 +140,12 @@ var orejimeConfig = {
// with the image `src` and `alt` attributes: `logo: {src: '...', alt: '...'}`
logo: '/img/logo.png',

// Optional. The theme used to render the UI (See the "theming" section below).
// If unset, this will default to "orejime", the classic built-in UI.
theme: 'orejime',

// You can overwrite existing translations and add translations for your
// purpose descriptions and purposes. See `src/translations.yml` for a full
// purpose descriptions and purposes. See `src/translations` for a full
// list of translations that can be overwritten
translations: {
modal: {
Expand Down Expand Up @@ -284,38 +288,75 @@ When including the script, the lib checks if the `window.orejimeConfig` variable
Orejime.init(orejimeConfig);
```

### Styling
#### As a module

If you're using Orejime within a bundler like webpack or vite, you have to provide actual themes and translations. This allows the bundler to perform better tree shaking as dependencies are explicitly stated.

For example, with the `orejime` theme and english translations:

```ts
import {orejime, orejimeTheme, en} from 'orejime';

const instance = orejime({
lang: 'en',
translations: en,
theme: orejimeTheme,
privacyPolicyUrl: 'http://example.org/privacy-policy',
purposes: [{
id: 'analytics',
title: 'Analytics',
cookies: []
}]
})
```

If you want full control over the UI, you might want to use only the [consent manager](`./src/core/Manager.ts`), which is the core of Orejime. You can then use it with vanilla JS or your framework of choice.

```ts
import {manager} from 'orejime';

const instance = manager([
{
id: 'analytics',
title: 'Analytics',
cookies: []
}
]);

console.log(instance.getConsent('analytics')); // false
instance.setConsent('analytics', true);
console.log(instance.getConsent('analytics')); // true
```

#### CSS
### Theming

Either replace the original CSS entirely, or add your custom stylesheet to overwrite only some of the rules.
For example:
Orejime support multiple themes to accomodate for every situation.

#### Default theme

This theme is loaded by default. It is meant to be simple but elegant enough to be used as-is on any website. It is easily customizable by tweaking some CSS properties.

Of course, you can either replace the original CSS entirely, or add your custom stylesheet to overwrite only some of the rules.

```css
/* custom-style.css */
.orejime-Notice,
.orejime-Modal {
background: pink;
color: white;
.orejime-Env {
--orejime-font-family: monospace;
--orejime-background: black;
--orejime-color: yellow;
}
```

```html
<link rel="stylesheet" href="orejime.css" />
<link rel="stylesheet" href="custom-style.css" />
```

#### Sass

You can import [the original Sass stylesheet](https://github.com/empreinte-digitale/orejime/blob/master/src/scss/orejime.scss) into your own, and tweak it as you wish.
Orejime provides default variables that you can overwrite to quickly change its appearance.
For example:
#### DSFR theme

```scss
$orejime-theme-bg: pink;
$orejime-theme-color: white;
This theme is meant to be used on websites using the official design system of the french government. As those sites already include the DSFR styles, this theme does not provide any styles of its own but only makes use of the correct markup and class names.

@import "~orejime/src/scss/orejime.scss"
```
See the [consent manager component](https://www.systeme-de-design.gouv.fr/composants-et-modeles/composants/gestionnaire-de-consentement) on the DSFR docs for an overview.

## API

Expand All @@ -325,10 +366,17 @@ $orejime-theme-color: white;
### Orejime instance

* `prompt()`: opens the consent modal
* `preload()`: preloads the UI without showing it
* `manager`: the Manager instance used. See `src/core/Manager.ts`
* `config`: the complete config object used

## Migrating

### Version 3

A major overhaul of the configuration took place in this version, as to clarify naming and align more with the GDPR vocabulary.

If you were already using version 2, a tool to migrate your current configuration is available here : https://orejime.empreintedigitale.fr/migration.

## Development

If you want to contribute to Orejime, or make a special build for yourself, clone the project then:
Expand Down
8 changes: 0 additions & 8 deletions build/tsconfig.commonjs.json

This file was deleted.

8 changes: 0 additions & 8 deletions build/tsconfig.module.json

This file was deleted.

19 changes: 8 additions & 11 deletions dist/dsfr.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!DOCTYPE html>

<html lang="fr">
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -33,7 +35,7 @@
<div class="fr-header__body">
<div class="fr-container">
<div class="fr-header__body-row">
<div class="fr-header__brand fr-enlarge-link">
<div class="fr-header__brand">
<div class="fr-header__brand-top">
<div class="fr-header__logo">
<p class="fr-logo">Exemple</p>
Expand All @@ -49,12 +51,7 @@
</div>

<div class="fr-header__service">
<a
href="/dsfr.html"
title="Accueil - Intégration au système de design de l'état - Orejime"
>
<p class="fr-header__service-title">Orejime</p>
</a>
<p class="fr-header__service-title">Orejime</p>
<p class="fr-header__service-tagline">
Gestionnaire de consentement accessible et éco-conçu
</p>
Expand Down Expand Up @@ -98,9 +95,10 @@ <h1>
<div class="fr-grid-row fr-grid-row--gutters fr-grid-row--center">
<div class="fr-col-12 fr-col-md-10 fr-col-lg-8">
<div class="fr-callout" id="privacy-policy">
<p class="fr-callout__title">
<h2 class="fr-callout__title">
Exemple de politique de confidentialité
</p>
</h2>

<p class="fr-callout__text">
Cette section tient lieu de page de politique de
confidentialité.
Expand All @@ -119,7 +117,6 @@ <h1>
<button
class="fr-btn"
data-orejime-open
data-orejime-preload
>
Configurer
</button>
Expand Down Expand Up @@ -179,7 +176,6 @@ <h1>
<button
class="fr-footer__bottom-link"
href="#"
data-orejime-preload
data-orejime-open
>
Gestion des cookies
Expand Down Expand Up @@ -207,6 +203,7 @@ <h1>
// see the annotated config in the README for details on how everything works
window.orejimeConfig = {
theme: 'dsfr',
lang: 'fr',
privacyPolicyUrl: '#privacyPolicy',
translations: {
modal: {
Expand Down
9 changes: 0 additions & 9 deletions dist/example-assets/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,3 @@ document.querySelectorAll('[data-orejime-reset]').forEach(function (trigger) {
window.orejime.manager.clearConsents();
});
});

document.querySelectorAll('[data-orejime-preload]').forEach(function (trigger) {
trigger.addEventListener('focus', function () {
window.orejime.preload();
});
trigger.addEventListener('mouseover', function () {
window.orejime.preload();
});
});
34 changes: 33 additions & 1 deletion dist/example-assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ a:active {
text-decoration: none;
}

.is-hidden {
display: none;
}

.Button {
display: inline-block;
border: 0;
Expand All @@ -106,6 +110,16 @@ a:active {
background: #b30443;
}

.ButtonGroup {
margin: 0;
padding: 0;
list-style: none;
}

.ButtonGroup li {
display: inline-block;
}

.Container {
box-sizing: border-box;
margin: auto;
Expand Down Expand Up @@ -242,6 +256,21 @@ a.Tile:active {
max-width: 100%;
}

.MigrationForm-input,
.MigrationForm-output {
margin-bottom: var(--unit);
border: 1px solid currentColor;
border-radius: calc(var(--unit) / 4);
width: 100%;
padding: calc(var(--unit) / 2);
font: inherit;
font-family: monospace;
}

.MigrationForm-output {
overflow-x: auto;
}

.Footer {
padding: calc(3 * var(--unit)) 0;
background: var(--contrast-surface);
Expand Down Expand Up @@ -272,5 +301,8 @@ a.Tile:active {
}

.orejime-Env {
--orejime-background: #eff9fd !important;
--orejime-color-background: #eff9fd !important;
--orejime-color-text: var(--on-surface) !important;
--orejime-color-interactive: var(--interactive) !important;
--orejime-color-shadow: 2, 10, 15 !important;
}
Loading