@gouvfr/dsfr-roller 1.0.9 → 1.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gouvfr/dsfr-roller",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Le module `dsfr-roller` permet de publier le site de documentation du Système de Design de l’État - DSFR",
5
5
  "keywords": [
6
6
  "Système de Design de l'État",
@@ -56,7 +56,7 @@
56
56
  ],
57
57
  "main": "./index.js",
58
58
  "dependencies": {
59
- "@gouvfr/dsfr-forge": "=1.0.9",
59
+ "@gouvfr/dsfr-forge": "=1.0.10",
60
60
  "@gouvfr/dsfr-publisher": "npm:@gouvfr/dsfr@1.13.1",
61
61
  "deepmerge": "^4.3.1",
62
62
  "ejs": "^3.1.10",
@@ -2,6 +2,27 @@ import { Node } from '../../../node.js'
2
2
 
3
3
  class CardContainerDirective extends Node {
4
4
  structure (data) {
5
+ const col = data.properties.col || '';
6
+ const colSm = data.properties.colSm || '';
7
+ const colMd = data.properties.colMd || '';
8
+ const colLg = data.properties.colLg || '';
9
+
10
+ return super.structure(
11
+ col || colSm || colMd || colLg ? {
12
+ type: 'htmlContainer',
13
+ tagName: 'div',
14
+ classes: [
15
+ col ? `fr-col-${col}` : '',
16
+ colSm ? `fr-col-sm-${colSm}` : '',
17
+ colMd ? `fr-col-md-${colMd}` : '',
18
+ colLg ? `fr-col-lg-${colLg}` : ''
19
+ ],
20
+ children: [this.structureCard(data)]
21
+ } : this.structureCard(data)
22
+ );
23
+ }
24
+
25
+ structureCard (data) {
5
26
  this._data = data;
6
27
  const horizontal = data.properties.horizontal === true;
7
28
  const download = data.properties.download === true;
@@ -12,7 +33,7 @@ class CardContainerDirective extends Node {
12
33
  const hintStart = this.structureHintStart;
13
34
  const hintEnd = this.structureHintEnd;
14
35
 
15
- return super.structure({
36
+ return {
16
37
  type: 'htmlContainer',
17
38
  tagName: 'div',
18
39
  classes: ['fr-card', 'fr-enlarge-link', horizontal ? 'fr-card--horizontal' : '', download ? 'fr-card--download' : ''],
@@ -60,7 +81,7 @@ class CardContainerDirective extends Node {
60
81
  ]
61
82
  }
62
83
  ]
63
- });
84
+ };
64
85
  }
65
86
 
66
87
  get structureHintStart() {
@@ -74,10 +95,12 @@ class CardContainerDirective extends Node {
74
95
  {
75
96
  type: 'paragraph',
76
97
  classes: ['fr-card__detail'],
77
- children: {
78
- type: 'text',
79
- value: this._data.properties.hintStart
80
- }
98
+ children: [
99
+ {
100
+ type: 'text',
101
+ value: this._data.properties.hintStart
102
+ }
103
+ ]
81
104
  }
82
105
  ]
83
106
  }
@@ -96,10 +119,12 @@ class CardContainerDirective extends Node {
96
119
  {
97
120
  type: 'paragraph',
98
121
  classes: ['fr-card__detail'],
99
- children: {
100
- type: 'text',
101
- value: this._data.properties.hintEnd
102
- }
122
+ children: [
123
+ {
124
+ type: 'text',
125
+ value: this._data.properties.hintEnd
126
+ }
127
+ ]
103
128
  }
104
129
  ]
105
130
  }
@@ -23,18 +23,22 @@ class TileContainerDirective extends Node {
23
23
  }
24
24
 
