tecitheme 0.0.13 → 0.0.14

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.
@@ -21,7 +21,7 @@
21
21
  }
22
22
  </script>
23
23
 
24
- <footer class="bg-gray-800" aria-labelledby="footerHeading">
24
+ <footer id="bottom" class="bg-gray-800" aria-labelledby="footerHeading">
25
25
  <h2 id="footerHeading" class="sr-only">Footer</h2>
26
26
  <div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:py-16 lg:px-8">
27
27
  <div class="xl:grid xl:grid-cols-3 xl:gap-8">
@@ -50,11 +50,7 @@
50
50
  />
51
51
  </span>
52
52
  {:else if icon?.startsWith("icon-")}
53
- <span class="not-prose">
54
- <div class="{classes} bg-teci-blue-dark flex flex-col justify-center items-center">
55
- <span class="material-icons block text-4xl text-white">{icon?.slice(5)}</span>
56
- </div>
57
- </span>
53
+ <span class="material-icons-outlined {classes}">{icon?.slice(5)}</span>
58
54
  {:else}
59
55
  <span class="not-prose">
60
56
  <svg class={classes} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 250 250">
@@ -1,53 +1,112 @@
1
1
  <script>
2
2
  import { onMount } from "svelte";
3
+
3
4
  export let data;
4
5
 
5
- let tocMoved = false;
6
-
7
- onMount(() => {
8
- function moveTOC() {
9
- console.log("Moving TOC");
10
- var oldParent = document.getElementsByClassName('page-toc')[0];
11
- if (oldParent && oldParent.nodeType == 1){
12
- var newParent = document.getElementById('sidebar-nav');
13
- var loader = document.getElementById('loader');
14
- var classes = oldParent.classList;
15
- newParent.insertAdjacentElement('beforeend', oldParent)
16
- loader.remove();
17
- classes.remove("hidden");
18
- tocMoved = true;
19
- console.log("TOC Moved")
20
- } else {
21
- console.log(tocMoved, oldParent);
22
- if(!tocMoved && oldParent == undefined){
23
- console.log("Reloading");
24
- window.location.reload();
25
- } else {
26
- console.log("Leave it alone.")
27
- tocMoved = true;
28
- }
29
- }
30
- };
6
+ let tocOpen = false;
7
+ let tocBuilt = false;
8
+ let w;
9
+
10
+ $: if (w > 702 && tocOpen == false) {tocOpen = true}
31
11
 
32
- if (tocMoved == false && data.sidebar) {
33
- moveTOC();
12
+ onMount( async () => {
13
+ if (data.toc) {
14
+ tocBuilt = buildToC();
34
15
  };
35
16
  });
17
+
18
+ function buildToC() {
19
+ // Based on https://projectcodeed.blogspot.com/2020/04/an-automatic-table-of-contents.html
20
+
21
+ // Get ToC div
22
+ let toc = document.getElementById("ToC");
23
+
24
+ //Add a header
25
+ var tocHeader = document.createElement("a");
26
+ tocHeader.classList.add("mb-2", "inline-block", "w-auto", "text-center", "bg-gray-50", "hover:bg-gray-100", "py-1", "px-2", "border")
27
+ tocHeader.innerHTML = "<span class='material-icons-outlined text-sm font-bold text-gray-500 align-text-bottom'>vertical_align_top</span>";
28
+ tocHeader.setAttribute("href","#top");
29
+ tocHeader.setAttribute("title","To Top of Page");
30
+ toc.appendChild(tocHeader);
31
+
32
+ // Create a list for the ToC entries
33
+ let tocList = document.createElement("ul");
34
+
35
+ // Find the primary content section
36
+ let content = document.getElementById("content")
37
+
38
+ // Get the h2 tags - ToC entries
39
+ let headers = content.getElementsByTagName("h2");
40
+
41
+ if (headers.length == 0) {
42
+ console.log("There are not any H2 elements in the document.");
43
+ } else {
44
+ // For each h2
45
+ for (let i = 0; i < headers.length; i++){
46
+
47
+ // Get Heading ID
48
+ let name = headers[i].id
49
+
50
+ // list item for the entry
51
+ let tocListItem = document.createElement("li");
52
+ tocListItem.classList.add("text-teci-blue-light", "hover:text-teci-blue-dark", "text-sm", "truncate");
53
+
54
+ // link for the h2
55
+ let tocEntry = document.createElement("a");
56
+ tocEntry.setAttribute("href","#"+name);
57
+ tocEntry.innerText=headers[i].innerText;
58
+
59
+ // add link to list item list
60
+ tocListItem.appendChild(tocEntry);
61
+
62
+ // add list item to list
63
+ tocList.appendChild(tocListItem);
64
+ }
65
+
66
+ // add list to toc element
67
+ toc.appendChild(tocList);
68
+
69
+ //Add a footer
70
+ //var tocFooter = document.createElement("a");
71
+ //tocFooter.classList.add("mt-2", "inline-block", "w-auto", "text-center", "bg-gray-50", "hover:bg-gray-100", "py-1", "px-2", "border")
72
+ //tocFooter.innerHTML="<span class='material-icons-outlined text-sm font-bold text-gray-500 align-text-bottom'>vertical_align_bottom</span>";
73
+ //tocFooter.setAttribute("href","#bottom");
74
+ //tocFooter.setAttribute("title","To Bottom of Page");
75
+ //toc.appendChild(tocFooter);
76
+
77
+ return true;
78
+ }
79
+ }
36
80
  </script>
37
81
 
38
- <section class="w-auto mx-auto flex flex-col lg:flex-row items-start lg:space-x-8">
39
- {#if data.sidebar}
40
- <div id="sidebar-nav" class="pr-4 lg:text-right font-medium mb-4 w-auto lg:max-w-xs lg:mb-0 lg:w-60 lg:sticky lg:top-8 shrink-0 lg:border-r lg:border-r-gray-400">
41
- <div id="loader">
42
- <svg role="status" class="inline-block mr-2 w-6 h-6 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
43
- <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
44
- <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
45
- </svg>
46
- <span class="inline-block">Loading...</span>
47
- </div>
48
- </div>
49
- {/if}
50
- <div id="text" class="w-full prose max-w-none lg:max-w-prose">
82
+ <section bind:clientWidth={w} class="relative mx-auto flex flex-row {(data.toc || data.rightRail) ? 'md:space-x-8' : 'space-x-0'}">
83
+ <div id="content" class="prose w-full { data.fullWidth ? 'max-w-none' : 'max-w-prose'}">
51
84
  <slot />
52
85
  </div>
86
+ <aside class="relative w-0 {(data.toc || data.rightRail) ? 'md:w-60' : 'hidden'}">
87
+ {#if data.toc}
88
+ <div class="sticky top-8 shrink-0 flex flex-col">
89
+ <button on:click={() => {tocOpen = !tocOpen;}}
90
+ class="md:hidden absolute -left-10 w-10 h-10 flex items-center justify-center border border-teci-blue-light text-teci-blue-light bg-white
91
+ {tocOpen ? 'border-opacity-100 bg-opacity-100 text-opacity-100' : 'border-opacity-20 bg-opacity-20 text-opacity-20'}"
92
+ title="Table of Contents Toggle" alt="Table of Contents Toggle"
93
+ >
94
+ <span class="material-icons-outlined">menu_open</span>
95
+ </button>
96
+ {#if tocBuilt == false}
97
+ <svg role="status" class="inline-block m-2 w-6 h-6 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
98
+ <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
99
+ <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
100
+ </svg>
101
+ {/if}
102
+ <div id="ToC" class="absolute md:relative -left-[282px] border shadow-md bg-white md:left-0 font-medium text-right md:text-left p-2 {tocOpen ? 'block w-60 mb-4' : 'hidden'}">
103
+ </div>
104
+ </div>
105
+ {/if}
106
+ {#if data.rightRail}
107
+ <div class="hidden md:block p-2 bg-gray-200 {(data.toc || data.rightRail) ? 'md:w-60' : 'w-0'}">
108
+ Dynamic Stuff
109
+ </div>
110
+ {/if}
111
+ </aside>
53
112
  </section>
@@ -11,6 +11,7 @@
11
11
  export let data = [
12
12
  {
13
13
  icon: 'pyrosim',
14
+ classes: 'h-12 w-12',
14
15
  image: 'https://www.thunderheadeng.com/wp-content/uploads/2013/09/company_pyrosim.jpg',
15
16
  heading: 'Product 1',
16
17
  subheading: 'Nutshell',
@@ -19,6 +20,7 @@
19
20
  },
20
21
  {
21
22
  icon: '',
23
+ classes: '',
22
24
  image: 'https://www.thunderheadeng.com/wp-content/uploads/2013/08/company_pathfinder.png',
23
25
  heading: 'Product 2',
24
26
  subheading: 'No Icon',
@@ -28,6 +30,7 @@
28
30
  {
29
31
  icon: 'icon-auto_stories',
30
32
  image: 'https://www.thunderheadeng.com/wp-content/uploads/2013/08/company_petrasim.png',
33
+ classes: 'inline-block bg-teci-blue-dark text-white text-4xl text-center align-bottom h-12 w-12 pt-1 px-1',
31
34
  heading: 'Google Icon, No Subtitle or Text',
32
35
  subheading: '',
33
36
  text: '',
@@ -51,7 +54,7 @@
51
54
  {/if}
52
55
  <div class="flex flex-row items-start space-x-4">
53
56
  {#if col.icon}
54
- <Icon classes="h-12 w-12" icon={col.icon} />
57
+ <Icon classes={col.classes} icon={col.icon} />
55
58
  {/if}
56
59
  <div class="leading-none font-medium flex flex-col">
57
60
  <h3 class="text-2xl leading-none">{col.heading}</h3>
@@ -4,6 +4,7 @@
4
4
  export default class ThreeColumn extends SvelteComponentTyped<{
5
5
  data?: {
6
6
  icon: string;
7
+ classes: string;
7
8
  image: string;
8
9
  heading: string;
9
10
  subheading: string;
@@ -23,6 +24,7 @@ declare const __propDef: {
23
24
  props: {
24
25
  data?: {
25
26
  icon: string;
27
+ classes: string;
26
28
  image: string;
27
29
  heading: string;
28
30
  subheading: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tecitheme",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "svelte": true,
5
5
  "devDependencies": {
6
6
  "@jsdevtools/rehype-toc": "^3.0.2",