@ca-plant-list/ca-plant-list 0.1.5 → 0.1.6

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.
@@ -61,6 +61,13 @@ span.rare::before {
61
61
  font-weight: 600;
62
62
  }
63
63
 
64
+ div.grid {
65
+ display: grid;
66
+ grid-auto-flow: row;
67
+ grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
68
+ column-gap: 2rem;
69
+ }
70
+
64
71
  div.wrapper {
65
72
  display: flex;
66
73
  flex-wrap: wrap;
@@ -82,6 +89,8 @@ div.section ul {
82
89
 
83
90
  div.section li {
84
91
  display: block;
92
+ margin-left: 1rem;
93
+ text-indent: -1rem;
85
94
  }
86
95
 
87
96
  div.section ul.indent {
@@ -6,9 +6,9 @@ class Search {
6
6
  static #debounceTimer;
7
7
  static #searchData;
8
8
 
9
- static #debounce( func ) {
9
+ static #debounce( timeout = 500 ) {
10
10
  clearTimeout( this.#debounceTimer );
11
- this.#debounceTimer = setTimeout( func, 500 );
11
+ this.#debounceTimer = setTimeout( Search.#doSearch, timeout );
12
12
  }
13
13
 
14
14
  static #doSearch() {
@@ -141,7 +141,11 @@ class Search {
141
141
  }
142
142
 
143
143
  static #handleChange() {
144
- this.#debounce( Search.#doSearch );
144
+ this.#debounce();
145
+ }
146
+
147
+ static #handleSubmit() {
148
+ this.#debounce( 0 );
145
149
  }
146
150
 
147
151
  static init() {
@@ -149,6 +153,7 @@ class Search {
149
153
  const eName = document.getElementById( "name" );
150
154
  eName.focus();
151
155
  eName.oninput = ( ev ) => { return this.#handleChange( ev ); };
156
+ document.getElementById( "search_form" ).onsubmit = () => { this.#handleSubmit(); return false; };
152
157
  }
153
158
 
154
159
  }
@@ -8,7 +8,7 @@ js: name_search.js
8
8
  const NAMES = {% include names.json%};
9
9
  </script>
10
10
 
11
- <form>
11
+ <form id="search_form">
12
12
  <input type="text" id="name"><label for="name">Search for scientific name, common name, or synonym</label>
13
13
  </form>
14
14
 
@@ -1,17 +1,20 @@
1
1
  import * as fs from "node:fs";
2
2
  import { Config } from "./config.js";
3
+ import { Families } from "./families.js";
3
4
 
4
5
  class BasePageRenderer {
5
6
 
6
7
  static render( outputDir, Taxa ) {
7
8
 
8
9
  // Copy static files
9
- fs.rmSync( outputDir, { force: true, recursive: true, maxRetries: 2, retryDelay: 300 } );
10
+ fs.rmSync( outputDir, { force: true, recursive: true, maxRetries: 2, retryDelay: 400 } );
10
11
  // First copy default Jekyll files from package.
11
12
  fs.cpSync( Config.getPackageDir() + "/jekyll", outputDir, { recursive: true } );
12
13
  // Then copy Jekyll files from current dir (which may override default files).
13
14
  fs.cpSync( "jekyll", outputDir, { recursive: true } );
14
15
 
16
+ Families.renderPages( outputDir );
17
+
15
18
  this.renderTools( outputDir, Taxa );
16
19
 
17
20
  }
package/lib/families.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as fs from "node:fs";
2
2
  import { HTMLPage } from "./htmlpage.js";
3
- import { HTML, HTML_OPTIONS } from "./html.js";
3
+ import { HTML } from "./html.js";
4
4
  import { Jepson } from "./jepson.js";
5
5
  import { Taxa } from "./taxa.js";
6
6
 
@@ -46,7 +46,7 @@ class PageFamilyList extends HTMLPage {
46
46
 
47
47
  let html = this.getFrontMatter( title );
48
48
 
49
- html += HTML.getElement( "h1", title );
49
+ html += HTML.textElement( "h1", title );
50
50
 
51
51
  html += "<ul>";
52
52
  for ( const family of this.#families ) {
@@ -75,13 +75,12 @@ class PageFamily extends HTMLPage {
75
75
 
76
76
  let html = this.getFrontMatter( this.#family.getName() );
77
77
 
78
- html += HTML.getElement( "h1", this.#family.getName() );
78
+ html += HTML.textElement( "h1", this.#family.getName() );
79
79
 
80
- html += HTML.getElement(
80
+ html += HTML.wrap(
81
81
  "div",
82
82
  Jepson.getEFloraLink( this.#family.getJepsonID() ),
83
- { class: "section" },
84
- HTML_OPTIONS.NO_ESCAPE
83
+ { class: "section" }
85
84
  );
86
85
 
87
86
  html += Taxa.getHTMLTable( this.#family.getTaxa() );
package/lib/html.js CHANGED
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @deprecated
3
+ */
1
4
  const HTML_OPTIONS = {
2
5
  OPEN_NEW: 1,
3
6
  NO_ESCAPE: 2,
@@ -17,6 +20,9 @@ class HTML {
17
20
  return text.replaceAll( "&", "&amp;" ).replaceAll( "<", "&lt;" ).replaceAll( ">", "&gt;" );
18
21
  }
19
22
 
23
+ /**
24
+ * @deprecated
25
+ */
20
26
  static getElement( elName, text, attributes = {}, options = 0 ) {
21
27
  let html = "<" + elName;
22
28
  html += this.renderAttributes( attributes );
@@ -28,6 +34,16 @@ class HTML {
28
34
 
29
35
  }
30
36
 
37
+ static #getElement( elName, text, attributes, escape ) {
38
+ let html = "<" + elName;
39
+ html += this.renderAttributes( attributes );
40
+ if ( escape ) {
41
+ text = this.escapeText( text );
42
+ }
43
+ html += ">" + text + "</" + elName + ">";
44
+ return html;
45
+ }
46
+
31
47
  static getLink( href, linkText, attributes = {}, options = 0 ) {
32
48
  let html = "<a";
33
49
  if ( href !== undefined ) {
@@ -52,6 +68,14 @@ class HTML {
52
68
  return html;
53
69
  }
54
70
 
71
+ static textElement( elName, text, attributes = {} ) {
72
+ return this.#getElement( elName, text, attributes, true );
73
+ }
74
+
75
+ static wrap( elName, text, attributes = {} ) {
76
+ return this.#getElement( elName, text, attributes, false );
77
+ }
78
+
55
79
  }
56
80
 
57
81
  export { HTML, HTML_OPTIONS };
@@ -1,5 +1,4 @@
1
1
  import * as fs from "node:fs";
2
- import { Families } from "./families.js";
3
2
  import { HTML, HTML_OPTIONS } from "./html.js";
4
3
  import { Taxa } from "./taxa.js";
5
4
  import { HTMLPage } from "./htmlpage.js";
@@ -16,8 +15,6 @@ class PageRenderer extends BasePageRenderer {
16
15
 
17
16
  this.renderLists( outputDir );
18
17
 
19
- Families.renderPages( outputDir );
20
-
21
18
  const taxa = Taxa.getTaxa();
22
19
  for ( const taxon of taxa ) {
23
20
  new PageTaxon( taxon ).render( outputDir );
package/lib/pagetaxon.js CHANGED
@@ -151,7 +151,7 @@ class PageTaxon extends HTMLPage {
151
151
  );
152
152
  }
153
153
 
154
- html += "<div class=\"wrapper\">";
154
+ html += "<div class=\"grid\">";
155
155
  html += this.#getListSectionHTML( this.#getInfoLinks(), "Information", "info" );
156
156
  html += this.#getListSectionHTML( this.#getObsLinks(), "Observations", "obs" );
157
157
  html += this.#getListSectionHTML( this.#getRelatedTaxaLinks(), "Related Species", "rel-taxa" );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Tools to create Jekyll files for a website listing plants in an area of California.",
5
5
  "license": "MIT",
6
6
  "repository": {