25
25
  structureTile(data) {
26
- const noBorder = data.properties.noBorder || false;
26
+ const classes = ['fr-tile'];
27
+ if (data.properties.enlargeLink || title?.children[0]?.type === 'link') classes.push('fr-enlarge-link');
28
+ if (data.properties.noBorder) classes.push('fr-tile--no-border');
29
+ if (data.properties.horizontal) classes.push('fr-tile--horizontal');
30
+ if (data.properties.download) classes.push('fr-tile--download');
27
31
  const pictogramUrl = data.properties.pictogram;
28
32
  const image = Node.getImageChild(data);
29
33
  const contentChildren = data.children.filter(child => !Node.getImageChild(child));
30
- const title = contentChildren[0];
34
+ const title = contentChildren.find(child => child.type === 'heading');
31
35
  const description = contentChildren[1];
32
36
  const details = contentChildren[2];
33
37
 
34
38
  return {
35
39
  type: 'htmlContainer',
36
40
  tagName: 'div',
37
- classes: ['fr-tile', noBorder ? 'fr-tile--no-border' : ''],
41
+ classes: classes,
38
42
  children: [
39
43
  {
40
44
  type: 'htmlContainer',
@@ -0,0 +1,20 @@
1
+ import { Node } from '../../node.js'
2
+
3
+ class ColContainerDirective extends Node {
4
+ constructor (data) {
5
+ super(data, 'div');
6
+ this.attributes.addClass('fr-col-' + data.properties.col || 12);
7
+ if (data.properties.colSm) this.attributes.addClass('fr-col-sm-' + data.properties.colSm);
8
+ if (data.properties.colMd) this.attributes.addClass('fr-col-md-' + data.properties.colMd);
9
+ if (data.properties.colLg) this.attributes.addClass('fr-col-lg-' + data.properties.colLg);
10
+ if (data.properties.alignV) this.attributes.addClass('fr-col--' + data.properties.alignV);
11
+ if (data.properties.offset) this.attributes.addClass('fr-col-offset-' + data.properties.offset);
12
+ if (data.properties.offsetSm) this.attributes.addClass('fr-col-offset-sm-' + data.properties.offsetSm);
13
+ if (data.properties.offsetMd) this.attributes.addClass('fr-col-offset-md-' + data.properties.offsetMd);
14
+ if (data.properties.offsetLg) this.attributes.addClass('fr-col-offset-lg-' + data.properties.offsetLg);
15
+ }
16
+ }
17
+
18
+ ColContainerDirective.NAME = 'fr-col';
19
+
20
+ export { ColContainerDirective };
@@ -10,9 +10,11 @@ class HpSliceVideoContainerDirective extends Node {
10
10
  const imgUrl = data.imgUrl;
11
11
  const imgDarkUrl = data.imgDarkUrl;
12
12
  const buttonLabel = data.properties.button;
13
- const vimeoUrl = data.properties.vimeo;
14
- const youtubeUrl = data.properties.youtube;
15
13
  const modalId = data.properties.modalId;
14
+ const videoProperties = {
15
+ videoId: data.videoId,
16
+ provider: data.provider,
17
+ };
16
18
 
17
19
  let structureCategoryLabel = {};
18
20
  if (categoryLabel) structureCategoryLabel = {
@@ -26,22 +28,6 @@ class HpSliceVideoContainerDirective extends Node {
26
28
  ]
27
29
  };
28
30
 
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
31
  return super.structure({
46
32
  type: 'htmlContainer',
47
33
  tagName: 'div',
@@ -217,11 +203,10 @@ class HpSliceVideoContainerDirective extends Node {
217
203
  ]
218
204
  },
219
205
  {
220
- type: 'htmlContainer',
221
- tagName: 'iframe',
222
- classes: ['fr-responsive-vid'],
223
- attributes: {
224
- ...videoAttributes
206
+ type: 'leafDirective',
207
+ name: 'dsfr-doc-video',
208
+ properties: {
209
+ ...videoProperties,
225
210
  }
226
211
  }
227
212
  ]
@@ -24,6 +24,8 @@ 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 { GridContainerDirective } from './directive/core/grid-container-directive.js';
28
+ import { ColContainerDirective } from './directive/core/col-container-directive.js';
27
29
  import { HpHeroContainerDirective } from './directive/home/hp-hero-container-directive.js';
28
30
  import { HpDiscoverContainerDirective } from './directive/home/hp-discover-container-directive.js';
29
31
  import { HpDiscoverTileContainerDirective } from './directive/home/hp-discover-tile-container-directive.js';
@@ -112,7 +114,9 @@ const DIRECTIVE_CONTAINERS = [
112
114
  TableContainerDirective,
113
115
  TabContainerDirective,
114
116
  TabsContainerDirective,
115
- AnatomyContainerDirective
117
+ AnatomyContainerDirective,
118
+ GridContainerDirective,
119
+ ColContainerDirective
116
120
  ];
117
121
  const DIRECTIVE_LEAFS = [
118
122
  ButtonLeafDirective,
@@ -1,10 +1,12 @@
1
1
  import { instantiateElements } from '../main/core/element.js'
2
+ import { SearchBar } from '../main/elements/search-bar/index.js';
2
3
  import { InjectSvg } from './inject-svg.js'
3
4
  import { ShowOnScroll } from './show-on-scroll.js'
4
5
  import { StopVideoOnClose } from './stop-video-on-close.js'
5
6
 
6
- window.onload = () => {
7
- instantiateElements('img[src$=".svg"]', InjectSvg);
8
- instantiateElements('[dsfr-doc-show-on-scroll]', ShowOnScroll);
9
- instantiateElements('.fr-modal', StopVideoOnClose);
7
+ window.onload = async () => {
8
+ await instantiateElements('#search', SearchBar);
9
+ await instantiateElements('img[src$=".svg"]', InjectSvg);
10
+ await instantiateElements('[dsfr-doc-show-on-scroll]', ShowOnScroll);
11
+ await instantiateElements('.fr-modal', StopVideoOnClose);
10
12
  };
@@ -4,69 +4,68 @@ import config from './tarteaucitron/config';
4
4
  import tacLang from './tarteaucitron/lang';
5
5
 
6
6
  import {
7
- youtube,
8
- vimeo,
9
- // dailymotion,
10
- // twitterembed,
11
- // instagram,
12
- // facebook,
7
+ vimeo,
8
+ // youtube,
9
+ // dailymotion,
10
+ // twitterembed,
11
+ // instagram,
12
+ // facebook,
13
13
  } from './tarteaucitron/services';
14
14
 
15
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
- }
16
+ constructor(data) {
17
+ this._data = data;
18
+ this._legalNoticeLink =
19
+ getCurrentRepo() + this._data?.tarteaucitron?.legalNoticeLink;
20
+ this._services = [
21
+ vimeo,
22
+ // youtube,
23
+ // dailymotion,
24
+ // twitterembed,
25
+ // instagram,
26
+ // facebook,
27
+ ];
28
+ this.tac = tarteaucitron;
29
+ }
30
30
 
31
- get services() {
32
- return this._services.map((service) => service.key);
33
- }
31
+ get services() {
32
+ return this._services.map((service) => service.key);
33
+ }
34
34
 
35
- get tacConfig() {
36
- return config(this._legalNoticeLink);
37
- }
35
+ get tacConfig() {
36
+ return config(this._legalNoticeLink);
37
+ }
38
38
 
39
- addServices() {
40
- this._services.forEach(
41
- (service) => (this.tac.services[service.key] = service)
42
- );
43
- }
39
+ addServices() {
40
+ this._services.forEach(
41
+ (service) => (this.tac.services[service.key] = service)
42
+ );
43
+ }
44
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
- }
45
+ addJobs() {
46
+ this.tac.job = this.tac.job || [];
47
+ this._services.forEach((service) => {
48
+ if (!this.tac.job.includes(service.key)) this.tac.job.push(service.key);
49
+ });
50
+ }
52
51
 
53
- loadLang() {
54
- Object.assign(
55
- this.tac.lang,
56
- tacLang(this._data?.tarteaucitron, this._legalNoticeLink)
57
- );
58
- }
52
+ loadLang() {
53
+ Object.assign(
54
+ this.tac.lang,
55
+ tacLang(this._data?.tarteaucitron, this._legalNoticeLink)
56
+ );
57
+ }
59
58
 
60
- initTac() {
61
- this.loadLang();
62
- this.tac.init(this.tacConfig);
63
- }
59
+ initTac() {
60
+ this.loadLang();
61
+ this.tac.init(this.tacConfig);
62
+ }
64
63
 
65
- init() {
66
- this.addServices();
67
- this.addJobs();
68
- this.initTac();
69
- }
64
+ init() {
65
+ this.addServices();
66
+ this.addJobs();
67
+ this.initTac();
68
+ }
70
69
  }
71
70
 
72
71
  export { ConsentManagementPlatform };