cec-nuxt-lib 0.4.3 → 0.4.5

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.5"
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,32 @@ 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}`;
68
+ let article = `${e.content ? e.content : ''}${e.genericList ? genList(e.genericList, accId) : ''}`;
69
+ if (!article.length) {
70
+ article = '<p>Nothing to display at present</p>';
71
+ }
67
72
  html += `
68
- <input class="${id}"
73
+ <input class="${data.id}"
69
74
  id="${accId}"
70
75
  type="checkbox"
71
76
  />
72
77
  <label for="${accId}">${e.accLabel}</label>
73
- <article>${e.content}</article>
78
+ <article>
79
+
80
+ </article>
81
+
74
82
  `;
75
83
  });
76
84
  html += '</section>';
77
85
  return html;
78
86
  };
79
87
 
88
+ const accordionComponent = (props: any) => {
89
+ return accordion({ ...props.block.value, id: props.block.id });
90
+ };
91
+
80
92
  const anchor = (data) => {
81
93
  return `<${data.tag} id="${data.id}">${data.text}</${data.tag}>`;
82
94
  };
@@ -600,11 +612,14 @@ const processUri = (uri) => {
600
612
  };
601
613
 
602
614
  const genericList = (props: any) => {
603
- let item = props.block?.value;
604
- let id = props.block.id;
615
+ return genList(props.block.value, props.block.id);
616
+ };
617
+ const genList = (item, id) => {
618
+ let heading = item.title ? `<h2 class="fs-4 mt-3">${item.title}</h2>` : '';
619
+
605
620
  return listItems.value[id]
606
621
  ? `
607
- <h2 class="fs-4 mt-3">${item.title}</h2>
622
+ ${heading}
608
623
  <ul>
609
624
  ${listItems.value[id].reduce((acc, e) => {
610
625
  return e.sys.dataFormat === 'webpage'
@@ -630,6 +645,8 @@ const myInlineEntry = (props: any) => {
630
645
  let data = props.block?.value;
631
646
  let id = props.block?.id;
632
647
  switch (props.block?.value.sys.contentTypeId) {
648
+ case 'accordion':
649
+ return accordion(data);
633
650
  case 'abbreviation':
634
651
  return abbr(data);
635
652
  case 'anchor':
@@ -707,7 +724,6 @@ onMounted(() => {
707
724
  // Expand all buttons
708
725
  const expandAll = (btn) => {
709
726
  btn.addEventListener('click', (e) => {
710
- console.log(btn.id);
711
727
  const op = btn.innerText;
712
728
  btn.innerText = op === 'Expand all' ? 'Close all' : 'Expand all';
713
729
  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.5",
3
3
  "name": "cec-nuxt-lib",
4
4
  "description": "Nuxt components and assets",
5
5
  "license": "MIT",