cec-nuxt-lib 0.4.3 → 0.4.4

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.4.3"
4
+ "version": "0.4.4"
5
5
  }
@@ -39,13 +39,15 @@ const abbr = (data) => {
39
39
  return `<abbr title="${text(data.entryDescription)}">${text(data.entryTitle)}</abbr>`;
40
40
  };
41
41
 
42
- const accordionComponent = (props: any) => {
43
- let id = props.block?.id;
44
- let html = props.block?.value?.expandAll
42
+ const accordion = (data) => {
43
+ if (!data.id) {
44
+ data.id = data.sys.id;
45
+ }
46
+ let html = data.expandAll
45
47
  ? `
46
48
  <div class="text-end">
47
49
  <button
48
- id="${props.block?.id}"
50
+ id="${data.id}"
49
51
  class="expand-all btn btn-outline-success"
50
52
  type="button"
51
53
  >
@@ -61,22 +63,29 @@ const accordionComponent = (props: any) => {
61
63
  </p>
62
64
  <section class="access-acc-container">
63
65
  `;
64
- let acc = props.block?.value?.accordionSection;
65
- acc.forEach((e, i) => {
66
- let accId = `${id}_${i}`;
66
+ data.accordionSection.forEach((e, i) => {
67
+ let accId = `${data.id}_${i}`;
67
68
  html += `
68
- <input class="${id}"
69
+ <input class="${data.id}"
69
70
  id="${accId}"
70
71
  type="checkbox"
71
72
  />
72
73
  <label for="${accId}">${e.accLabel}</label>
73
- <article>${e.content}</article>
74
+ <article>${e.content ? e.content : ''}
75
+ ${e.genericList ? genList(e.genericList, accId) : ''}
76
+
77
+ </article>
78
+
74
79
  `;
75
80
  });
76
81
  html += '</section>';
77
82
  return html;
78
83
  };
79
84
 
85
+ const accordionComponent = (props: any) => {
86
+ return accordion({ ...props.block.value, id: props.block.id });
87
+ };
88
+
80
89
  const anchor = (data) => {
81
90
  return `<${data.tag} id="${data.id}">${data.text}</${data.tag}>`;
82
91
  };
@@ -600,11 +609,14 @@ const processUri = (uri) => {
600
609
  };
601
610
 
602
611
  const genericList = (props: any) => {
603
- let item = props.block?.value;
604
- let id = props.block.id;
612
+ return genList(props.block.value, props.block.id);
613
+ };
614
+ const genList = (item, id) => {
615
+ let heading = item.title ? `<h2 class="fs-4 mt-3">${item.title}</h2>` : '';
616
+
605
617
  return listItems.value[id]
606
618
  ? `
607
- <h2 class="fs-4 mt-3">${item.title}</h2>
619
+ ${heading}
608
620
  <ul>
609
621
  ${listItems.value[id].reduce((acc, e) => {
610
622
  return e.sys.dataFormat === 'webpage'
@@ -630,6 +642,8 @@ const myInlineEntry = (props: any) => {
630
642
  let data = props.block?.value;
631
643
  let id = props.block?.id;
632
644
  switch (props.block?.value.sys.contentTypeId) {
645
+ case 'accordion':
646
+ return accordion(data);
633
647
  case 'abbreviation':
634
648
  return abbr(data);
635
649
  case 'anchor':
@@ -707,7 +721,6 @@ onMounted(() => {
707
721
  // Expand all buttons
708
722
  const expandAll = (btn) => {
709
723
  btn.addEventListener('click', (e) => {
710
- console.log(btn.id);
711
724
  const op = btn.innerText;
712
725
  btn.innerText = op === 'Expand all' ? 'Close all' : 'Expand all';
713
726
  Array.from(document.getElementsByClassName(btn.id)).forEach(
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.3",
2
+ "version": "0.4.4",
3
3
  "name": "cec-nuxt-lib",
4
4
  "description": "Nuxt components and assets",
5
5
  "license": "MIT",