jekyll-theme-amethyst 1.1.0 → 1.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d266106998f837dc87b9400d550b909e8d3c34d57bd3b4f0b1f38e3dc5c3d03b
4
- data.tar.gz: e5b5cd9501161c5221b4bd43b336202e0b0b22a77a6b2fcc77a5177e50e93d93
3
+ metadata.gz: dd713f104c3f11d0bbf936b256059ac16abed6d63e3bfe4d3641cf1d7bd0cf9d
4
+ data.tar.gz: 9eb9b32ecd778b4a10ffa708c3ef3176bc574b4a540dd90682a404aec69aaa9f
5
5
  SHA512:
6
- metadata.gz: 0e4fa532ac951cbec039e6611db5924e57b50baea29fd8deaa7fc9d24568d3db18cbec26e2bcfe158dd1a46be5b52aad730a748ea2ba66f50e0be9c5f40d927d
7
- data.tar.gz: 70e27c6890f693c2b9c10fc0bf3d13915d2ca0146a916058ddafac5bf82809bc398ea270df69019a98cfde33d5ef38854c47d4f5fa060c3b8ccab57abb58d80d
6
+ metadata.gz: 88ea9945ef9a71a0f3bdb14cfdf932c90a5a6c7209e687fcd19377be5b3099eb74fcea5d066cf23b20964bdee42b683a3e06ba332cd92f9b9523aa1a064b7241
7
+ data.tar.gz: ca19314005d3446128363a3c5b24475a1cbf1f8443f6c98dd5928ebc10d25b54a584dce38e4e2fa8318b76438057a945e0f9f94fa68bfdabcf7e46116da49ad7
@@ -1,6 +1,6 @@
1
- <form role="search" class="tsmb-form"{% if site.amethyst.typesense.search_only_api_key %} data-origin="{{ site.amethyst.typesense.origin | escape }}" data-collection="{{ site.amethyst.typesense.collection | escape }}" data-key="{{ site.amethyst.typesense.search_only_api_key | escape }}" data-foot="true"{% endif %} action="https://duckduckgo.com">
1
+ <typesense-minibar{% if site.amethyst.typesense.search_only_api_key %} data-origin="{{ site.amethyst.typesense.origin | escape }}" data-collection="{{ site.amethyst.typesense.collection | escape }}" data-key="{{ site.amethyst.typesense.search_only_api_key | escape }}" data-foot="true"{% endif %}>
2
+ <form role="search" action="https://duckduckgo.com">
2
3
  <input type="search" name="q" aria-label="Search" placeholder="Search..." autocomplete="off">
3
4
  <input type="hidden" name="sites" value="{{ site.url | remove_first: 'http://' | remove_first: 'https://' }}">
4
5
  </form>
5
-
6
-
6
+ </typesense-minibar>
@@ -49,7 +49,7 @@
49
49
  </button>
50
50
  <script type="module">
51
51
  const searchToggle = document.querySelector('.search-toggle');
52
- const searchForm = document.querySelector('form[role=search]');
52
+ const searchForm = document.querySelector('typesense-minibar');
53
53
  const searchInput = searchForm.querySelector('input[type=search]');
