@gouvfr/dsfr-roller 1.0.6 → 1.0.8

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.
Files changed (94) hide show
  1. package/env/local/env.json +1 -0
  2. package/env/prod/env.json +1 -0
  3. package/env/staging/env.json +1 -0
  4. package/package.json +3 -2
  5. package/src/component/components/button.js +2 -2
  6. package/src/component/components/header.js +1 -1
  7. package/src/component/components/sidemenu.js +1 -0
  8. package/src/integration/bundler.js +14 -2
  9. package/src/node/directive/{doc → components/accordion}/accordion-container-directive.js +4 -4
  10. package/src/node/directive/{doc → components/accordion}/accordions-group-container-directive.js +1 -1
  11. package/src/node/directive/{doc → components/button}/button-leaf-directive.js +3 -3
  12. package/src/node/directive/components/card/card-container-directive.js +114 -0
  13. package/src/node/directive/{doc → components/table}/table-container-directive.js +7 -7
  14. package/src/node/directive/{doc → components/tabs}/tab-container-directive.js +1 -1
  15. package/src/node/directive/{doc → components/tabs}/tabs-container-directive.js +1 -1
  16. package/src/node/directive/components/tile/tile-container-directive.js +135 -0
  17. package/src/node/directive/core/grid-container-directive.js +15 -0
  18. package/src/node/directive/doc/{anatomy-container-directive.js → guidance/anatomy-container-directive.js} +2 -2
  19. package/src/node/directive/doc/{guideline-container-directive.js → guidance/guideline-container-directive.js} +3 -3
  20. package/src/node/directive/doc/{guidelines-container-directive.js → guidance/guidelines-container-directive.js} +1 -1
  21. package/src/node/directive/doc/{pin-leaf-directive.js → guidance/pin-leaf-directive.js} +1 -1
  22. package/src/node/directive/doc/page-item-card-container-directive.js +53 -0
  23. package/src/node/directive/doc/page-item-list-leaf-directive.js +33 -0
  24. package/src/node/directive/doc/tab-navigation-container-directive.js +1 -1
  25. package/src/node/directive/doc/video-leaf-directive.js +44 -0
  26. package/src/node/directive/home/hp-analytics-container-directive.js +67 -0
  27. package/src/node/directive/home/hp-community-container-directive.js +78 -0
  28. package/src/node/directive/home/hp-community-tile-container-directive.js +57 -0
  29. package/src/node/directive/home/hp-discover-container-directive.js +41 -0
  30. package/src/node/directive/home/hp-discover-tile-container-directive.js +81 -0
  31. package/src/node/directive/home/hp-faq-container-directive.js +60 -0
  32. package/src/node/directive/home/hp-goals-container-directive.js +37 -0
  33. package/src/node/directive/home/hp-hero-container-directive.js +54 -0
  34. package/src/node/directive/home/hp-news-container-directive.js +53 -0
  35. package/src/node/directive/home/hp-showcase-card-container-directive.js +81 -0
  36. package/src/node/directive/home/hp-showcase-container-directive.js +55 -0
  37. package/src/node/directive/home/hp-slice-video-container-directive.js +246 -0
  38. package/src/node/generic/link-node.js +1 -1
  39. package/src/node/node-factory.js +45 -11
  40. package/src/page/head/head.js +3 -0
  41. package/src/page/head/resource.js +17 -0
  42. package/src/page/head/share.js +23 -5
  43. package/src/page/head/stylesheets.js +2 -1
  44. package/src/page/page.js +3 -1
  45. package/src/page/scripts/scripts.js +2 -1
  46. package/src/script/home/index.js +10 -0
  47. package/src/script/home/inject-svg.js +28 -0
  48. package/src/script/home/show-on-scroll.js +24 -0
  49. package/src/script/home/stop-video-on-close.js +20 -0
  50. package/src/script/main/cmp/index.js +72 -0
  51. package/src/script/main/cmp/tarteaucitron/config.js +34 -0
  52. package/src/script/main/cmp/tarteaucitron/lang.js +14 -0
  53. package/src/script/main/cmp/tarteaucitron/services.js +9142 -0
  54. package/src/script/main/cmp/tarteaucitron/tarteaucitron.js +3301 -0
  55. package/src/script/main/core/element.js +7 -3
  56. package/src/script/main/core/get-current-repo.js +6 -0
  57. package/src/script/main/core/get-query.js +12 -0
  58. package/src/script/main/core/replace-fragments.js +4 -0
  59. package/src/script/main/elements/pagination/index.js +23 -0
  60. package/src/script/main/elements/pagination/pagination-item.js +94 -0
  61. package/src/script/main/elements/pagination/pagination-list.js +131 -0
  62. package/src/script/main/elements/search-bar/index.js +64 -0
  63. package/src/script/main/elements/search-bar/results/result-item.js +13 -0
  64. package/src/script/main/elements/search-bar/results/results-button.js +20 -0
  65. package/src/script/main/elements/search-bar/results/results-dropdown.js +48 -0
  66. package/src/script/main/elements/search-bar/results/results-empty.js +21 -0
  67. package/src/script/main/elements/search-bar/results/results-list.js +19 -0
  68. package/src/script/main/index.js +11 -5
  69. package/src/script/main/minisearch/index.js +46 -0
  70. package/src/script/search/elements/result-card.js +46 -0
  71. package/src/script/search/elements/results-count.js +21 -0
  72. package/src/script/search/elements/results-empty.js +21 -0
  73. package/src/script/search/elements/results-list.js +25 -0
  74. package/src/script/search/elements/search-page.js +44 -0
  75. package/src/script/search/index.js +9 -0
  76. package/src/style/home/_analytics.scss +105 -0
  77. package/src/style/home/_community.scss +222 -0
  78. package/src/style/home/_discover.scss +208 -0
  79. package/src/style/home/_faq.scss +24 -0
  80. package/src/style/home/_goals.scss +53 -0
  81. package/src/style/home/_hero.scss +135 -0
  82. package/src/style/home/_news.scss +26 -0
  83. package/src/style/home/_showcase.scss +129 -0
  84. package/src/style/home/_slice-video.scss +168 -0
  85. package/src/style/home/index.scss +13 -0
  86. package/src/style/main/components/_dsfr-doc-pagination.scss +4 -0
  87. package/src/style/main/components/_dsfr-doc-searchbar.scss +54 -0
  88. package/src/style/main/components/_index.scss +3 -1
  89. package/src/style/search/_search-page.scss +0 -0
  90. package/src/style/search/index.scss +1 -0
  91. package/src/template/templates/home-template.js +4 -3
  92. package/src/template/templates/search-template.js +15 -8
  93. package/static/img/placeholder.16x9.png +0 -0
  94. package/src/script/main/elements/searchbar.js +0 -18
