-
Couldn't load subscription status.
- Fork 1
Demo: add placeholder views #337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
48265cd
43ac1a7
91bf555
c817ada
e0d95af
b19c88f
2854c82
2c07607
489ee52
948f4a2
91240b6
f86d31a
8421e0b
4bb59d1
3fed8b5
f67a807
dba016e
f4def02
8dda6a7
334246d
de81037
ba242f2
f08df72
446072d
ab66930
9d3483b
9c65176
5490564
9138106
4517c50
4055bab
99fd951
710eee9
b88ba34
146103b
d1f3c4a
fcf3e35
030a8e5
2832383
5ee8643
12a1e60
6572655
675fcba
2b673df
2f19df1
619e47b
43fa399
082ea45
b58cf28
c6c6160
db1fc28
354c71e
c087fda
4240893
3f2ad00
c75e755
9588030
8b77dff
d60368e
c657f97
1a40ab0
f0b9733
6004db0
317b916
c7a3ed5
9b3bade
4dabdfc
94a0335
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,9 @@ import { | |
| SearchType, | ||
| StringField, | ||
| } from '@internetarchive/search-service'; | ||
| import { LocalCache } from '@internetarchive/local-cache'; | ||
| import { html, css, LitElement, PropertyValues, nothing } from 'lit'; | ||
| import { customElement, property, query, state } from 'lit/decorators.js'; | ||
| import { SharedResizeObserver } from '@internetarchive/shared-resize-observer'; | ||
| import { CollectionNameCache } from '@internetarchive/collection-name-cache'; | ||
|
|
||
| import type { ModalManagerInterface } from '@internetarchive/modal-manager'; | ||
| import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager'; | ||
|
|
@@ -28,13 +26,6 @@ export class AppRoot extends LitElement { | |
|
|
||
| private resizeObserver = new SharedResizeObserver(); | ||
|
|
||
| private localCache = new LocalCache(); | ||
|
|
||
| private collectionNameCache = new CollectionNameCache({ | ||
| searchService: this.searchService, | ||
| localCache: this.localCache, | ||
| }); | ||
|
|
||
| @state() private toggleSlots: boolean = false; | ||
|
|
||
| @state() private currentPage?: number; | ||
|
|
@@ -404,6 +395,55 @@ export class AppRoot extends LitElement { | |
| </label> | ||
| </div> | ||
| </fieldset> | ||
| <fieldset class="Placeholder-type"> | ||
| <legend>Placeholder type</legend> | ||
| <div class="checkbox-control"> | ||
| <input | ||
| type="button" | ||
| id="placeholder-empty-query" | ||
| @click=${() => this.showEmptyPlaceholder('empty query')} | ||
| value="empty query" | ||
| /> | ||
| </div> | ||
| ${this.withinCollection | ||
| ? html` | ||
| <div class="checkbox-control"> | ||
| <input | ||
| type="button" | ||
| id="placeholder-collection-err" | ||
| @click=${() => | ||
| this.showEmptyPlaceholder('collection error')} | ||
| value="collection error" | ||
| /> | ||
| </div> | ||
| <div class="checkbox-control"> | ||
| <input | ||
| type="button" | ||
| id="placeholder-no-results" | ||
| @click=${() => | ||
| this.showEmptyPlaceholder('empty collection')} | ||
| value="empty collection" | ||
| /> | ||
| </div> | ||
| ` | ||
| : nothing} | ||
| <div class="checkbox-control"> | ||
| <input | ||
| type="button" | ||
| id="placeholder-query-err" | ||
| @click=${() => this.showEmptyPlaceholder('query error')} | ||
| value="query error" | ||
| /> | ||
| </div> | ||
| <div class="checkbox-control"> | ||
| <input | ||
| type="button" | ||
| id="placeholder-loading" | ||
| @click=${() => this.showEmptyPlaceholder('placeholder loading')} | ||
| value="placeholder loading" | ||
| /> | ||
| </div> | ||
| </fieldset> | ||
| </div> | ||
| <button id="toggle-dev-tools-btn" @click=${this.toggleDevTools}> | ||
| Toggle Search Controls | ||
|
|
@@ -415,7 +455,6 @@ export class AppRoot extends LitElement { | |
| .baseImageUrl=${'https://archive.org'} | ||
| .searchService=${this.searchService} | ||
| .resizeObserver=${this.resizeObserver} | ||
| .collectionNameCache=${this.collectionNameCache} | ||
| .showHistogramDatePicker=${true} | ||
| .loggedIn=${this.loggedIn} | ||
| .modalManager=${this.modalManager} | ||
|
|
@@ -499,6 +538,50 @@ export class AppRoot extends LitElement { | |
| } | ||
| } | ||
|
|
||
| private async showEmptyPlaceholder(placeholderType: string) { | ||
| switch (placeholderType) { | ||
| case 'empty query': | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know we are on demo for developers but we should not use string slugs for checking conditions. I would write these something like |
||
| this.collectionBrowser.baseQuery = ''; | ||
| this.collectionBrowser.withinCollection = ''; | ||
| this.collectionBrowser.withinProfile = ''; | ||
| break; | ||
| case 'empty collection': | ||
| this.collectionBrowser.baseQuery = ''; | ||
| this.collectionBrowser.withinProfile = ''; | ||
| await this.collectionBrowser.updateComplete; | ||
|
|
||
| break; | ||
| case 'empty profile': | ||
| this.collectionBrowser.baseQuery = ''; | ||
| this.collectionBrowser.withinCollection = ''; | ||
| this.collectionBrowser.withinProfile = '@brewster'; | ||
| break; | ||
| case 'collection error': | ||
| this.collectionBrowser.withinCollection = 'acdc'; | ||
| await this.collectionBrowser.updateComplete; | ||
|
|
||
| this.collectionBrowser.baseQuery = ''; | ||
| this.collectionBrowser.queryErrorMessage = 'foo message'; | ||
| break; | ||
| case 'query error': | ||
| this.collectionBrowser.baseQuery = ''; | ||
| this.collectionBrowser.withinCollection = ''; | ||
| this.collectionBrowser.queryErrorMessage = 'foo message'; | ||
| break; | ||
| case 'placeholder loading': | ||
| this.collectionBrowser.baseQuery = ''; | ||
| this.collectionBrowser.setSearchResultsLoading(true); | ||
| this.collectionBrowser.setFacetsLoading(true); | ||
| this.collectionBrowser.suppressPlaceholders = true; | ||
| this.collectionBrowser.clearResultsOnEmptyQuery = true; | ||
| this.requestUpdate(); | ||
| await this.collectionBrowser.updateComplete; | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| private toggleFacetGroupOutline(e: Event) { | ||
| const target = e.target as HTMLInputElement; | ||
| if (target.checked) { | ||
|
|
@@ -552,6 +635,7 @@ export class AppRoot extends LitElement { | |
| const oldQuery = this.searchQuery; | ||
| this.searchQuery = ''; // Should just reset to the placeholder | ||
| await this.updateComplete; | ||
| this.collectionBrowser.suppressPlaceholders = false; | ||
| // For unclear reasons, Safari refuses to re-apply the old query until the next tick, hence: | ||
| await new Promise(res => { | ||
| setTimeout(res, 0); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.