cec-nuxt-lib 0.3.5 → 0.3.7

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/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "cec-nuxt-lib",
3
3
  "configKey": "cec-nuxt-lib",
4
- "version": "0.3.5"
4
+ "version": "0.3.7"
5
5
  }
@@ -82,7 +82,7 @@ const anchor = (data) => {
82
82
 
83
83
  const carousel = (data, id) => {
84
84
  // Create the indicators
85
- let indicators = data.carouselComponent.reduce((acc, e, i) => {
85
+ let indicators = data.carouselComponent.reduce((acc, _, i) => {
86
86
  return (
87
87
  acc +
88
88
  `<button type="button" data-bs-target="#${id}-indicators" data-bs-slide-to="${i}" class="${i ? '' : 'active'}" aria-current="${i ? '' : 'true'}" aria-label="Slide ${i}">${i + 1}</button>`
@@ -169,6 +169,46 @@ const centralColumn = (props: any) => {
169
169
  }
170
170
  };
171
171
 
172
+ const centralPromotionalSection = (props: any) => {
173
+ let item = props.block?.value;
174
+ return `
175
+ <div class="row">
176
+ <div class="py-5 bg-cec-central-promo-section">
177
+ <div class="cec-meta-outer px-4">
178
+ <div class="cec-meta-content col-lg-8 col-md-12 px-3 py-4 px-md-5">
179
+ <div>${item.content}</div>
180
+ </div>
181
+ </div>
182
+ </div>
183
+ </div>
184
+ `;
185
+ };
186
+
187
+ const contactDetails = (data) => {
188
+ let address = data.buildingName ? `<p class="mb-0">${data.buildingName}` : '';
189
+ address += data.streetAddress
190
+ ? makeAddressItem('streetAddress', data.streetAddress)
191
+ : '';
192
+ address += data.locality
193
+ ? makeAddressItem('addressLocality', data.locality)
194
+ : '';
195
+ address += data.county ? makeAddressItem('addressRegion', data.county) : '';
196
+ address += data.postCode ? makeAddressItem('postalCode', data.postCode) : '';
197
+ let contact = data.phoneNumber
198
+ ? makeAddressItem('telephone', data.phoneNumber)
199
+ : '';
200
+ contact += data.email ? makeAddressItem('email', data.email) : '';
201
+ return `
202
+ <div itemscope itemtype="https://schema.org/Organization">
203
+ ${makeAddressItem('name', data.name)}
204
+ <div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress">
205
+ ${address}
206
+ </div>
207
+ ${contact}
208
+ </div>
209
+ `;
210
+ };
211
+
172
212
  const container = (data) => {
173
213
  if (data.closeContainer) {
174
214
  return `</div>${data.singleChoice === 'cec-main-column' ? '</div>' : ''}`;
@@ -181,10 +221,10 @@ const container = (data) => {
181
221
  `;
182
222
  };
183
223
 
184
- const promotionalFullWidthImageWithOverlay = (props: any) => {
224
+ const fullWidthImageWithOverlay = (props: any) => {
185
225
  let item = props.block?.value;
186
226
  let overlay;
187
- if (!item.overlayText) {
227
+ if (item.overlayImage) {
188
228
  overlay = `
189
229
  <div class="cec-cent-promo-txt-wrap top-50 end-0">
190
230
  <div
@@ -197,7 +237,7 @@ const promotionalFullWidthImageWithOverlay = (props: any) => {
197
237
  />
198
238
  </div>
199
239
  </div>`;
200
- } else {
240
+ } else if (item.overlayText) {
201
241
  overlay = `
202
242
  <div class="position-relative">
203
243
  <div class="row g-0">
@@ -211,17 +251,19 @@ const promotionalFullWidthImageWithOverlay = (props: any) => {
211
251
  <div
212
252
  class="cec-cent-promo-txt bg-tog-for-chil-green col-lg-8 col-md-12 mx-auto my-md-4 mb-md-5 pb-2"
213
253
  >
214
- <div class="text-white text-center p-4">${item.overlayText}</div>
254
+ <div class="text-white text-center p-3">${item.overlayText}</div>
215
255
  </div>
216
256
  </div>
217
257
  </div>
218
258
  </div>
219
259
  </div>
220
260
  `;
261
+ } else {
262
+ overlay = '';
221
263
  }
222
264
  return `
223
265
  <div class="position-relative">
224
- <div class="row g-0 mb-3">
266
+ <div class="row g-0">
225
267
  <img
226
268
  class="img-fluid"
227
269
  alt="${item.image.altText}"
@@ -233,137 +275,23 @@ const promotionalFullWidthImageWithOverlay = (props: any) => {
233
275
  `;
234
276
  };
235
277
 
236
- const promotionalContrastRegion = (props: any) => {
237
- let item = props.block?.value;
238
- const bgClass = `bg-${item.colour.toLowerCase().replace(/\s/g, '-')}`;
239
- let textCol = `
240
- <div class="p-2 ps-lg-4 ms-lg-5 col">
241
- <div class="cec-pull-column pe-md-5">${item.content}</div>
242
- </div>`;
243
- let imageCol = `
244
- <div class="col">
245
- <img
246
- class="img-fluid"
247
- alt="${item.image.altText}"
248
- src="${baseUrl.value}${item.image.asset.sys.uri}"
249
- />
250
- </div>`;
251
- return `
252
- <div
253
- class="${bgClass} cec-pull-container pe-md-0 d-flex flex-column flex-md-row justify-content-center ps-4 align-items-center py-5 mb-4"
254
- >
255
- ${item.alignment === 'left' ? imageCol + textCol : textCol + imageCol}
256
- </div>
257
- `;
258
- };
259
-
260
- const promotionalFullWidthImageWithSideOverlay = (props: any) => {
278
+ const fullWidthImageWithSideOverlay = (props: any) => {
261
279
  let item = props.block?.value;
262
280
  return `
263
281
  <div class="position-relative side-overlay-section">
264
282
  <div class="row g-0">
265
- <img
266
- class="img-fluid"
267
- alt="${item.image.altText}"
268
- src="${baseUrl.value}${item.image.asset.sys.uri}"
269
- />
270
- <div
271
- style="position: absolute"
272
- class="my-side-overlay col-lg-6 bg-cec-green ms-lg-5 mt-lg-5 p-2 top-0"
273
- >
274
- <h2 class="text-white promo-heading display-6">${item.heading}</h2>
275
- <div class="text-white">${item.content}</div>
276
- </div>
283
+ <img
284
+ class="img-fluid"
285
+ alt="${item.image.altText}"
286
+ src="${baseUrl.value}${item.image.asset.sys.uri}"
287
+ />
288
+ <div style="position: absolute;" class="my-side-overlay col-lg-6 bg-cec-green ms-lg-5 mt-lg-5 p-2 top-0 ">
289
+ <h2 class="text-white promo-heading display-6">${item.heading}</h2>
290
+ <div class="text-white "> ${item.content}</div>
277
291
  </div>
278
- </div>
279
- `;
280
- };
281
-
282
- const centralPromotionalSection = (props: any) => {
283
- let item = props.block?.value;
284
- return `
285
- <div class="row">
286
- <div class="py-5 bg-cec-central-promo-section">
287
- <div class="cec-meta-outer px-4">
288
- <div class="cec-meta-content col-lg-8 col-md-12 px-3 py-4 px-md-5">
289
- <div>${item.content}</div>
290
- </div>
291
292
  </div>
292
293
  </div>
293
- </div>
294
- `;
295
- };
296
-
297
- const promotionalBannerWithText = (props: any) => {
298
- let item = props.block?.value;
299
- let overlay = `
300
- <div class="cec-cent-promo-txt-wrap col-md-11 top-50 w-100 text-center">
301
- <h1
302
- class="mb-0 cec-cent-promo-txt d-md-inline-block px-3 pt-1 pb-3 promo-heading bg-cec-green text-white"
303
- >
304
- ${item.text}
305
- </h1>
306
- </div>
307
294
  `;
308
- let paras = item.html.replace(/<\/?p>/g, '').split('\n');
309
- if (paras.length) {
310
- overlay = `
311
- <div
312
- class="cec-cent-promo-txt-wrap col-lg-8 col-md-11 text-center top-50 w-100 "
313
- >
314
- <div id="overlay" class="bg-tog-for-chil-green d-md-inline-block py-3 px-4 ">
315
- <h1
316
- class="hp-promo-heading text-white d-md-inline-block display-md-5 text-center px-3 pt-1 pb-0"
317
- style="font-family: myriad-pro, sans-serif"
318
- >
319
- ${paras[0]}
320
- </h1>
321
- <div class="d-flex justify-content-center mt-2 strapline text-white">
322
- ${paras[1]}
323
- </div>
324
- </div>
325
- </div>`;
326
- }
327
- return `
328
- <div class="position-relative row g-0 mb-3">
329
- <img
330
- alt="${item.bannerImage.altText}"
331
- src="${baseUrl.value}${item.bannerImage.asset.sys.uri}"
332
- />
333
- ${overlay}
334
- </div>
335
- `;
336
- };
337
-
338
- const processUri = (uri) => {
339
- return uri.toLowerCase().replace(/%e2/g, '%E2');
340
- };
341
-
342
- const genericList = (props: any) => {
343
- let item = props.block?.value;
344
- let id = props.block.id;
345
- return listItems.value[id]
346
- ? `
347
- <h2 class="fs-4 mt-3">${item.title}</h2>
348
- <ul>
349
- ${listItems.value[id].reduce((acc, e) => {
350
- return e.sys.dataFormat === 'webpage'
351
- ? `${acc}
352
- <li><a href="${processUri(e.sys.uri)}">${e.title}</a></li>
353
- `
354
- : `${acc}
355
- <li>
356
- <a href="${processUri(e.sys.uri)}"
357
- >${e.title[0].toUpperCase()}${e.title.slice(1)}
358
- (${e.sys.contentTypeId.toUpperCase()},
359
- ${sizeString(e.sys.properties.fileSize)})
360
- </a>
361
- </li>
362
- `;
363
- }, '')}
364
- </ul>
365
- `
366
- : '';
367
295
  };
368
296
 
369
297
  const heroUnit = (props: any) => {
@@ -374,8 +302,8 @@ const heroUnit = (props: any) => {
374
302
  const horizontalTable = (props: any) => {
375
303
  let data = props.block?.value;
376
304
  let rows = data.tableRow.reduce((acc, r) => {
377
- let cols = r.columns.reduce((acc, c) => {
378
- return `<td>${c}</td>`;
305
+ let cols = r.columns.reduce((acc1, c) => {
306
+ return acc1 + `<td>${c}</td>`;
379
307
  }, '');
380
308
  return `${acc}<tr><th scope="row">${r.headerCell}</th>${cols}</tr>`;
381
309
  }, '');
@@ -383,10 +311,10 @@ const horizontalTable = (props: any) => {
383
311
  <div class="table-responsive">
384
312
  <table class="usr_TableDefault">
385
313
  <caption class="hidden">${data.caption}</caption>
386
- <tbody>
387
- ${rows}
388
- </tbody>
389
- </table>
314
+ <tbody>
315
+ ${rows}
316
+ </tbody>
317
+ </table>
390
318
  </div>
391
319
  `;
392
320
  };
@@ -409,6 +337,63 @@ const linkEntry = (data) => {
409
337
  return `<a title="${data.title || ''}" href="${data.target}">${data.text}</a>`;
410
338
  };
411
339
 
340
+ const makeAddressItem = (prop, text) => {
341
+ if (prop === 'email') {
342
+ return `<p class="mb-0"> <a href="mailto:${text}" itemprop="${prop}>${text}</a></p>`;
343
+ }
344
+ return `<p class="mb-0" itemprop="${prop}">${text}</p>`;
345
+ };
346
+
347
+ const makeQuestions = (data, id) => {
348
+ data.question.forEach((qu, j) => {
349
+ qu.stack = [0];
350
+ qu.buttons = qu.responseForQuestionComponent.reduce((acc, r, i) => {
351
+ return (
352
+ acc +
353
+ `<div class="col w-auto ps-0 pe-3">
354
+ <button
355
+ type="button"
356
+ id="${id}_${j}_${i}"
357
+ class="cec-button question-btns"
358
+ >
359
+ ${r.buttonText}
360
+ </button>
361
+ </div>`
362
+ );
363
+ }, '');
364
+ questions.value.push({ id: id, question: data.question, stack: [0] });
365
+ });
366
+
367
+ let buttons = data.question[0].buttons;
368
+ return `
369
+ <div class="mt-3 questions">
370
+ <h2>Answer the questions:</h2>
371
+ <fieldset class="p-1 mb-3">
372
+ <legend>${data.entryTitle}</legend>
373
+ <div class="ps-2 align-items-end question row g-0">
374
+ <div id="${id}_display">${data.question[0].question}</div>
375
+ <div class="row row-cols-auto btns-div" id="${id}_buttons">
376
+ ${buttons}
377
+ </div>
378
+ </div>
379
+ <button
380
+ type="button"
381
+ class="mt-4 btn btn-light previous"
382
+ id="${id}_prev"
383
+ >
384
+ Previous question
385
+ </button>
386
+ <button
387
+ type="button"
388
+ class="mt-4 btn btn-light reset"
389
+ id="${id}_reset"
390
+ >
391
+ Restart
392
+ </button>
393
+ </fieldset>
394
+ </div>`;
395
+ };
396
+
412
397
  const processTime = (str) => {
413
398
  let suffix = 'am';
414
399
  if (str === '00:00') {
@@ -472,6 +457,174 @@ const openingHours = (data) => {
472
457
  `;
473
458
  };
474
459
 
460
+ const promotionalBannerWithText = (props: any) => {
461
+ let item = props.block?.value;
462
+ let overlay = `
463
+ <div class="cec-cent-promo-txt-wrap col-md-11 top-50 w-100 text-center">
464
+ <h1
465
+ class="mb-0 cec-cent-promo-txt d-md-inline-block px-3 pt-1 pb-3 promo-heading bg-cec-green text-white"
466
+ >
467
+ ${item.text}
468
+ </h1>
469
+ </div>
470
+ `;
471
+ let paras = item.html.replace(/<\/?p>/g, '').split('\n');
472
+ if (paras.length) {
473
+ overlay = `
474
+ <div
475
+ class="cec-cent-promo-txt-wrap col-lg-8 col-md-11 text-center top-50 w-100 "
476
+ >
477
+ <div id="overlay" class="bg-tog-for-chil-green d-md-inline-block py-3 px-4 ">
478
+ <h1
479
+ class="hp-promo-heading text-white d-md-inline-block display-md-5 text-center px-3 pt-1 pb-0"
480
+ style="font-family: myriad-pro, sans-serif"
481
+ >
482
+ ${paras[0]}
483
+ </h1>
484
+ <div class="d-flex justify-content-center mt-2 strapline text-white">
485
+ ${paras[1]}
486
+ </div>
487
+ </div>
488
+ </div>`;
489
+ }
490
+ return `
491
+ <div class="position-relative row g-0 mb-3">
492
+ <img
493
+ alt="${item.bannerImage.altText}"
494
+ src="${baseUrl.value}${item.bannerImage.asset.sys.uri}"
495
+ />
496
+ ${overlay}
497
+ </div>
498
+ `;
499
+ };
500
+ const promotionalContrastRegion = (props: any) => {
501
+ let item = props.block?.value;
502
+ const bgClass = `bg-${item.colour.toLowerCase().replace(/\s/g, '-')}`;
503
+ let textCol = `
504
+ <div class="p-2 ps-lg-4 ms-lg-5 col">
505
+ <div class="cec-pull-column pe-md-5">${item.content}</div>
506
+ </div>`;
507
+ let imageCol = `
508
+ <div class="col">
509
+ <img
510
+ class="img-fluid"
511
+ alt="${item.image.altText}"
512
+ src="${baseUrl.value}${item.image.asset.sys.uri}"
513
+ />
514
+ </div>`;
515
+ return `
516
+ <div
517
+ class="${bgClass} cec-pull-container pe-md-0 d-flex flex-column flex-md-row justify-content-center ps-4 align-items-center py-5 mb-4"
518
+ >
519
+ ${item.alignment === 'left' ? imageCol + textCol : textCol + imageCol}
520
+ </div>
521
+ `;
522
+ };
523
+
524
+ const promotionalFullWidthImageWithOverlay = (props: any) => {
525
+ let item = props.block?.value;
526
+ let overlay;
527
+ if (!item.overlayText) {
528
+ overlay = `
529
+ <div class="cec-cent-promo-txt-wrap top-50 end-0">
530
+ <div
531
+ class="cec-cent-promo-txt text-center bg-tog-for-chil-green col-lg-8 col-md-10 mx-auto my-md-4 mb-md-5 pb-2"
532
+ >
533
+ <img
534
+ class="px-4 mx-auto mt-2"
535
+ alt="${item.overlayImage.altText}"
536
+ src="${baseUrl.value}${item.overlayImage.asset.sys.uri}"
537
+ />
538
+ </div>
539
+ </div>`;
540
+ } else {
541
+ overlay = `
542
+ <div class="position-relative">
543
+ <div class="row g-0">
544
+ <img
545
+ class="img-fluid"
546
+ alt="${item.image.altText}"
547
+ src="${baseUrl.value}${item.image.asset.sys.uri}"
548
+ />
549
+ <div class="cec-cent-promo-txt-wrap top-50 end-0">
550
+ <div class="container-md">
551
+ <div
552
+ class="cec-cent-promo-txt bg-tog-for-chil-green col-lg-8 col-md-12 mx-auto my-md-4 mb-md-5 pb-2"
553
+ >
554
+ <div class="text-white text-center p-4">${item.overlayText}</div>
555
+ </div>
556
+ </div>
557
+ </div>
558
+ </div>
559
+ </div>
560
+ `;
561
+ }
562
+ return `
563
+ <div class="position-relative">
564
+ <div class="row g-0 mb-3">
565
+ <img
566
+ class="img-fluid"
567
+ alt="${item.image.altText}"
568
+ src="${baseUrl.value}${item.image.asset.sys.uri}"
569
+ />
570
+ ${overlay}
571
+ </div>
572
+ </div>
573
+ `;
574
+ };
575
+ const promotionalFullWidthImageWithSideOverlay = (props: any) => {
576
+ let item = props.block?.value;
577
+ return `
578
+ <div class="position-relative side-overlay-section">
579
+ <div class="row g-0">
580
+ <img
581
+ class="img-fluid"
582
+ alt="${item.image.altText}"
583
+ src="${baseUrl.value}${item.image.asset.sys.uri}"
584
+ />
585
+ <div
586
+ style="position: absolute"
587
+ class="my-side-overlay col-lg-6 bg-cec-green ms-lg-5 mt-lg-5 p-2 top-0"
588
+ >
589
+ <h2 class="text-white promo-heading display-6">${item.heading}</h2>
590
+ <div class="text-white">${item.content}</div>
591
+ </div>
592
+ </div>
593
+ </div>
594
+ `;
595
+ };
596
+
597
+ const processUri = (uri) => {
598
+ return uri.toLowerCase().replace(/%e2/g, '%E2');
599
+ };
600
+
601
+ const genericList = (props: any) => {
602
+ let item = props.block?.value;
603
+ let id = props.block.id;
604
+ return listItems.value[id]
605
+ ? `
606
+ <h2 class="fs-4 mt-3">${item.title}</h2>
607
+ <ul>
608
+ ${listItems.value[id].reduce((acc, e) => {
609
+ return e.sys.dataFormat === 'webpage'
610
+ ? `${acc}
611
+ <li><a href="${processUri(e.sys.uri)}">${e.title}</a></li>
612
+ `
613
+ : `${acc}
614
+ <li>
615
+ <a href="${processUri(e.sys.uri)}"
616
+ >${e.title[0].toUpperCase()}${e.title.slice(1)}
617
+ (${e.sys.contentTypeId.toUpperCase()},
618
+ ${sizeString(e.sys.properties.fileSize)})
619
+ </a>
620
+ </li>
621
+ `;
622
+ }, '')}
623
+ </ul>
624
+ `
625
+ : '';
626
+ };
627
+
475
628
  const myInlineEntry = (props: any) => {
476
629
  let data = props.block?.value;
477
630
  let id = props.block?.id;
@@ -482,6 +635,8 @@ const myInlineEntry = (props: any) => {
482
635
  return anchor(data);
483
636
  case 'carousel':
484
637
  return carousel(data, id);
638
+ case 'contactDetails':
639
+ return contactDetails(data);
485
640
  case 'container':
486
641
  return container(data);
487
642
  case 'linkEntry':
@@ -495,56 +650,6 @@ const myInlineEntry = (props: any) => {
495
650
  }
496
651
  };
497
652
 
498
- const makeQuestions = (data, id) => {
499
- data.question.forEach((qu, j) => {
500
- qu.stack = [0];
501
- qu.buttons = qu.responseForQuestionComponent.reduce((acc, r, i) => {
502
- return (
503
- acc +
504
- `<div class="col w-auto ps-0 pe-3">
505
- <button
506
- type="button"
507
- id="${id}_${j}_${i}"
508
- class="cec-button question-btns"
509
- >
510
- ${r.buttonText}
511
- </button>
512
- </div>`
513
- );
514
- }, '');
515
- questions.value.push({ id: id, question: data.question, stack: [0] });
516
- });
517
-
518
- let buttons = data.question[0].buttons;
519
- return `
520
- <div class="mt-3 questions">
521
- <h2>Answer the questions:</h2>
522
- <fieldset class="p-1 mb-3">
523
- <legend>${data.entryTitle}</legend>
524
- <div class="ps-2 align-items-end question row g-0">
525
- <div id="${id}_display">${data.question[0].question}</div>
526
- <div class="row row-cols-auto btns-div" id="${id}_buttons">
527
- ${buttons}
528
- </div>
529
- </div>
530
- <button
531
- type="button"
532
- class="mt-4 btn btn-light previous"
533
- id="${id}_prev"
534
- >
535
- Previous question
536
- </button>
537
- <button
538
- type="button"
539
- class="mt-4 btn btn-light reset"
540
- id="${id}_reset"
541
- >
542
- Restart
543
- </button>
544
- </fieldset>
545
- </div>`;
546
- };
547
-
548
653
  const renderer = createRenderer({
549
654
  blocks: {
550
655
  _inlineEntry: myInlineEntry,
@@ -553,6 +658,8 @@ const renderer = createRenderer({
553
658
  accordionComponent: accordionComponent,
554
659
  cecButton: cecButton,
555
660
  centralColumn: centralColumn,
661
+ fullWidthImageWithOverlay: fullWidthImageWithOverlay,
662
+ fullWidthImageWithSideOverlay: fullWidthImageWithSideOverlay,
556
663
  centralPromotionalSection: centralPromotionalSection,
557
664
  promotionalFullWidthImageWithOverlay: promotionalFullWidthImageWithOverlay,
558
665
  promotionalFullWidthImageWithSideOverlay:
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.5",
2
+ "version": "0.3.7",
3
3
  "name": "cec-nuxt-lib",
4
4
  "description": "Nuxt components and assets",
5
5
  "license": "MIT",
@@ -31,7 +31,6 @@
31
31
  "@nuxt/kit": "^3.11.2"
32
32
  },
33
33
  "devDependencies": {
34
- "@contensis/canvas-html": "^1.2.0",
35
34
  "@nuxt/devtools": "latest",
36
35
  "@nuxt/eslint-config": "^0.2.0",
37
36
  "@nuxt/module-builder": "^0.5.5",