@@ -0,0 +1,246 @@
1
+ import { Node } from '../../node.js';
2
+ class HpSliceVideoContainerDirective extends Node {
3
+ constructor (data) {
4
+ super(data);
5
+ }
6
+
7
+ structure (data) {
8
+ const title = data.children[0];
9
+ const categoryLabel = data.properties.category;
10
+ const imgUrl = data.imgUrl;
11
+ const imgDarkUrl = data.imgDarkUrl;
12
+ const buttonLabel = data.properties.button;
13
+ const vimeoUrl = data.properties.vimeo;
14
+ const youtubeUrl = data.properties.youtube;
15
+ const modalId = data.properties.modalId;
16
+
17
+ let structureCategoryLabel = {};
18
+ if (categoryLabel) structureCategoryLabel = {
19
+ type: 'paragraph',
20
+ classes: ['dsfr-doc-hp-slice-video__category'],
21
+ children: [
22
+ {
23
+ type: 'text',
24
+ value: categoryLabel
25
+ }
26
+ ]
27
+ };
28
+
29
+ const videoAttributes = {
30
+ frameborder: '0',
31
+ allowfullscreen: '',
32
+ };
33
+
34
+ if (vimeoUrl) {
35
+ videoAttributes.title= 'Vimeo',
36
+ videoAttributes.allow = 'autoplay; fullscreen; picture-in-picture; clipboard-write; encrypted-media',
37
+ videoAttributes.src = 'https://player.vimeo.com/video/' + vimeoUrl.match(/\/([^\/]+)$/)[1];
38
+ } else if (youtubeUrl) {
39
+ videoAttributes.title= 'Youtube',
40
+ videoAttributes.allow = 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share',
41
+ videoAttributes.referrerpolicy = "strict-origin-when-cross-origin",
42
+ videoAttributes.src = 'https://www.youtube.com/embed/' + youtubeUrl.match(/\/([^\/]+)$/)[1];
43
+ }
44
+
45
+ return super.structure({
46
+ type: 'htmlContainer',
47
+ tagName: 'div',
48
+ classes: ['dsfr-doc-hp-slice-video', 'fr-background-contrast--info'],
49
+ attributes: {
50
+ 'dsfr-doc-show-on-scroll': ''
51
+ },
52
+ children: [
53
+ {
54
+ type: 'htmlContainer',
55
+ tagName: 'style',
56
+ children: [
57
+ {
58
+ type: 'text',
59
+ value: `
60
+ @media (min-width: 48em) {
61
+ .dsfr-doc-hp-slice-video > .fr-container::before {
62
+ background-image: url('${data.imgBgUrl}');
63
+ }
64
+ }
65
+
66
+ [data-fr-theme='dark'] {
67
+ @media (min-width: 48em) {
68
+ .dsfr-doc-hp-slice-video > .fr-container::before {
69
+ background-image: url('${data.imgDarkBgUrl}');
70
+ }
71
+ }
72
+ }
73
+ `
74
+ }
75
+ ]
76
+ },
77
+ {
78
+ type: 'htmlContainer',
79
+ tagName: 'div',
80
+ classes: ['fr-container'],
81
+ children: [
82
+ {
83
+ type: 'htmlContainer',
84
+ tagName: 'div',
85
+ classes: ['fr-grid-row', 'fr-grid-row--gutters'],
86
+ children: [
87
+ {
88
+ type: 'htmlContainer',
89
+ tagName: 'div',
90
+ classes: ['dsfr-doc-hp-slice-video__content', 'fr-col-12', 'fr-col-md-5'],
91
+ children: [
92
+ structureCategoryLabel,
93
+ {
94
+ type: 'htmlContainer',
95
+ tagName: 'h2',
96
+ classes: ['dsfr-doc-hp-slice-video__title'],
97
+ children: title.children
98
+ },
99
+ {
100
+ type: 'htmlContainer',
101
+ tagName: 'button',
102
+ classes: ['dsfr-doc-hp-slice-video__btn', 'fr-btn', 'fr-btn--secondary'],
103
+ attributes: {
104
+ 'data-fr-opened': 'false',
105
+ 'aria-controls': modalId
106
+ },
107
+ children: [
108
+ {
109
+ type: 'text',
110
+ value: buttonLabel
111
+ }
112
+ ]
113
+ },
114
+ ]
115
+ },
116
+ {
117
+ type: 'htmlContainer',
118
+ tagName: 'div',
119
+ classes: ['dsfr-doc-hp-slice-video__img', 'fr-col-12', 'fr-col-md-6', 'fr-col-offset-md-1'],
120
+ attributes: {
121
+ 'aria-controls': modalId,
122
+ 'data-fr-opened': 'false',
123
+ },
124
+ children: [
125
+ {
126
+ type: 'image',
127
+ classes: ['dsfr-doc-hp-slice-video__img--light'],
128
+ attributes: {
129
+ src: imgUrl,
130
+ alt: ''
131
+ }
132
+ },
133
+ {
134
+ type: 'image',
135
+ classes: ['dsfr-doc-hp-slice-video__img--dark'],
136
+ attributes: {
137
+ src: imgDarkUrl,
138
+ alt: ''
139
+ }
140
+ }
141
+ ]
142
+ }
143
+ ]
144
+ }
145
+ ]
146
+ },
147
+ {
148
+ type: 'htmlContainer',
149
+ tagName: 'dialog',
150
+ classes: ['fr-modal'],
151
+ attributes: {
152
+ id: modalId,
153
+ 'aria-labelledby': modalId + '-title',
154
+ role: 'dialog'
155
+ },
156
+ children: [
157
+ {
158
+ type: 'htmlContainer',
159
+ tagName: 'div',
160
+ classes: ['fr-container', 'fr-container--fluid', 'fr-container-md'],
161
+ children: [
162
+ {
163
+ type: 'htmlContainer',
164
+ tagName: 'div',
165
+ classes: ['fr-grid-row', 'fr-grid-row--center'],
166
+ children: [
167
+ {
168
+ type: 'htmlContainer',
169
+ tagName: 'div',
170
+ classes: ['fr-col-12', 'fr-col-md-10', 'fr-col-lg-8'],
171
+ children: [
172
+ {
173
+ type: 'htmlContainer',
174
+ tagName: 'div',
175
+ classes: ['fr-modal__body'],
176
+ children: [
177
+ {
178
+ type: 'htmlContainer',
179
+ tagName: 'div',
180
+ classes: ['fr-modal__header'],
181
+ children: [
182
+ {
183
+ type: 'htmlContainer',
184
+ tagName: 'button',
185
+ classes: ['fr-btn', 'fr-btn--close'],
186
+ attributes: {
187
+ type: 'button',
188
+ 'aria-controls': modalId,
189
+ 'title': data.fragments.button.close,
190
+ },
191
+ children: [
192
+ {
193
+ type: 'text',
194
+ value: data.fragments.button.close
195
+ }
196
+ ]
197
+ }
198
+ ]
199
+ },
200
+ {
201
+ type: 'htmlContainer',
202
+ tagName: 'div',
203
+ classes: ['fr-modal__content'],
204
+ children: [
205
+ {
206
+ type: 'htmlContainer',
207
+ tagName: 'h3',
208
+ classes: ['fr-modal__title'],
209
+ attributes: {
210
+ id: modalId + '-title'
211
+ },
212
+ children: [
213
+ {
214
+ type: 'text',
215
+ value: title.children[0].value
216
+ }
217
+ ]
218
+ },
219
+ {
220
+ type: 'htmlContainer',
221
+ tagName: 'iframe',
222
+ classes: ['fr-responsive-vid'],
223
+ attributes: {
224
+ ...videoAttributes
225
+ }
226
+ }
227
+ ]
228
+ }
229
+ ]
230
+ }
231
+ ]
232
+ }
233
+ ]
234
+ }
235
+ ]
236
+ }
237
+ ]
238
+ }
239
+ ]
240
+ });
241
+ }
242
+ }
243
+
244
+ HpSliceVideoContainerDirective.NAME = 'hp-slice-video';
245
+
246
+ export { HpSliceVideoContainerDirective };
@@ -10,7 +10,7 @@ class LinkNode extends Node {
10
10
  href: data.url,
11
11
  blank
12
12
  };
