jekyll_ranked_search 0.0.3 → 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/search.js +25 -2
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81e9541ca2a4139827dfb10a8ad23bb3f493f9465d95c8c0d8f18f55affeb10f
4
- data.tar.gz: cc861e099846391ab537624f4a509e7bf97987c5f68851335a613fe8fbadb6e9
3
+ metadata.gz: 285d83435623362b1b2a64895f39e9083a23e994f44772b8d7d0ee119bb0a2a8
4
+ data.tar.gz: 3f87f6708fb4bb8070ffbf22a388345ec0ead46c251aa94b7828d3cb8e0653d6
5
5
  SHA512:
6
- metadata.gz: cb47470cf5b035428a768d83804dd92703e754e3776f85655094f136e02d1523e0995c884595caf02716a29fe8cf7f416fd05f4549b18ca121c13fbad0ec252e
7
- data.tar.gz: 5258f44e86d40cc44666aae5841ffd7e50c7a51b5c60dcf7666300177b278ffff0c4e89f5b4a6b2d62c6117f21edea8f8a0ee75ed076a8def7b010a572472a1d
6
+ metadata.gz: c5b400d6ad614276e3f325923c7a0ba56a78fc216e4eeaf26acb5fd070a89e90b41e995c16760f337c983b1902d892d8f96bfdba1312000e8f9bfff71104cb00
7
+ data.tar.gz: 132c37490020d2205f526ae84c0f190236e265ac19f33f12abb4654d0350547055e0549517e3df554b5a46d9271f43e80556dafbeadf5fd98f79c4992a126d70
data/lib/search.js CHANGED
@@ -12,6 +12,9 @@ class SearchBox extends LitElement {
12
12
 
13
13
  // Lazy loading
14
14
  lazy: {type: Boolean, attribute: true},
15
+
16
+ // Maximum number of results to show
17
+ maxResults: {type: Number, attribute: "max-results"},
15
18
  };
16
19
 
17
20
  /**
@@ -35,6 +38,9 @@ class SearchBox extends LitElement {
35
38
  // Disable lazy loading by default
36
39
  this.lazy = false;
37
40
 
41
+ // Default to maximum of 8 results
42
+ this.maxResults = 8;
43
+
38
44
  this._placeholder = "Search...";
39
45
  }
40
46
 
@@ -48,7 +54,7 @@ class SearchBox extends LitElement {
48
54
  box-sizing: border-box;
49
55
  width: 100%;
50
56
  // margin: 0 auto;
51
- padding: .4em;
57
+ padding: .4em 30px;
52
58
  border: 1px solid #ccc;
53
59
  font-size: 1.2em;
54
60
  border-radius: 4px;
@@ -56,12 +62,27 @@ class SearchBox extends LitElement {
56
62
  z-index: 11;
57
63
  }
58
64
 
65
+ label {
66
+ position: relative;
67
+ }
68
+
69
+ label::before {
70
+ content: "";
71
+ position: absolute;
72
+ left: 10px;
73
+ top: 0;
74
+ bottom: 0;
75
+ width: 20px;
76
+ background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='currentColor' class=''%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z' /%3E%3C/svg%3E") no-repeat center center;
77
+ }
78
+
59
79
  #results {
60
80
  position: absolute;
61
81
  width: 100%;
62
82
  margin-top: 4px;
63
83
  z-index: 10;
64
84
  background-color: #F6F6F6;
85
+ overflow: hidden;
65
86
  border-radius: 4px;
66
87
  box-shadow: 1px 1px 2px #888;
67
88
  }
@@ -208,7 +229,7 @@ class SearchBox extends LitElement {
208
229
  const candidates = [...results.entries()].sort((a, b) => b[1] - a[1]).map((a) => a[0]);
209
230
 
210
231
  // Get top n results
211
- this._results = candidates.map((idx) => this._data.docs[idx]).slice(0, 8);
232
+ this._results = candidates.map((idx) => this._data.docs[idx]).slice(0, this.maxResults);
212
233
  this._open = true;
213
234
  }
214
235
 
@@ -238,7 +259,9 @@ class SearchBox extends LitElement {
238
259
 
239
260
  render() {
240
261
  return html`<div>
262
+ <label>
241
263
  <input id="q" type="text" placeholder="${this._placeholder}" @keyup="${this.search}" @click=${this.openIfResults} @focus=${this.focus}>
264
+ </label>
242
265
  ${this._open ? html`
243
266
  <div id="results">
244
267
  ${this._results.map((result) => html`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_ranked_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2023-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  requirements: []
56
- rubygems_version: 3.4.13
56
+ rubygems_version: 3.4.15
57
57
  signing_key:
58
58
  specification_version: 4
59
59
  summary: TF-IDF offline search for Jekyll posts