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:
Ilya Kreymer
2020-09-06 17:10:48 -07:00
parent 2212678ed7
commit a3214dc081
4 changed files with 53 additions and 36 deletions
+13 -12
View File
@@ -38,8 +38,8 @@ class Pages extends LitElement
this.menuActive = false;
this.sortKey = "ts";
this.sortDesc = true;
this.sortKey = null;
this.sortDesc = null;
this.isSidebar = false;
this.url = "";
@@ -72,6 +72,7 @@ class Pages extends LitElement
sortedPages: { type: Array },
query: { type: String },
defaultKey: { type: String },
loading: { type: Boolean },
updatingSearch: { type: Boolean },
@@ -102,12 +103,15 @@ class Pages extends LitElement
async updated(changedProperties) {
if (changedProperties.has("collInfo")) {
this.updateTextSearch();
} else if (changedProperties.has("query")) {
this.filter();
// default sort to score if has query, otherwise timestamp
this.sortKey = this.query ? "" : "ts";
this.sortDesc = this.query ? false : true;
} else if (changedProperties.has("query")) {
if (this.query && !changedProperties.get("query")) {
this.sortKey = null;
this.sortDesc = null;
}
this.filter();
} else if (changedProperties.has("currList")) {
this.filter();
@@ -610,13 +614,10 @@ class Pages extends LitElement
<div class="is-hidden-tablet mobile-header">
<div class="num-results">${this.formatResults()}</div>
<wr-sorter id="pages"
.sortKey="${this.sortKey}"
.sortDesc="${this.sortDesc}"
.defaultKey="${this.sortKey ? this.sortKey : (this.query ? '' : 'ts')}"
.defaultDesc="${this.sortDesc !== null ? this.sortDesc : (this.query ? false : true)}"
.sortKeys="${Pages.sortKeys}"
.data="${this.filteredPages}"
@sort-changed="${this.onSortChanged}"
+19 -8
View File
@@ -15,10 +15,9 @@ class Sorter extends LitElement
this.data = [];
this.numResults = DEFAULT_RESULTS;
this.defaultDesc = false;
this.sortKey = "url";
this.sortDesc = false;
this.sortKey = null;
this.sortDesc = null;
this.defaultKey = "";
this.defaultDesc = false;
@@ -41,11 +40,15 @@ class Sorter extends LitElement
}
}
firstUpdated() {
this.sortKey = localStorage.getItem(`${this.id}:sortKey`) || this.defaultKey;
const sortDesc = localStorage.getItem(`${this.id}:sortDesc`);
this.sortDesc = !sortDesc ? this.defaultDesc : sortDesc === "1";
}
// firstUpdated() {
// if (this.sortKey === null && this.defaultKey) {
// this.sortKey = localStorage.getItem(`${this.id}:sortKey`) || this.defaultKey;
// }
// const sortDesc = localStorage.getItem(`${this.id}:sortDesc`);
// if (this.sortDesc === null) {
// this.sortDesc = !sortDesc ? this.defaultDesc : sortDesc === "1";
// }
// }
updated(changedProperties) {
const keyChanged = changedProperties.has("sortKey");
@@ -53,6 +56,14 @@ class Sorter extends LitElement
const dataChanged = changedProperties.has("data");
const numResultsChanged = changedProperties.has("numResults");
if (changedProperties.has("defaultKey")) {
this.sortKey = this.defaultKey;
}
if (changedProperties.has("defaultDesc")) {
this.sortDesc = this.defaultDesc;
}
if (keyChanged) {
localStorage.setItem(`${this.id}:sortKey`, this.sortKey);
}
+5 -1
View File
@@ -92,6 +92,10 @@ class Story extends LitElement
align-items: center;
}
.desc p {
margin-bottom: 1.0em;
}
.columns {
width: 100%;
height: 100%;
@@ -182,7 +186,7 @@ class Story extends LitElement
</aside>
</div>
<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>
${this.collInfo.desc ? unsafeHTML(marked(this.collInfo.desc)) : ''}
</section>
+16 -15
View File
File diff suppressed because one or more lines are too long