13
- if (blank) actionData.attributes = { title: `${this.text} - ${data.fragments.blank}` };
13
+ if (blank) actionData.attributes = { title: `${data.title || this.text} - ${data.fragments.blank}` };
14
14
  this._action = new Action(actionData);
15
15
  }
16
16
  async render () {
@@ -24,21 +24,38 @@ import { TableRowNode } from './gfm/table-row-node.js';
24
24
  import { TableHeaderNode } from './gfm/table-header-node.js';
25
25
  import { TableCellNode } from './gfm/table-cell-node.js';
26
26
  import { NodeRoot } from './node-root.js';
27
+ import { HpHeroContainerDirective } from './directive/home/hp-hero-container-directive.js';
28
+ import { HpDiscoverContainerDirective } from './directive/home/hp-discover-container-directive.js';
29
+ import { HpDiscoverTileContainerDirective } from './directive/home/hp-discover-tile-container-directive.js';
30
+ import { HpSliceVideoContainerDirective } from './directive/home/hp-slice-video-container-directive.js';
31
+ import { HpGoalsContainerDirective } from './directive/home/hp-goals-container-directive.js';
32
+ import { HpShowcaseContainerDirective } from './directive/home/hp-showcase-container-directive.js';
33
+ import { HpShowcaseCardContainerDirective } from './directive/home/hp-showcase-card-container-directive.js';
34
+ import { HpCommunityContainerDirective } from './directive/home/hp-community-container-directive.js';
35
+ import { HpCommunityTileContainerDirective } from './directive/home/hp-community-tile-container-directive.js';
36
+ import { HpNewsContainerDirective } from './directive/home/hp-news-container-directive.js';
37
+ import { HpFaqContainerDirective } from './directive/home/hp-faq-container-directive.js';
38
+ import { HpAnalyticsContainerDirective } from './directive/home/hp-analytics-container-directive.js';
39
+ import { AccordionContainerDirective } from './directive/components/accordion/accordion-container-directive.js';
40
+ import { AccordionsGroupContainerDirective } from './directive/components/accordion/accordions-group-container-directive.js';
41
+ import { ButtonLeafDirective } from './directive/components/button/button-leaf-directive.js'
42
+ import { CardContainerDirective } from './directive/components/card/card-container-directive.js';
43
+ import { TableContainerDirective } from './directive/components/table/table-container-directive.js';
44
+ import { TabContainerDirective } from './directive/components/tabs/tab-container-directive.js'
45
+ import { TabsContainerDirective } from './directive/components/tabs/tabs-container-directive.js'
46
+ import { TileContainerDirective } from './directive/components/tile/tile-container-directive.js';
47
+ import { AnatomyContainerDirective } from './directive/doc/guidance/anatomy-container-directive.js';
48
+ import { PinLeafDirective } from './directive/doc/guidance/pin-leaf-directive.js';
49
+ import { GuidelineContainerDirective } from './directive/doc/guidance/guideline-container-directive.js';
50
+ import { GuidelinesContainerDirective } from './directive/doc/guidance/guidelines-container-directive.js';
27
51
  import { TabNavigationContainerDirective } from './directive/doc/tab-navigation-container-directive.js';
28
52
  import { StorybookLeafDirective } from './directive/doc/storybook-leaf-directive.js';
29
53
  import { FigmaLeafDirective } from './directive/doc/figma-leaf-directive.js';
30
- import { AnatomyContainerDirective } from './directive/doc/anatomy-container-directive.js';
31
- import { PinLeafDirective } from './directive/doc/pin-leaf-directive.js';
32
- import { AccordionContainerDirective } from './directive/doc/accordion-container-directive.js';
33
- import { AccordionsGroupContainerDirective } from './directive/doc/accordions-group-container-directive.js';
34
- import { GuidelineContainerDirective } from './directive/doc/guideline-container-directive.js';
35
- import { GuidelinesContainerDirective } from './directive/doc/guidelines-container-directive.js';
36
- import { TableContainerDirective } from './directive/doc/table-container-directive.js';
37
- import { TabContainerDirective } from './directive/doc/tab-container-directive.js'
38
- import { TabsContainerDirective } from './directive/doc/tabs-container-directive.js'
54
+ import { PageItemListLeafDirective } from './directive/doc/page-item-list-leaf-directive.js';
55
+ import { PageItemCardContainerDirective } from './directive/doc/page-item-card-container-directive.js';
56
+ import { VideoLeafDirective } from './directive/doc/video-leaf-directive.js';
39
57
  import { ImageTextDirective } from './directive/doc/image-text-directive.js'
40
58
  import { ChangelogLeafDirective } from './directive/doc/changelog-leaf-directive.js'
41
- import { ButtonLeafDirective } from './directive/doc/button-leaf-directive.js'
42
59
 
43
60
 
44
61
  const NODES = [
@@ -72,8 +89,23 @@ const NODES = [
72
89
  const nodesMap = new Map(NODES.map(Node => [Node.TYPE, Node]));
73
90
 
74
91
  const DIRECTIVE_CONTAINERS = [
92
+ HpHeroContainerDirective,
93
+ HpDiscoverContainerDirective,
94
+ HpDiscoverTileContainerDirective,
95
+ HpSliceVideoContainerDirective,
96
+ HpGoalsContainerDirective,
97
+ HpShowcaseContainerDirective,
98
+ HpShowcaseCardContainerDirective,
99
+ HpCommunityContainerDirective,
100
+ HpCommunityTileContainerDirective,
101
+ HpNewsContainerDirective,
102
+ HpFaqContainerDirective,
103
+ HpAnalyticsContainerDirective,
75
104
  AccordionContainerDirective,
76
105
  AccordionsGroupContainerDirective,
106
+ CardContainerDirective,
107
+ PageItemCardContainerDirective,
108
+ TileContainerDirective,
77
109
  GuidelineContainerDirective,
78
110
  GuidelinesContainerDirective,
79
111
  TabNavigationContainerDirective,
@@ -87,7 +119,9 @@ const DIRECTIVE_LEAFS = [
87
119
  StorybookLeafDirective,
88
120
  FigmaLeafDirective,
89
121
  ChangelogLeafDirective,
90
- PinLeafDirective
122
+ PinLeafDirective,
123
+ VideoLeafDirective,
124
+ PageItemListLeafDirective
91
125
  ];
92
126
  const DIRECTIVE_TEXTS = [
93
127
  ImageTextDirective
@@ -3,6 +3,7 @@ import { Canonical } from './canonical.js';
3
3
  import { Stylesheets } from './stylesheets.js';
4
4
  import { Renderable } from '../../core/renderable.js';
5
5
  import { Favicon } from './favicon.js';
6
+ import { Resource } from './resource.js';
6
7
  import { Share } from './share.js';
7
8
 
8
9
  class Head extends Renderable {
@@ -12,6 +13,7 @@ class Head extends Renderable {
12
13
  this._title = new Title(data);
13
14
  this._canonical = new Canonical(data);
14
15
  this._favicon = new Favicon(data);
16
+ this._resource = new Resource(data);
15
17
  this._share = new Share(data);
16
18
  this._stylesheets = new Stylesheets(data);
17
19
  }
@@ -27,6 +29,7 @@ class Head extends Renderable {
27
29
  ${await this._favicon.render()}
28
30
  ${await this._share.render()}
29
31
  ${await this._stylesheets.render()}
32
+ ${await this._resource.render()}
30
33
  </head>
31
34
  `;
32
35
  }
@@ -0,0 +1,17 @@
1
+ import { Renderable } from '../../core/renderable.js';
2
+
3
+ class Resource extends Renderable {
4
+ async render() {
5
+ const resource = {
6
+ meta: this._data.resource.meta,
7
+ search: this._data.resource.search,
8
+ pagination: this._data.resource.pagination,
9
+ consent: this._data.resource.consent
10
+ };
11
+ return `<script>
12
+ window.resource = ${JSON.stringify(resource)};
13
+ </script>`;
14
+ }
15
+ }
16
+
17
+ export { Resource };
@@ -1,13 +1,31 @@
1
1
  import { Renderable } from '../../core/renderable.js';
2
2
 
3
3
  class Share extends Renderable {
4
- constructor (data) {
5
- super(data);
4
+ constructor(data) {
5
+ super(data, 'share');
6
+ this._resource = data.resource || {};
7
+ this._title = `${data.title} - ${this._resource?.meta?.title}`;
8
+ this._description = data.description || this._resource?.meta?.description;
9
+ this._cover = data.cover || '/static/img/placeholder.16x9.png';
10
+ this._url = this._resource?.meta?.baseUrl + data.url;
11
+ this._locale = `${data.lang}_${data.lang.toUpperCase()}`;
6
12
  }
7
13
 
8
- async render () {
9
- // facebook, twitter, linkedin, bluesky
10
- return '<!-- Share -->';
14
+ async render() {
15
+ return `
16
+ <meta property="og:title" content="${this._title}">
17
+ <meta property="og:description" content="${this._description}">
18
+ <meta property="og:image" content="${this._cover}">
19
+ <meta property="og:type" content="website">
20
+ <meta property="og:url" content="${this._url}">
21
+ <meta property="og:locale" content="${this._locale}">
22
+
23
+ <meta name="twitter:card" content="summary_large_image">
24
+ <meta name="twitter:title" content="${this._title}">
25
+ <meta name="twitter:description" content="${this._description}">
26
+ <meta name="twitter:site" content="@gouvernementFR">
27
+ <meta name="twitter:image" content="${this._cover}">
28
+ `;
11
29
  }
12
30
  }
13
31
 
@@ -11,7 +11,8 @@ const DEFAULT_LIB_FILES = [
11
11
  ];
12
12
 
13
13
  const STYLES_MAP = new Map([
14
- ['search', 'dsfr-doc-search']
14
+ ['search', 'dsfr-doc-search'],
15
+ ['home', 'dsfr-doc-home'],
15
16
  ]);
16
17
 
17
18
  class Stylesheets extends Renderable {
package/src/page/page.js CHANGED
@@ -26,8 +26,10 @@ class Page extends Renderable {
26
26
  keywords: this.data.keywords,
27
27
  summary: this.data.summary,
28
28
  excerpt: this.data.excerpt,
29
+ cover: this.data.cover,
29
30
  boost: this.data.boost,
30
- text: this._html.text
31
+ text: this._html.text,
32
+ section: this.data.section,
31
33
  }
32
34
  }
33
35
 
@@ -11,7 +11,8 @@ const DEFAULT_LIB_FILES = [
11
11
  ];
12
12
 
13
13
  const SCRIPTS_MAP = new Map([
14
- ['search', 'dsfr-doc-search']
14
+ ['search', 'dsfr-doc-search'],
15
+ ['home', 'dsfr-doc-home']
15
16
  ]);
16
17
 
17
18
  class Scripts extends Renderable {
@@ -0,0 +1,10 @@
1
+ import { instantiateElements } from '../main/core/element.js'
2
+ import { InjectSvg } from './inject-svg.js'
3
+ import { ShowOnScroll } from './show-on-scroll.js'
4
+ import { StopVideoOnClose } from './stop-video-on-close.js'
5
+
6
+ window.onload = () => {
7
+ instantiateElements('img[src$=".svg"]', InjectSvg);
8
+ instantiateElements('[dsfr-doc-show-on-scroll]', ShowOnScroll);
9
+ instantiateElements('.fr-modal', StopVideoOnClose);
10
+ };
@@ -0,0 +1,28 @@
1
+ import { Element } from '../main/core/element.js'
2
+
3
+ class InjectSvg extends Element {
4
+ init() {
5
+ this._src = this._element.getAttribute('src');
6
+ this._class = this._element.getAttribute('class');
7
+ this._ariaHidden = this._element.getAttribute('aria-hidden');
8
+ this._alt = this._element.getAttribute('alt');
9
+ this.replaceSvg();
10
+ }
11
+
12
+ replaceSvg() {
13
+ fetch(this._src)
14
+ .then(response => response.text())
15
+ .then(svg => {
16
+ const parser = new DOMParser();
17
+ const svgDocument = parser.parseFromString(svg, 'image/svg+xml');
18
+ const svgElement = svgDocument.querySelector('svg');
19
+ if (this._class) svgElement.setAttribute('class', this._class);
20
+ if (this._ariaHidden !== null) svgElement.setAttribute('aria-hidden', this._ariaHidden);
21
+ if (this._alt) svgElement.setAttribute('aria-label', this._alt);
22
+ this._element.parentNode.insertBefore(svgElement, this._element);
23
+ this._element.remove();
24
+ });
25
+ }
26
+ }
27
+
28
+ export { InjectSvg };
@@ -0,0 +1,24 @@
1
+ import { Element } from '../main/core/element.js'
2
+
3
+ class ShowOnScroll extends Element {
4
+ init() {
5
+ this._observer = new IntersectionObserver(entries => {
6
+ entries.forEach(entry => {
7
+ if (entry.isIntersecting) {
8
+ entry.target.setAttribute('dsfr-doc-in-view', true);
9
+ return;
10
+ }
11
+
12
+ entry.target.setAttribute('dsfr-doc-in-view', false);
13
+ });
14
+ }, {
15
+ rootMargin: '0px 0px -35% 0px',
16
+ threshold: 0
17
+ });
18
+
19
+ this._observer.observe(this._element);
20
+ }
21
+
22
+ }
23
+
24
+ export { ShowOnScroll };
@@ -0,0 +1,20 @@
1
+ import { Element } from '../main/core/element.js'
2
+
3
+ class StopVideoOnClose extends Element {
4
+ init() {
5
+ this._element.addEventListener('dsfr.conceal', () => {
6
+ this._iframe = this._element.querySelector('iframe');
7
+ if (this._iframe) {
8
+ this._iframe.setAttribute('src', this._iframe.getAttribute('src'));
9
+ }
10
+
11
+ this._video = this._element.querySelector('video');
12
+ if (this._video) {
13
+ this._video.pause();
14
+ }
15
+ });
16
+ }
17
+
18
+ }
19
+
20
+ export { StopVideoOnClose };
@@ -0,0 +1,72 @@
1
+ import { tarteaucitron } from './tarteaucitron/tarteaucitron';
2
+ import { getCurrentRepo } from '../core/get-current-repo';
3
+ import config from './tarteaucitron/config';
4
+ import tacLang from './tarteaucitron/lang';
5
+
6
+ import {
7
+ youtube,
8
+ vimeo,
9
+ // dailymotion,
10
+ // twitterembed,
11
+ // instagram,
12
+ // facebook,
13
+ } from './tarteaucitron/services';
14
+
15
+ class ConsentManagementPlatform {
16
+ constructor(data) {
17
+ this._data = data;
18
+ this._legalNoticeLink =
19
+ getCurrentRepo() + this._data?.tarteaucitron?.legalNoticeLink;
20
+ this._services = [
21
+ youtube,
22
+ vimeo,
23
+ // dailymotion,
24
+ // twitterembed,
25
+ // instagram,
26
+ // facebook,
27
+ ];
28
+ this.tac = tarteaucitron;
29
+ }
30
+
31
+ get services() {
32
+ return this._services.map((service) => service.key);
33
+ }
34
+
35
+ get tacConfig() {
36
+ return config(this._legalNoticeLink);
37
+ }
38
+
39
+ addServices() {
40
+ this._services.forEach(
41
+ (service) => (this.tac.services[service.key] = service)
42
+ );
43
+ }
44
+
45
+ addJobs() {
46
+ this.tac.job = this.tac.job || [];
47
+ this._services.forEach((service) => {
48
+ if (!this.tac.job.includes(service.key))
49
+ this.tac.job.push(service.key);
50
+ });
51
+ }
52
+
53
+ loadLang() {
54
+ Object.assign(
55
+ this.tac.lang,
56
+ tacLang(this._data?.tarteaucitron, this._legalNoticeLink)
57
+ );
58
+ }
59
+
60
+ initTac() {
61
+ this.loadLang();
62
+ this.tac.init(this.tacConfig);
63
+ }
64
+
65
+ init() {
66
+ this.addServices();
67
+ this.addJobs();
68
+ this.initTac();
69
+ }
70
+ }
71
+
72
+ export { ConsentManagementPlatform };
@@ -0,0 +1,34 @@
1
+ export default function (link) {
2
+ return {
3
+ privacyUrl: link /* Privacy policy url */,
4
+ bodyPosition:
5
+ 'top' /* or top to bring it as first element for accessibility */,
6
+ hashtag: '#consent-modal' /* Open the panel with this hashtag */,
7
+ cookieName: 'tarteaucitron' /* Cookie name */,
8
+ orientation: 'bottom' /* Banner position (top - bottom) */,
9
+ groupServices: false /* Group services by category */,
10
+ showDetailsOnClick: false /* Click to expand the description */,
11
+ serviceDefaultState: 'wait' /* Default state (true - wait - false) */,
12
+ showAlertSmall: false /* Show the small banner on bottom right */,
13
+ cookieslist: false /* Show the cookie list */,
14
+ closePopup: false /* Show a close X on the banner */,
15
+ showIcon: false /* Show cookie icon to manage cookies */,
16
+ // "iconSrc": "", /* Optionnal: URL or base64 encoded image */
17
+ iconPosition:
18
+ 'BottomRight' /* BottomRight, BottomLeft, TopRight and TopLeft */,
19
+ adblocker: false /* Show a Warning if an adblocker is detected */,
20
+ DenyAllCta: true /* Show the deny all button */,
21
+ AcceptAllCta: true /* Show the accept all button when highPrivacy on */,
22
+ highPrivacy: true /* HIGHLY RECOMMANDED Disable auto consent */,
23
+ handleBrowserDNTRequest: false /* If Do Not Track == 1, disallow all */,
24
+ removeCredit: true /* Remove credit link */,
25
+ moreInfoLink: true /* Show more info link */,
26
+ useExternalCss: true /* If false, the tarteaucitron.css file will be loaded */,
27
+ useExternalJs: true /* If false, the tarteaucitron.js file will be loaded */,
28
+ // "cookieDomain": ".my-multisite-domaine.fr", /* Shared cookie for multisite */
29
+ readmoreLink: link /* Change the default readmore link */,
30
+ mandatory: false /* Show a message about mandatory cookies */,
31
+ mandatoryCta: true /* Show the disabled accept button when mandatory on */,
32
+ // "customCloserId": "" /* Optional a11y: Custom element ID used to open the panel */
33
+ };
34
+ }
@@ -0,0 +1,14 @@
1
+ import { replaceFragment } from '../../core/replace-fragments.js';
2
+
3
+ export default function (tarteaucitron, legalNoticeLink) {
4
+ return {
5
+ ...tarteaucitron,
6
+ alertBigPrivacy: {
7
+ title: tarteaucitron?.alertBigPrivacy?.title,
8
+ content: replaceFragment(
9
+ tarteaucitron?.alertBigPrivacy?.content,
10
+ legalNoticeLink
11
+ ),
12
+ },
13
+ };
14
+ }