minor tweaks:
- add padding to markdown <p> in story mode, fixing #6? - fix page sorting: switch to best match if searching, otherwise default to date
This commit is contained in:
+13
-12
@@ -38,8 +38,8 @@ class Pages extends LitElement
|
|||||||
|
|
||||||
this.menuActive = false;
|
this.menuActive = false;
|
||||||
|
|
||||||
this.sortKey = "ts";
|
this.sortKey = null;
|
||||||
this.sortDesc = true;
|
this.sortDesc = null;
|
||||||
|
|
||||||
this.isSidebar = false;
|
this.isSidebar = false;
|
||||||
this.url = "";
|
this.url = "";
|
||||||
@@ -72,6 +72,7 @@ class Pages extends LitElement
|
|||||||
sortedPages: { type: Array },
|
sortedPages: { type: Array },
|
||||||
|
|
||||||
query: { type: String },
|
query: { type: String },
|
||||||
|
defaultKey: { type: String },
|
||||||
|
|
||||||
loading: { type: Boolean },
|
loading: { type: Boolean },
|
||||||
updatingSearch: { type: Boolean },
|
updatingSearch: { type: Boolean },
|
||||||
@@ -102,12 +103,15 @@ class Pages extends LitElement
|
|||||||
async updated(changedProperties) {
|
async updated(changedProperties) {
|
||||||
if (changedProperties.has("collInfo")) {
|
if (changedProperties.has("collInfo")) {
|
||||||
this.updateTextSearch();
|
this.updateTextSearch();
|
||||||
} else if (changedProperties.has("query")) {
|
|
||||||
this.filter();
|
|
||||||
|
|
||||||
// default sort to score if has query, otherwise timestamp
|
} else if (changedProperties.has("query")) {
|
||||||
this.sortKey = this.query ? "" : "ts";
|
|
||||||
this.sortDesc = this.query ? false : true;
|
if (this.query && !changedProperties.get("query")) {
|
||||||
|
this.sortKey = null;
|
||||||
|
this.sortDesc = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.filter();
|
||||||
|
|
||||||
} else if (changedProperties.has("currList")) {
|
} else if (changedProperties.has("currList")) {
|
||||||
this.filter();
|
this.filter();
|
||||||
@@ -610,13 +614,10 @@ class Pages extends LitElement
|
|||||||
|
|
||||||
|
|
||||||
<div class="is-hidden-tablet mobile-header">
|
<div class="is-hidden-tablet mobile-header">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="num-results">${this.formatResults()}</div>
|
<div class="num-results">${this.formatResults()}</div>
|
||||||
<wr-sorter id="pages"
|
<wr-sorter id="pages"
|
||||||
.sortKey="${this.sortKey}"
|
.defaultKey="${this.sortKey ? this.sortKey : (this.query ? '' : 'ts')}"
|
||||||
.sortDesc="${this.sortDesc}"
|
.defaultDesc="${this.sortDesc !== null ? this.sortDesc : (this.query ? false : true)}"
|
||||||
.sortKeys="${Pages.sortKeys}"
|
.sortKeys="${Pages.sortKeys}"
|
||||||
.data="${this.filteredPages}"
|
.data="${this.filteredPages}"
|
||||||
@sort-changed="${this.onSortChanged}"
|
@sort-changed="${this.onSortChanged}"
|
||||||
|
|||||||
+19
-8
@@ -15,10 +15,9 @@ class Sorter extends LitElement
|
|||||||
this.data = [];
|
this.data = [];
|
||||||
|
|
||||||
this.numResults = DEFAULT_RESULTS;
|
this.numResults = DEFAULT_RESULTS;
|
||||||
this.defaultDesc = false;
|
|
||||||
|
|
||||||
this.sortKey = "url";
|
this.sortKey = null;
|
||||||
this.sortDesc = false;
|
this.sortDesc = null;
|
||||||
|
|
||||||
this.defaultKey = "";
|
this.defaultKey = "";
|
||||||
this.defaultDesc = false;
|
this.defaultDesc = false;
|
||||||
@@ -41,11 +40,15 @@ class Sorter extends LitElement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
firstUpdated() {
|
// firstUpdated() {
|
||||||
this.sortKey = localStorage.getItem(`${this.id}:sortKey`) || this.defaultKey;
|
// if (this.sortKey === null && this.defaultKey) {
|
||||||
const sortDesc = localStorage.getItem(`${this.id}:sortDesc`);
|
// this.sortKey = localStorage.getItem(`${this.id}:sortKey`) || this.defaultKey;
|
||||||
this.sortDesc = !sortDesc ? this.defaultDesc : sortDesc === "1";
|
// }
|
||||||
}
|
// const sortDesc = localStorage.getItem(`${this.id}:sortDesc`);
|
||||||
|
// if (this.sortDesc === null) {
|
||||||
|
// this.sortDesc = !sortDesc ? this.defaultDesc : sortDesc === "1";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
updated(changedProperties) {
|
updated(changedProperties) {
|
||||||
const keyChanged = changedProperties.has("sortKey");
|
const keyChanged = changedProperties.has("sortKey");
|
||||||
@@ -53,6 +56,14 @@ class Sorter extends LitElement
|
|||||||
const dataChanged = changedProperties.has("data");
|
const dataChanged = changedProperties.has("data");
|
||||||
const numResultsChanged = changedProperties.has("numResults");
|
const numResultsChanged = changedProperties.has("numResults");
|
||||||
|
|
||||||
|
if (changedProperties.has("defaultKey")) {
|
||||||
|
this.sortKey = this.defaultKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changedProperties.has("defaultDesc")) {
|
||||||
|
this.sortDesc = this.defaultDesc;
|
||||||
|
}
|
||||||
|
|
||||||
if (keyChanged) {
|
if (keyChanged) {
|
||||||
localStorage.setItem(`${this.id}:sortKey`, this.sortKey);
|
localStorage.setItem(`${this.id}:sortKey`, this.sortKey);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -92,6 +92,10 @@ class Story extends LitElement
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.desc p {
|
||||||
|
margin-bottom: 1.0em;
|
||||||
|
}
|
||||||
|
|
||||||
.columns {
|
.columns {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -182,7 +186,7 @@ class Story extends LitElement
|
|||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
<div @scroll=${this.onScroll} class="column main-content main-scroll">
|
<div @scroll=${this.onScroll} class="column main-content main-scroll">
|
||||||
<section id="list-0" class="">
|
<section id="list-0" class="desc">
|
||||||
<h2 class="has-text-centered title is-3">${this.collInfo.title}</h2>
|
<h2 class="has-text-centered title is-3">${this.collInfo.title}</h2>
|
||||||
${this.collInfo.desc ? unsafeHTML(marked(this.collInfo.desc)) : ''}
|
${this.collInfo.desc ? unsafeHTML(marked(this.collInfo.desc)) : ''}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user