@gouvfr/dsfr-roller 1.0.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.
- package/LICENSE.md +21 -0
- package/README.md +11 -0
- package/index.js +5 -0
- package/package.json +65 -0
- package/src/component/component.js +50 -0
- package/src/component/components/action.js +28 -0
- package/src/component/components/breadcrumb.js +33 -0
- package/src/component/components/button.js +37 -0
- package/src/component/components/display-body.js +41 -0
- package/src/component/components/display-modal.js +29 -0
- package/src/component/components/footer.js +85 -0
- package/src/component/components/header.js +96 -0
- package/src/component/components/navigation.js +72 -0
- package/src/component/components/sidemenu.js +58 -0
- package/src/component/components/skiplink.js +49 -0
- package/src/component/components/translate.js +32 -0
- package/src/component/components/version.js +21 -0
- package/src/component/ejs/version/version.ejs +46 -0
- package/src/component/ejs/version/versions.ejs +31 -0
- package/src/component/ejs-pkg.js +6 -0
- package/src/component/render.js +19 -0
- package/src/constants.js +7 -0
- package/src/core/format-html.js +16 -0
- package/src/core/format-link.js +8 -0
- package/src/core/html-renderable.js +10 -0
- package/src/core/renderable.js +20 -0
- package/src/integration/bundler.js +47 -0
- package/src/integration/indexing/indexer.js +23 -0
- package/src/integration/indexing/sitemap.js +44 -0
- package/src/integration/redirect/redirection-type.js +4 -0
- package/src/integration/redirect/redirection.js +77 -0
- package/src/node/custom/html-container-node.js +7 -0
- package/src/node/directive/doc/accordion-container-directive.js +59 -0
- package/src/node/directive/doc/accordions-group-container-directive.js +12 -0
- package/src/node/directive/doc/anatomy-container-directive.js +61 -0
- package/src/node/directive/doc/button-leaf-directive.js +37 -0
- package/src/node/directive/doc/changelog-leaf-directive.js +238 -0
- package/src/node/directive/doc/figma-leaf-directive.js +21 -0
- package/src/node/directive/doc/guideline-container-directive.js +71 -0
- package/src/node/directive/doc/guidelines-container-directive.js +13 -0
- package/src/node/directive/doc/image-text-directive.js +13 -0
- package/src/node/directive/doc/pin-leaf-directive.js +46 -0
- package/src/node/directive/doc/storybook-leaf-directive.js +18 -0
- package/src/node/directive/doc/tab-container-directive.js +22 -0
- package/src/node/directive/doc/tab-navigation-container-directive.js +49 -0
- package/src/node/directive/doc/table-container-directive.js +56 -0
- package/src/node/directive/doc/tabs-container-directive.js +71 -0
- package/src/node/generic/blockquote-node.js +26 -0
- package/src/node/generic/break-node.js +11 -0
- package/src/node/generic/code-node.js +37 -0
- package/src/node/generic/definition-node.js +13 -0
- package/src/node/generic/emphasis-node.js +11 -0
- package/src/node/generic/heading-node.js +56 -0
- package/src/node/generic/html-node.js +11 -0
- package/src/node/generic/image-node.js +14 -0
- package/src/node/generic/image-reference-node.js +14 -0
- package/src/node/generic/inline-code-node.js +21 -0
- package/src/node/generic/link-node.js +26 -0
- package/src/node/generic/link-reference-node.js +14 -0
- package/src/node/generic/list-item-node.js +11 -0
- package/src/node/generic/list-node.js +15 -0
- package/src/node/generic/paragraph-node.js +11 -0
- package/src/node/generic/strong-node.js +11 -0
- package/src/node/generic/text-node.js +15 -0
- package/src/node/generic/thematic-break-node.js +12 -0
- package/src/node/gfm/table-body-node.js +11 -0
- package/src/node/gfm/table-cell-node.js +17 -0
- package/src/node/gfm/table-head-node.js +11 -0
- package/src/node/gfm/table-header-node.js +16 -0
- package/src/node/gfm/table-node.js +91 -0
- package/src/node/gfm/table-row-node.js +11 -0
- package/src/node/node-factory.js +128 -0
- package/src/node/node-root.js +25 -0
- package/src/node/node.js +106 -0
- package/src/page/body/custom-header.js +40 -0
- package/src/page/body/main.js +23 -0
- package/src/page/body/scheme.js +9 -0
- package/src/page/head/canonical.js +16 -0
- package/src/page/head/favicon.js +14 -0
- package/src/page/head/head.js +35 -0
- package/src/page/head/share.js +14 -0
- package/src/page/head/stylesheets.js +48 -0
- package/src/page/head/title.js +9 -0
- package/src/page/html.js +46 -0
- package/src/page/page.js +39 -0
- package/src/page/scripts/highlight.js +53 -0
- package/src/page/scripts/scripts.js +57 -0
- package/src/script/main/core/element.js +29 -0
- package/src/script/main/elements/copy-snippet.js +35 -0
- package/src/script/main/elements/searchbar.js +18 -0
- package/src/script/main/elements/storybook.js +20 -0
- package/src/script/main/index.js +10 -0
- package/src/script/search/index.js +0 -0
- package/src/style/main/components/_dsfr-doc-anatomy.scss +54 -0
- package/src/style/main/components/_dsfr-doc-code-snippet.scss +9 -0
- package/src/style/main/components/_dsfr-doc-figma-leaf.scss +6 -0
- package/src/style/main/components/_dsfr-doc-guideline.scss +58 -0
- package/src/style/main/components/_dsfr-doc-tab-navigation.scss +99 -0
- package/src/style/main/components/_dsfr-doc-version.scss +154 -0
- package/src/style/main/components/_index.scss +6 -0
- package/src/style/main/index.scss +3 -0
- package/src/style/main/third-party/_highlight.scss +227 -0
- package/src/style/main/third-party/_index.scss +1 -0
- package/src/style/main/utility/_dsfr-doc-code.scss +9 -0
- package/src/style/main/utility/_font.scss +31 -0
- package/src/style/main/utility/_icon.scss +4 -0
- package/src/style/main/utility/_index.scss +3 -0
- package/src/style/search/index.scss +0 -0
- package/src/template/template-factory.js +16 -0
- package/src/template/template.js +27 -0
- package/src/template/templates/editorial-template.js +45 -0
- package/src/template/templates/home-template.js +18 -0
- package/src/template/templates/search-template.js +20 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Le contenu de ce dépôt est placé sous licence MIT License, à l'exception de la fonte Marianne.
|
|
2
|
+
Voir les [conditions générales d'utilisation](doc/legal/cgu.md)
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
|
21
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# 🇫🇷 Outil de publication du site de documentation du Système de Design de l’État
|
|
2
|
+
|
|
3
|
+
[](https://GitHub.com/gouvernementFR/dsfr/releases/) [](https://www.npmjs.com/package/@gouvfr/dsfr-roller) [](https://github.com/GouvernementFR/dsfr/blob/main/LICENSE.md) [](https://npmjs.com/package/@gouvfr/dsfr-roller)
|
|
4
|
+
|
|
5
|
+
Le Système de Design de l’État (ci-après, le **DSFR**) est un ensemble de composants web HTML, CSS et Javascript pour faciliter le travail des équipes projets des sites Internet publics, et créer des interfaces numériques de qualité et accessibles.
|
|
6
|
+
|
|
7
|
+
Le module `dsfr-roller` permet de publier le site de documentation du Système de Design de l’État - DSFR. Il est destiné à un usage interne par les équipes du Service d'Information du Gouvernement (SIG).
|
|
8
|
+
|
|
9
|
+
## Licence et droit d'utilisation
|
|
10
|
+
|
|
11
|
+
Le contenu de ce projet est placé sous licence MIT License. Voir [LICENSE.md](https://github.com/GouvernementFR/dsfr/blob/main/LICENSE.md).
|
package/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Page } from './src/page/page.js';
|
|
2
|
+
export { Bundler } from './src/integration/bundler.js';
|
|
3
|
+
export { RedirectionType } from './src/integration/redirect/redirection-type.js';
|
|
4
|
+
export { Redirection } from './src/integration/redirect/redirection.js';
|
|
5
|
+
export { Indexer } from './src/integration/indexing/indexer.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gouvfr/dsfr-roller",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Le module `dsfr-roller` permet de publier le site de documentation du Système de Design de l’État - DSFR",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Système de Design de l'État",
|
|
7
|
+
"gouvfr",
|
|
8
|
+
"dsfr",
|
|
9
|
+
"doc"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/GouvernementFR/dsfr/tree/main/modules/roller",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/GouvernementFR/dsfr/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Service d'Information du Gouvernement",
|
|
18
|
+
"email": "maxime.beaugrand@pm.gouv.fr",
|
|
19
|
+
"url": "https://www.systeme-de-design.gouv.fr/"
|
|
20
|
+
},
|
|
21
|
+
"contributors": [
|
|
22
|
+
{
|
|
23
|
+
"name": "Bertrand Larrieu",
|
|
24
|
+
"email": "bertrand.larrieu@actimage.com"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Keryan Sanié",
|
|
28
|
+
"email": "keryan.sanie@actimage.com"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "Baptiste Zeller",
|
|
32
|
+
"email": "baptiste.zeller@actimage.com"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+ssh://git@github.com/GouvernementFR/dsfr.git",
|
|
38
|
+
"directory": "./modules/doc/publisher"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"type": "module",
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22.14.0"
|
|
46
|
+
},
|
|
47
|
+
"packageManager": "yarn@4.5.2+sha224.c2e2e9ed3cdadd6ec250589b3393f71ae56d5ec297af11cec1eba3b4",
|
|
48
|
+
"files": [
|
|
49
|
+
"index.js",
|
|
50
|
+
"src/",
|
|
51
|
+
"../../../legal/*",
|
|
52
|
+
"../../../SECURITY.md",
|
|
53
|
+
"../../../LICENSE.md"
|
|
54
|
+
],
|
|
55
|
+
"main": "./index.js",
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@gouvfr/dsfr-forge": "=1.0.0",
|
|
58
|
+
"@gouvfr/dsfr-publisher": "npm:@gouvfr/dsfr@1.13.1",
|
|
59
|
+
"deepmerge": "^4.3.1",
|
|
60
|
+
"ejs": "^3.1.10",
|
|
61
|
+
"highlight.js": "^11.10.0",
|
|
62
|
+
"prettier": "^3.3.3",
|
|
63
|
+
"yaml": "^2.4.1"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import render from './render.js';
|
|
2
|
+
import deepmerge from 'deepmerge';
|
|
3
|
+
import { Renderable } from '../core/renderable.js';
|
|
4
|
+
|
|
5
|
+
class Component extends Renderable {
|
|
6
|
+
constructor (data, id, pkg = undefined) {
|
|
7
|
+
super(data);
|
|
8
|
+
this._id = id;
|
|
9
|
+
this._pkg = pkg;
|
|
10
|
+
this._counter = 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get id () {
|
|
14
|
+
return this._id;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get counter () {
|
|
18
|
+
this._counter++;
|
|
19
|
+
return this._counter;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
uniqueId () {
|
|
23
|
+
return `${this.id}-${this.counter}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get ejsPath () {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async format () {
|
|
31
|
+
return this._data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async render (renderingData) {
|
|
35
|
+
if (!this.ejsPath) {
|
|
36
|
+
throw new Error('The ejsPath property must be defined');
|
|
37
|
+
}
|
|
38
|
+
const formatedData = await this.format();
|
|
39
|
+
|
|
40
|
+
const mergedData = renderingData ? deepmerge(formatedData, renderingData) : formatedData;
|
|
41
|
+
|
|
42
|
+
const data = {
|
|
43
|
+
[this.id]: mergedData
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return await render(this.ejsPath, data, this._pkg);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { Component };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
|
|
3
|
+
class Action extends Component {
|
|
4
|
+
constructor (data) {
|
|
5
|
+
super(data, 'action');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get ejsPath () {
|
|
9
|
+
return 'src/dsfr/core/template/ejs/action/action.ejs';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async format () {
|
|
13
|
+
return {
|
|
14
|
+
markup: this.data.markup ?? 'button',
|
|
15
|
+
label: this.data.label ?? this.data.text,
|
|
16
|
+
id: this.data.id,
|
|
17
|
+
href: this.data.url ?? this.data.href,
|
|
18
|
+
type: this.data.type,
|
|
19
|
+
blank: this.data.blank,
|
|
20
|
+
self: this.data.self,
|
|
21
|
+
disabled: this.data.disabled,
|
|
22
|
+
classes: this.data.classes,
|
|
23
|
+
attributes: this.data.attributes,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { Action };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
|
|
3
|
+
class Breadcrumb extends Component {
|
|
4
|
+
constructor (data) {
|
|
5
|
+
super(data, 'breadcrumb');
|
|
6
|
+
}
|
|
7
|
+
get ejsPath () {
|
|
8
|
+
return 'src/dsfr/component/breadcrumb/template/ejs/breadcrumb.ejs';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async format () {
|
|
12
|
+
const chunks = [''];
|
|
13
|
+
const segments = this.data.segments.map((segment) => this._formatSegment(segment, chunks));
|
|
14
|
+
segments[0].path = `/${segments[0].path}`;
|
|
15
|
+
return {
|
|
16
|
+
id: 'breadcrumb',
|
|
17
|
+
segments: segments,
|
|
18
|
+
button: this.data.button
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_formatSegment (segment, chunks) {
|
|
23
|
+
const missing = segment.url.split('/').filter((chunk) => !chunks.includes(chunk));
|
|
24
|
+
chunks.push(...missing);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
label: segment.label ?? segment.text,
|
|
28
|
+
path: missing.join('/')
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Breadcrumb };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
import yaml from 'yaml';
|
|
3
|
+
|
|
4
|
+
class Button extends Component {
|
|
5
|
+
constructor (data) {
|
|
6
|
+
super(data, 'button');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
get ejsPath () {
|
|
10
|
+
return 'src/dsfr/component/button/template/ejs/button.ejs';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async format () {
|
|
14
|
+
const index = [, , 'secondary', 'tertiary', 'tertiary-no-outline'].indexOf(this.data.kind);
|
|
15
|
+
const url = this.data.url ?? this.data.href;
|
|
16
|
+
const blank = this.data.blank === 'true' || /^(http|www)/.test(url);
|
|
17
|
+
return {
|
|
18
|
+
markup: url ? 'a' : this.data.markup,
|
|
19
|
+
kind: index > -1 ? index : parseInt(this.data.kind),
|
|
20
|
+
size: this.data.size,
|
|
21
|
+
label: this.data.label ?? this.data.text,
|
|
22
|
+
title: this.data.title,
|
|
23
|
+
id: this.data.id,
|
|
24
|
+
href: url,
|
|
25
|
+
type: this.data.type,
|
|
26
|
+
blank,
|
|
27
|
+
self: !blank || this.data.self === 'true',
|
|
28
|
+
disabled: this.data.disabled === 'true',
|
|
29
|
+
classes: this.data.classes.split(','),
|
|
30
|
+
attributes: yaml.parse(this.data.attributes),
|
|
31
|
+
icon: this.data.icon,
|
|
32
|
+
iconPlace: this.data['icon-place'],
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { Button };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
|
|
3
|
+
class DisplayBody extends Component {
|
|
4
|
+
constructor (data) {
|
|
5
|
+
super(data, 'fieldset');
|
|
6
|
+
}
|
|
7
|
+
get ejsPath () {
|
|
8
|
+
return 'src/dsfr/component/form/template/ejs/fieldset/fieldset.ejs';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async format () {
|
|
12
|
+
return {
|
|
13
|
+
id: 'display-fieldset',
|
|
14
|
+
legend: this.data.legend,
|
|
15
|
+
inline: false,
|
|
16
|
+
choice: true,
|
|
17
|
+
elements: this.data.radios.map(radio => this.formatRadio(radio))
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
formatRadio ({id, text, pictogram, hint}) {
|
|
22
|
+
return {
|
|
23
|
+
type: 'radio',
|
|
24
|
+
inline: false,
|
|
25
|
+
data: {
|
|
26
|
+
id: `fr-radios-theme-${id}`,
|
|
27
|
+
label: text,
|
|
28
|
+
value: id,
|
|
29
|
+
size: 'md',
|
|
30
|
+
name: 'fr-radios-theme',
|
|
31
|
+
rich: true,
|
|
32
|
+
hint: hint,
|
|
33
|
+
pictogram: {
|
|
34
|
+
name: pictogram
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { DisplayBody };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
import { DisplayBody } from './display-body.js';
|
|
3
|
+
|
|
4
|
+
class DisplayModal extends Component {
|
|
5
|
+
constructor (data) {
|
|
6
|
+
super(data, 'modal');
|
|
7
|
+
this._displayBody = new DisplayBody(data.resource.display);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get ejsPath () {
|
|
11
|
+
return 'src/dsfr/component/modal/template/ejs/modal.ejs';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async format () {
|
|
15
|
+
const displayBody = await this._displayBody.render();
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
id: 'display-modal',
|
|
19
|
+
title: this.data.resource.display.title,
|
|
20
|
+
size: 'sm',
|
|
21
|
+
closeButton: {
|
|
22
|
+
label: this.data.fragments.button.close,
|
|
23
|
+
},
|
|
24
|
+
body: `<div id="fr-display" class="fr-display">${displayBody}</div>`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { DisplayModal };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
import { formatLink } from '../../core/format-link.js';
|
|
3
|
+
|
|
4
|
+
class Footer extends Component {
|
|
5
|
+
constructor (data) {
|
|
6
|
+
super(data, 'footer');
|
|
7
|
+
}
|
|
8
|
+
get ejsPath () {
|
|
9
|
+
return 'src/dsfr/component/footer/template/ejs/footer.ejs';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async format () {
|
|
13
|
+
return {
|
|
14
|
+
id: 'footer',
|
|
15
|
+
top: this._formatTop(this.data?.top),
|
|
16
|
+
brand: {
|
|
17
|
+
logo: {
|
|
18
|
+
title: 'République<br>Française',
|
|
19
|
+
},
|
|
20
|
+
link: formatLink(this.data?.link),
|
|
21
|
+
},
|
|
22
|
+
content: {
|
|
23
|
+
...this.data.content,
|
|
24
|
+
links: this.data?.content?.links?.map(link => formatLink(link))
|
|
25
|
+
},
|
|
26
|
+
bottom: this._formatBottom(this.data?.bottom),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_formatTop (top) {
|
|
31
|
+
if (!top) return undefined;
|
|
32
|
+
return {
|
|
33
|
+
...top,
|
|
34
|
+
categories: top?.categories?.map(category => {
|
|
35
|
+
return {
|
|
36
|
+
...formatLink(category),
|
|
37
|
+
links: category?.links.map(link => formatLink(link))
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_formatBottom (bottom) {
|
|
44
|
+
if (!bottom) return undefined;
|
|
45
|
+
return {
|
|
46
|
+
...bottom,
|
|
47
|
+
links: bottom?.links?.map(link => this._formatBottomLink(link))
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_formatBottomLink (link) {
|
|
52
|
+
const classes = link.classes ?? [];
|
|
53
|
+
const attributes = link.attributes ?? {};
|
|
54
|
+
|
|
55
|
+
switch (true) {
|
|
56
|
+
case link.action === 'display':
|
|
57
|
+
classes.push('fr-btn--display');
|
|
58
|
+
attributes['data-fr-opened'] = false;
|
|
59
|
+
attributes['aria-controls'] = 'display-modal';
|
|
60
|
+
link.template = 'button';
|
|
61
|
+
link.label = link.text ?? link.label;
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case link.action === 'consent':
|
|
65
|
+
classes.push('fr-btn--tertiary-no-outline');
|
|
66
|
+
attributes['data-fr-opened'] = false;
|
|
67
|
+
attributes['aria-controls'] = 'consent-modal';
|
|
68
|
+
link.template = 'button';
|
|
69
|
+
link.label = link.text ?? link.label;
|
|
70
|
+
break;
|
|
71
|
+
|
|
72
|
+
default:
|
|
73
|
+
link = formatLink(link);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
link.classes = classes;
|
|
77
|
+
link.attributes = attributes;
|
|
78
|
+
|
|
79
|
+
return link;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { Footer };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
import { formatLink } from '../../core/format-link.js';
|
|
3
|
+
|
|
4
|
+
class Header extends Component {
|
|
5
|
+
constructor (data) {
|
|
6
|
+
super(data, 'header');
|
|
7
|
+
}
|
|
8
|
+
get ejsPath () {
|
|
9
|
+
return 'src/dsfr/component/header/template/ejs/header.ejs';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async format () {
|
|
13
|
+
const links = this.data.links ? this._formatButtons(this.data.links) : undefined;
|
|
14
|
+
|
|
15
|
+
const menu = {
|
|
16
|
+
id: 'menu',
|
|
17
|
+
modalId: 'menu-modal',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const search = {
|
|
21
|
+
id: 'search',
|
|
22
|
+
modalId: 'search-modal',
|
|
23
|
+
input: { placeholder: this.data.search.label, label: this.data.search.label },
|
|
24
|
+
button: { id: 'search-button', label: this.data.search.label, title: this.data.search.title ?? this.data.search.label, attributes: { 'data-href': this.data.search.url } }
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
body: {
|
|
29
|
+
brand: {
|
|
30
|
+
logo: {
|
|
31
|
+
title: 'République<br>Française'
|
|
32
|
+
},
|
|
33
|
+
service: {
|
|
34
|
+
title: this.data.title
|
|
35
|
+
},
|
|
36
|
+
link: {
|
|
37
|
+
href: this.data.link.url,
|
|
38
|
+
title: this.data.link.title,
|
|
39
|
+
position: 'service'
|
|
40
|
+
},
|
|
41
|
+
navbar: {
|
|
42
|
+
menu: menu
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
tools: {
|
|
46
|
+
links: links,
|
|
47
|
+
search: search
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
menu: {
|
|
51
|
+
...menu,
|
|
52
|
+
tools: {
|
|
53
|
+
...links
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_formatButtons (data) {
|
|
60
|
+
return { buttons: data.map(button => this._formatButton(button)) };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_formatButton (data) {
|
|
64
|
+
const classes = [];
|
|
65
|
+
const attributes = {};
|
|
66
|
+
|
|
67
|
+
switch (true) {
|
|
68
|
+
case data.action === 'display':
|
|
69
|
+
classes.push('fr-btn--display');
|
|
70
|
+
attributes['data-fr-opened'] = 'false';
|
|
71
|
+
attributes['aria-controls'] = 'display-modal';
|
|
72
|
+
data.label = data.text;
|
|
73
|
+
break;
|
|
74
|
+
|
|
75
|
+
case data.url !== undefined:
|
|
76
|
+
data.markup = 'a';
|
|
77
|
+
data = formatLink(data);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (data.icon) classes.push(`fr-icon-${data.icon}`);
|
|
82
|
+
if (data.modifier) classes.push(`fr-btn--${data.modifier}`);
|
|
83
|
+
data.classes = classes;
|
|
84
|
+
data.attributes = attributes;
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_formatNavigation (data) {
|
|
89
|
+
return {
|
|
90
|
+
id: 'navigation',
|
|
91
|
+
links: this.data?.items?.map(item => ({ ...formatLink(item), active: item.isCurrent })).filter(item => item)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { Header };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
import { formatLink } from '../../core/format-link.js';
|
|
3
|
+
class Navigation extends Component {
|
|
4
|
+
constructor (data) {
|
|
5
|
+
super(data, 'navigation');
|
|
6
|
+
}
|
|
7
|
+
get ejsPath () {
|
|
8
|
+
return 'src/component/navigation/template/ejs/navigation.ejs';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async format () {
|
|
12
|
+
return {
|
|
13
|
+
id: 'navigation',
|
|
14
|
+
items: this.data?.items?.map(item => this._formatItem(item)).filter(item => item)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_formatItem (item) {
|
|
19
|
+
switch (item.type) {
|
|
20
|
+
case 'link':
|
|
21
|
+
return this._formatLink(item)
|
|
22
|
+
|
|
23
|
+
case 'menu':
|
|
24
|
+
return this._formatMenu(item);
|
|
25
|
+
|
|
26
|
+
case 'mega-menu':
|
|
27
|
+
return this._formatMegaMenu(item);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_formatLink (link) {
|
|
32
|
+
return {
|
|
33
|
+
...formatLink(link),
|
|
34
|
+
active: link.isCurrent,
|
|
35
|
+
type: 'link'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_formatMenu (menu) {
|
|
40
|
+
return {
|
|
41
|
+
id: menu.id,
|
|
42
|
+
collapseId: this.uniqueId(),
|
|
43
|
+
type: 'menu',
|
|
44
|
+
label: menu.label ?? menu.text,
|
|
45
|
+
active: menu.isCurrent,
|
|
46
|
+
items: menu.items.map(link => this._formatLink(link))
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_formatMegaMenu (megaMenu) {
|
|
51
|
+
return {
|
|
52
|
+
id: megaMenu.id,
|
|
53
|
+
collapseId: this.uniqueId(),
|
|
54
|
+
type: 'mega-menu',
|
|
55
|
+
label: megaMenu.label ?? megaMenu.text,
|
|
56
|
+
href: megaMenu.url,
|
|
57
|
+
active: megaMenu.isCurrent,
|
|
58
|
+
categories: megaMenu.categories.map(category => this._formatCategory(category))
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_formatCategory (category) {
|
|
63
|
+
return {
|
|
64
|
+
id: category.id,
|
|
65
|
+
...formatLink(category),
|
|
66
|
+
active: category.isCurrent,
|
|
67
|
+
items: category.items.map(link => this._formatLink(link))
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { Navigation };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
import { formatLink } from '../../core/format-link.js';
|
|
3
|
+
|
|
4
|
+
class Sidemenu extends Component {
|
|
5
|
+
constructor (data) {
|
|
6
|
+
super(data, 'sidemenu');
|
|
7
|
+
}
|
|
8
|
+
get ejsPath () {
|
|
9
|
+
return 'src/dsfr/component/sidemenu/template/ejs/sidemenu.ejs';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async format () {
|
|
13
|
+
return {
|
|
14
|
+
id: 'sidemenu',
|
|
15
|
+
collapseId: this.uniqueId(),
|
|
16
|
+
titleId: this.uniqueId(),
|
|
17
|
+
title: this.data.title,
|
|
18
|
+
items: this.data?.items?.map(item => this._formatItem(item)).filter(item => item)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_formatItem (item) {
|
|
23
|
+
switch (item.type) {
|
|
24
|
+
case 'menu':
|
|
25
|
+
return this._formatMenu(item);
|
|
26
|
+
|
|
27
|
+
default:
|
|
28
|
+
return this._formatLink(item);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_formatLink (link) {
|
|
33
|
+
return {
|
|
34
|
+
...formatLink(link),
|
|
35
|
+
active: link.isCurrent,
|
|
36
|
+
type: 'link'
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_formatMenu (menu) {
|
|
41
|
+
return {
|
|
42
|
+
id: menu.id,
|
|
43
|
+
isCollapsible: menu.isCollapsible,
|
|
44
|
+
collapseId: this.uniqueId(),
|
|
45
|
+
type: 'menu',
|
|
46
|
+
label: menu.label ?? menu.text,
|
|
47
|
+
href: menu.url,
|
|
48
|
+
active: menu.isCurrent,
|
|
49
|
+
items: menu.items.map(item => this._formatItem(item))
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async render () {
|
|
54
|
+
return await super.render();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { Sidemenu };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Component } from '../component.js';
|
|
2
|
+
|
|
3
|
+
class Skiplink extends Component {
|
|
4
|
+
constructor(data) {
|
|
5
|
+
super(data, 'skiplink');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get ejsPath() {
|
|
9
|
+
return 'src/dsfr/component/skiplink/template/ejs/skiplinks.ejs';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async format() {
|
|
13
|
+
return {
|
|
14
|
+
id: 'skiplink',
|
|
15
|
+
items: [
|
|
16
|
+
{
|
|
17
|
+
attributes: {
|
|
18
|
+
id: 'skiplink-content',
|
|
19
|
+
},
|
|
20
|
+
label: this.data.resource.skiplink.content,
|
|
21
|
+
href: '#content',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
attributes: {
|
|
25
|
+
id: 'skiplink-navigation',
|
|
26
|
+
},
|
|
27
|
+
label: this.data.resource.skiplink.navigation,
|
|
28
|
+
href: '#menu-modal',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
attributes: {
|
|
32
|
+
id: 'skiplink-search',
|
|
33
|
+
},
|
|
34
|
+
label: this.data.resource.skiplink.search,
|
|
35
|
+
href: '#search-modal',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
attributes: {
|
|
39
|
+
id: 'skiplink-footer',
|
|
40
|
+
},
|
|
41
|
+
label: this.data.resource.skiplink.footer,
|
|
42
|
+
href: '#footer',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { Skiplink };
|