54
54
  function searchFn(newState) {
55
55
  searchToggle.setAttribute('aria-expanded', String(newState));
data/_sass/amethyst.scss CHANGED
@@ -464,7 +464,7 @@ table {
464
464
 
465
465
  /* Search */
466
466
 
467
- .tsmb-form {
467
+ typesense-minibar {
468
468
  --tsmb-color-base-background: #{lighten($color-accent, 12%)};
469
469
  --tsmb-color-primary30: #{$color-accent};
470
470
  --tsmb-color-primary50: #{$color-vibrant};
@@ -473,22 +473,26 @@ table {
473
473
  --tsmb-color-base50: #{change-color($color-bright, $alpha: 0.6)}; // #a98dc1
474
474
  --tsmb-color-base90: #{change-color($color-bright, $alpha: 0.6)};
475
475
 
476
- width: auto;
477
476
  flex: 1;
478
477
  align-self: center;
479
478
  }
480
- .tsmb-form:not(:focus-within)::before {
479
+ typesense-minibar form {
480
+ width: auto;
481
+ }
482
+ typesense-minibar form:not(:focus-within)::before {
481
483
  filter: unquote("invert()");
482
484
  }
483
- .tsmb-form input[type="search"] {
485
+ typesense-minibar input[type="search"] {
484
486
  border: none;
485
487
  }
486
488
  @media (max-width: $screen-m) {
487
- .tsmb-form {
488
- display: none;
489
+ typesense-minibar {
490
+ --tsmb-size-input: calc( var(--tsmb-size-base) * 2.0 );
491
+
489
492
  flex: 100%;
490
493
  order: 10;
491
- --tsmb-size-input: calc( var(--tsmb-size-base) * 2.0 );
494
+ /* changed by button.search-toggle in wrapper.html */
495
+ display: none;
492
496
  }
493
497
  }
494
498
 
@@ -1,5 +1,6 @@
1
- /*! https://github.com/jquery/typesense-minibar 1.2.0 */
2
- .tsmb-form {
1
+ /*! https://github.com/jquery/typesense-minibar 1.3.2 */
2
+ .tsmb-form,
3
+ typesense-minibar {
3
4
  --tsmb-size-edge: 1px;
4
5
  --tsmb-size-radius: 3px;
5
6
  --tsmb-size-highlight: 2px;
@@ -23,7 +24,10 @@
23
24
  --tsmb-color-primary30: #390f39;
24
25
  --tsmb-color-primary50: #9c3493;
25
26
  --tsmb-color-primary90: #fbdbfb;
27
+ }
26
28
 
29
+ .tsmb-form,
30
+ typesense-minibar form {
27
31
  position: relative;
28
32
  width: 20rem;
29
33
  max-width: 100%;
@@ -31,7 +35,8 @@
31
35
  color: var(--tsmb-color-base30);
32
36
  }
33
37
 
34
- .tsmb-form input[type=search] {
38
+ .tsmb-form input[type=search],
39
+ typesense-minibar input[type=search] {
35
40
  box-sizing: border-box;
36
41
  -webkit-appearance: none;
37
42
  -moz-appearance: none;
@@ -46,31 +51,40 @@
46
51
  line-height: var(--tsmb-size-input);
47
52
  }
48
53
 
49
- .tsmb-form input[type=search]::placeholder {
54
+ .tsmb-form input[type=search]::placeholder,
55
+ typesense-minibar input[type=search]::placeholder {
50
56
  color: var(--tsmb-color-base50);
51
57
  opacity: 1;
52
58
  }
53
59
 
54
- .tsmb-form:focus-within {
60
+ .tsmb-form:focus-within,
61
+ typesense-minibar form:focus-within {
55
62
  color: var(--tsmb-color-focus30);
56
63
  }
57
64
 
58
- .tsmb-form:focus-within input[type=search] {
65
+ .tsmb-form:focus-within input[type=search],
66
+ typesense-minibar:focus-within input[type=search] {
59
67
  background: var(--tsmb-color-focus-background);
60
68
  }
61
69
 
62
- .tsmb-form:focus-within input[type=search]::placeholder {
70
+ .tsmb-form:focus-within input[type=search]::placeholder,
71
+ typesense-minibar:focus-within input[type=search]::placeholder {
63
72
  color: var(--tsmb-color-focus50);
64
73
  }
65
74
 
66
75
  .tsmb-form input[type=search]::-webkit-search-decoration,
67
76
  .tsmb-form input[type=search]::-webkit-search-cancel-button,
68
77
  .tsmb-form input[type=search]::-webkit-search-results-button,
69
- .tsmb-form input[type=search]::-webkit-search-results-decoration {
78
+ .tsmb-form input[type=search]::-webkit-search-results-decoration,
79
+ typesense-minibar input[type=search]::-webkit-search-decoration,
80
+ typesense-minibar input[type=search]::-webkit-search-cancel-button,
81
+ typesense-minibar input[type=search]::-webkit-search-results-button,
82
+ typesense-minibar input[type=search]::-webkit-search-results-decoration {
70
83
  display: none;
71
84
  }
72
85
 
73
- .tsmb-form::before {
86
+ .tsmb-form::before,
87
+ typesense-minibar form::before {
74
88
  content: '';
75
89
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='654 -372 1664 1664' width='20' height='20'><path d='M1806,332c0-123.3-43.8-228.8-131.5-316.5C1586.8-72.2,1481.3-116,1358-116s-228.8,43.8-316.5,131.5 C953.8,103.2,910,208.7,910,332s43.8,228.8,131.5,316.5C1129.2,736.2,1234.7,780,1358,780s228.8-43.8,316.5-131.5 C1762.2,560.8,1806,455.3,1806,332z M2318,1164c0,34.7-12.7,64.7-38,90s-55.3,38-90,38c-36,0-66-12.7-90-38l-343-342 c-119.3,82.7-252.3,124-399,124c-95.3,0-186.5-18.5-273.5-55.5s-162-87-225-150s-113-138-150-225S654,427.3,654,332 s18.5-186.5,55.5-273.5s87-162,150-225s138-113,225-150S1262.7-372,1358-372s186.5,18.5,273.5,55.5s162,87,225,150s113,138,150,225 S2062,236.7,2062,332c0,146.7-41.3,279.7-124,399l343,343C2305.7,1098.7,2318,1128.7,2318,1164z'/></svg>") 0 50% / contain no-repeat;
76
90
  position: absolute;
@@ -128,7 +142,8 @@
128
142
  color: var(--tsmb-color-base90);
129
143
  }
130
144
 
131
- .tsmb-form [role=listbox] {
145
+ .tsmb-form [role=listbox],
146
+ typesense-minibar [role=listbox] {
132
147
  position: absolute;
133
148
  z-index: 10;
134
149
  right: var(--tsmb-size-listbox-right);
@@ -149,29 +164,35 @@
149
164
  border-bottom: var(--tsmb-size-edge) solid var(--tsmb-color-focus90);
150
165
  }
151
166
 
152
- .tsmb-form [role=option] a {
167
+ .tsmb-form [role=option] a,
168
+ typesense-minibar [role=option] a {
153
169
  display: block;
154
170
  padding: var(--tsmb-size-base);
155
171
  text-decoration: none;
156
172
  border-left: var(--tsmb-size-highlight) solid transparent;
157
173
  }
158
174
 
159
- .tsmb-form:not([data-group=true]) [role=option]:not(:first-child) a {
175
+ .tsmb-form:not([data-group=true]) [role=option]:not(:first-child) a,
176
+ typesense-minibar:not([data-group=true]) [role=option]:not(:first-child) a {
160
177
  border-top: var(--tsmb-size-edge) solid var(--tsmb-color-focus90);
161
178
  }
162
179
 
163
- .tsmb-form[data-group=true] [role=option] a {
180
+ .tsmb-form[data-group=true] [role=option] a,
181
+ typesense-minibar[data-group=true] [role=option] a {
164
182
  margin: 0 var(--tsmb-size-base);
165
183
  padding: var(--tsmb-size-sm);
166
184
  }
167
185
 
168
186
  .tsmb-form [role=option] a:hover,
169
- .tsmb-form [role=option][aria-selected=true] a {
187
+ .tsmb-form [role=option][aria-selected=true] a,
188
+ typesense-minibar [role=option] a:hover,
189
+ typesense-minibar [role=option][aria-selected=true] a {
170
190
  background: var(--tsmb-color-primary90);
171
191
  border-left-color: var(--tsmb-color-primary50);
172
192
  }
173
193
 
174
- .tsmb-form [role=option] mark {
194
+ .tsmb-form [role=option] mark,
195
+ typesense-minibar [role=option] mark {
175
196
  background: none;
176
197
  color: inherit;
177
198
  font-style: normal;
@@ -189,7 +210,8 @@
189
210
  .tsmb-suggestion_title {
190
211
  color: var(--tsmb-color-primary30);
191
212
  }
192
- .tsmb-form[data-group=true] .tsmb-suggestion_title {
213
+ .tsmb-form[data-group=true] .tsmb-suggestion_title,
214
+ typesense-minibar[data-group=true] .tsmb-suggestion_title {
193
215
  font-weight: bold;
194
216
  font-size: var(--tsmb-size-sm);
195
217
  }
@@ -1,7 +1,5 @@
1
- /*! https://github.com/jquery/typesense-minibar 1.2.0 */
2
- globalThis.tsminibar = function tsminibar (form) {
3
- const { origin, collection } = form.dataset;
4
- const group = !!form.dataset.group;
1
+ /*! https://github.com/jquery/typesense-minibar 1.3.2 */
2
+ globalThis.tsminibar = function tsminibar (form, dataset = form.dataset) {
5
3
  const cache = new Map();
6
4
  const state = { query: '', cursor: -1, open: false, hits: [] };
7
5
  const searchParams = new URLSearchParams({
@@ -14,10 +12,10 @@ globalThis.tsminibar = function tsminibar (form) {
14
12
  sort_by: 'item_priority:desc',
15
13
  snippet_threshold: '8',
16
14
  highlight_affix_num_tokens: '12',
17
- 'x-typesense-api-key': form.dataset.key,
18
- ...Object.fromEntries(new URLSearchParams(form.dataset.searchParams))
15
+ 'x-typesense-api-key': dataset.key,
16
+ ...Object.fromEntries(new URLSearchParams(dataset.searchParams))
19
17
  });
20
- const noResults = form.dataset.noResults || "No results for '{}'.";
18
+ const noResults = dataset.noResults || "No results for '{}'.";
21
19
 
22
20
  const input = form.querySelector('input[type=search]');
23
21
  const listbox = document.createElement('div');
@@ -31,7 +29,7 @@ globalThis.tsminibar = function tsminibar (form) {
31
29
  preconnect = document.createElement('link');
32
30
  preconnect.rel = 'preconnect';
33
31
  preconnect.crossOrigin = 'anonymous'; // match fetch cors,credentials:omit
34
- preconnect.href = origin;
32
+ preconnect.href = dataset.origin;
35
33
  document.head.append(preconnect);
36
34
  }
37
35
  if (!state.open && state.hits.length) {
@@ -42,7 +40,7 @@ globalThis.tsminibar = function tsminibar (form) {
42
40
  input.addEventListener('input', async function () {
43
41
  const query = state.query = input.value;
44
42
  if (!query) {
45
- state.hits = []; // don't leak old hits on focus
43
+ state.hits = [];
46
44
  state.cursor = -1;
47
45
  return close();
48
46
  }
@@ -72,7 +70,7 @@ globalThis.tsminibar = function tsminibar (form) {
72
70
  }
73
71
  });
74
72
  form.addEventListener('submit', function (e) {
75
- e.preventDefault(); // disable fallback
73
+ e.preventDefault();
76
74
  });
77
75
  form.insertAdjacentHTML('beforeend', '<svg viewBox="0 0 12 12" width="20" height="20" aria-hidden="true" class="tsmb-icon-close" style="display: none;"><path d="M9 3L3 9M3 3L9 9"/></svg>');
78
76
  form.querySelector('.tsmb-icon-close').addEventListener('click', function () {
@@ -92,7 +90,7 @@ globalThis.tsminibar = function tsminibar (form) {
92
90
 
93
91
  function connect () {
94
92
  document.addEventListener('click', onDocClick);
95
- if (form.dataset.slash !== 'false') {
93
+ if (dataset.slash !== 'false') {
96
94
  document.addEventListener('keydown', onDocSlash);
97
95
  form.classList.add('tsmb-form--slash');
98
96
  }
@@ -124,9 +122,10 @@ globalThis.tsminibar = function tsminibar (form) {
124
122
  }
125
123
  searchParams.set('q', query);
126
124
  const resp = await fetch(
127
- `${origin}/collections/${collection}/documents/search?` + searchParams,
125
+ `${dataset.origin}/collections/${dataset.collection}/documents/search?` + searchParams,
128
126
  { mode: 'cors', credentials: 'omit', method: 'GET' }
129
127
  );
128
+ const group = !!dataset.group;
130
129
  const data = await resp.json();
131
130
  hits = data?.grouped_hits?.map(ghit => {
132
131
  const hit = ghit.hits[0];
@@ -151,14 +150,11 @@ globalThis.tsminibar = function tsminibar (form) {
151
150
  function render () {
152
151
  listbox.hidden = !state.open;
153
152
  form.classList.toggle('tsmb-form--open', state.open);
154
- if (state.open) {
155
- listbox.innerHTML = (state.hits.map((hit, i) => `<div role="option"${i === state.cursor ? ' aria-selected="true"' : ''}>${hit.lvl0 ? `<div class="tsmb-suggestion_group">${hit.lvl0}</div>` : ''}<a href="${hit.url}" tabindex="-1"><div class="tsmb-suggestion_title">${hit.title}</div><div class="tsmb-suggestion_content">${hit.content}</div></a></div>`).join('') || `<div class="tsmb-empty">${noResults.replace('{}', escape(state.query))}</div>`) + (form.dataset.foot ? '<a href="https://typesense.org" class="tsmb-foot" title="Search by Typesense"></a>' : '');
156
- }
153
+ listbox.innerHTML = (state.hits.map((hit, i) => `<div role="option"${i === state.cursor ? ' aria-selected="true"' : ''}>${hit.lvl0 ? `<div class="tsmb-suggestion_group">${hit.lvl0}</div>` : ''}<a href="${hit.url}" tabindex="-1"><div class="tsmb-suggestion_title">${hit.title}</div><div class="tsmb-suggestion_content">${hit.content}</div></a></div>`).join('') || `<div class="tsmb-empty">${noResults.replace('{}', escape(state.query))}</div>`) + (dataset.foot ? '<a href="https://typesense.org" class="tsmb-foot" title="Search by Typesense"></a>' : '');
157
154
  }
158
155
 
159
156
  function moveCursor (offset) {
160
157
  state.cursor += offset;
161
- // -1 refers to input field
162
158
  if (state.cursor >= state.hits.length) state.cursor = -1;
163
159
  if (state.cursor < -1) state.cursor = state.hits.length - 1;
164
160
  render();
@@ -166,4 +162,10 @@ globalThis.tsminibar = function tsminibar (form) {
166
162
 
167
163
  return { form, connect, disconnect };
168
164
  };
165
+ window.customElements.define('typesense-minibar', class extends HTMLElement {
166
+ connectedCallback () {
167
+ const form = this.querySelector('form');
168
+ if (form && this.dataset.origin) tsminibar(form, this.dataset);
169
+ }
170
+ });
169
171
  document.querySelectorAll('.tsmb-form[data-origin]').forEach(form => tsminibar(form));
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-amethyst
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Tijhof
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-07-02 00:00:00.000000000 Z
12
+ date: 2024-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll