tecitheme 0.11.7 → 0.11.8

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.
@@ -1,5 +1,8 @@
1
1
  <script>
2
+ import { goto } from "$app/navigation";
3
+ import { page } from "$app/stores";
2
4
  import { getColorStyles, makeIdString } from "../utils";
5
+ import { onMount } from "svelte";
3
6
  import { writable } from "svelte/store";
4
7
 
5
8
  export let data = {};
@@ -38,21 +41,21 @@
38
41
  * }
39
42
  */
40
43
  let tables = {};
41
- data.groups.forEach(section => {
42
- if (section.options)
44
+ data.groups.forEach(group => {
45
+ if (group.options)
43
46
  {
44
- tables[section.name] = {columns: [], categories: []}; //Initialize key for the section object
47
+ tables[group.name] = {name: group.name, columns: [], categories: []}; //Initialize key for the section object
45
48
 
46
- section.options.forEach(option => {
49
+ group.options.forEach(option => {
47
50
 
48
- tables[section.name]["columns"].push({name: option.name, description: option.description, highlightOption: option.highlightOption});
51
+ tables[group.name]["columns"].push({name: option.name, description: option.description, highlightOption: option.highlightOption});
49
52
 
50
53
  if (option.features) {
51
54
  option.features.forEach(category => {
52
55
 
53
56
  // Big 'ole ternary to retrieve or initialize category data
54
- let catData = tables[section.name]["categories"][category.name]
55
- ? tables[section.name]["categories"][category.name]
57
+ let catData = tables[group.name]["categories"][category.name]
58
+ ? tables[group.name]["categories"][category.name]
56
59
  : {name: category.name, features: {}};
57
60
 
58
61
  category.features.forEach((feature, index) => {
@@ -73,7 +76,7 @@
73
76
  });
74
77
 
75
78
  //Store category data
76
- tables[section.name]["categories"][category.name] = catData;
79
+ tables[group.name]["categories"][category.name] = catData;
77
80
 
78
81
  });
79
82
  }
@@ -82,17 +85,17 @@
82
85
  }
83
86
  });
84
87
 
85
- let selectedButton = writable({});
88
+ let selectedGroup = writable({});
86
89
  let selectedTable = writable({});
87
90
 
88
91
  //Initialize data stores
89
92
  if (data.groups) {
90
- selectedButton.update(val => data.groups[0]);
91
- selectedTable.update(val => tables[$selectedButton.name]);
93
+ selectedGroup.update(val => data.groups[0]);
94
+ selectedTable.update(val => tables[$selectedGroup.name]);
92
95
  }
93
96
 
94
97
  //Update table store when new button is selected
95
- selectedButton.subscribe(val => selectedTable.update(table => tables[val.name]))
98
+ selectedGroup.subscribe(val => selectedTable.update(table => tables[val.name]))
96
99
 
97
100
  /**
98
101
  *
@@ -123,6 +126,24 @@
123
126
  }
124
127
  }
125
128
 
129
+ onMount(() => {
130
+ let initialGroupParam = $page.url.searchParams.get("group");
131
+ if (initialGroupParam != null) {
132
+ let initialGroup = data.groups.filter(group => group.name === initialGroupParam)[0];
133
+ selectedGroup.update(_ => initialGroup);
134
+ }
135
+
136
+ selectedGroup.subscribe(newGroup => {
137
+ $page.url.searchParams.set("group", newGroup.name);
138
+ goto($page.url.toString(), {noScroll: true});
139
+
140
+ setTimeout(() => {
141
+ let anchorElement = document.getElementById($page.url.hash.slice(1,));
142
+ if (anchorElement) anchorElement.scrollIntoView(true);
143
+ }, 300)
144
+ })
145
+ })
146
+
126
147
  </script>
127
148
 
128
149
  <div id={id} class="relative flex flex-col space-y-4">
@@ -138,7 +159,10 @@
138
159
  <fieldset class="flex flex-row bg-white/5 text-center text-xs font-semibold leading-5 shadow-lg ring ring-gray-200/50">
139
160
  <legend class="sr-only">Group Selector</legend>
140
161
  {#each data.groups as btn}
141
- <button class="{$selectedButton === btn ? getColorStyles("background", data.color) : getColorStyles("button", "white")} px-4 py-2 transition ease-in-out duration-300" on:click={selectedButton.update(val => btn)}>
162
+ <button class="{$selectedGroup === btn ? getColorStyles("background", data.color) : getColorStyles("button", "white")} px-4 py-2 transition ease-in-out duration-300" on:click={() => {
163
+ selectedGroup.update(_ => btn);
164
+ goto($page.url.pathname + $page.url.search);
165
+ }}>
142
166
  {btn.name}
143
167
  </button>
144
168
  {/each}
@@ -152,8 +176,8 @@
152
176
 
153
177
  <div class="hidden lg:absolute lg:inset-x-px lg:bottom-0 lg:top-4 lg:block" aria-hidden="true"></div>
154
178
 
155
- {#if $selectedButton.options}
156
- {#each $selectedButton.options as card}
179
+ {#if $selectedGroup.options}
180
+ {#each $selectedGroup.options as card}
157
181
 
158
182
  <div class="relative ring-1 ring-white/30 lg:pb-14 {card.highlightOption ? getColorStyles("background", data.color) : "bg-white"} w-full shadow-lg">
159
183
  <div class="p-8 lg:pt-12 xl:p-10 xl:pt-14">
@@ -223,7 +247,14 @@
223
247
  {#each Object.values($selectedTable.categories) as category, categoryIndex}
224
248
 
225
249
  <!-- Category Name -->
226
- <h4 class="hidden sm:block sticky top-32 z-20 bg-white font-semibold leading-6 text-gray-900 px-4 py-2 w-fit">{category.name}</h4>
250
+ <div class="hidden sm:flex sticky top-32 z-20 bg-transparent flex-row">
251
+
252
+ <h4 id={makeIdString($selectedTable.name + " " + category.name)} class="scroll-mt-24 bg-white font-semibold leading-6 text-gray-900 pl-4 mr-8 py-2 w-full"><a href={"#"+makeIdString($selectedTable.name + " " + category.name)}>{category.name}</a></h4>
253
+
254
+ {#each $selectedTable.columns as col}
255
+ <div class="w-full"></div>
256
+ {/each}
257
+ </div>
227
258
 
228
259
  <!-- Table -->
229
260
  <div class="hidden relative sm:flex flex-col w-full shadow-lg">
@@ -310,7 +341,7 @@
310
341
  {#if sortFeaturesByOrder(category.features, column.name).length > 0}
311
342
 
312
343
  <!-- Category Headings -->
313
- <h4 class="sticky top-44 sm:hidden block font-semibold leading-6 text-gray-900 w-full bg-white z-20 py-2">{category.name}</h4>
344
+ <h4 id={makeIdString(column.name + " " + category.name)} class="sticky top-44 sm:hidden block font-semibold leading-6 text-gray-900 w-full bg-white z-20 py-2 scroll-mt-36"><a href={"#" + makeIdString(column.name + " " + category.name)}>{category.name}</a></h4>
314
345
 
315
346
  <div class="sm:hidden relative flex flex-col">
316
347
  <!-- Tables -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tecitheme",
3
- "version": "0.11.7",
3
+ "version": "0.11.8",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev",