@internetarchive/collection-browser 3.3.1 → 3.3.3
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.
- package/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +4 -4
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/collection-browser.js +683 -683
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.js +118 -118
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets.js +265 -266
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/data-source/models.js.map +1 -1
- package/dist/src/tiles/base-tile-component.js.map +1 -1
- package/dist/src/tiles/grid/account-tile.js +36 -36
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +77 -77
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +137 -137
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.d.ts +9 -1
- package/dist/src/tiles/hover/hover-pane-controller.js +105 -37
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
- package/dist/src/tiles/hover/tile-hover-pane.d.ts +1 -0
- package/dist/src/tiles/hover/tile-hover-pane.js +115 -112
- package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +99 -99
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +297 -297
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.d.ts +4 -1
- package/dist/src/tiles/tile-dispatcher.js +231 -204
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/utils/format-date.js.map +1 -1
- package/dist/test/collection-browser.test.js +189 -189
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +77 -77
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +68 -21
- package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js +70 -70
- package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +126 -126
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +130 -52
- package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
- package/dist/test/utils/format-date.test.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +118 -117
- package/renovate.json +6 -6
- package/src/collection-browser.ts +2829 -2829
- package/src/collection-facets/more-facets-content.ts +639 -639
- package/src/collection-facets.ts +994 -995
- package/src/data-source/collection-browser-data-source.ts +1401 -1401
- package/src/data-source/collection-browser-query-state.ts +65 -65
- package/src/data-source/models.ts +43 -43
- package/src/tiles/base-tile-component.ts +65 -65
- package/src/tiles/grid/account-tile.ts +113 -113
- package/src/tiles/grid/collection-tile.ts +163 -163
- package/src/tiles/grid/item-tile.ts +340 -340
- package/src/tiles/hover/hover-pane-controller.ts +613 -517
- package/src/tiles/hover/tile-hover-pane.ts +184 -180
- package/src/tiles/list/tile-list-compact.ts +239 -239
- package/src/tiles/list/tile-list.ts +700 -700
- package/src/tiles/tile-dispatcher.ts +517 -490
- package/src/utils/format-date.ts +62 -62
- package/test/collection-browser.test.ts +2403 -2403
- package/test/tiles/grid/item-tile.test.ts +520 -520
- package/test/tiles/hover/hover-pane-controller.test.ts +418 -353
- package/test/tiles/list/tile-list-compact.test.ts +282 -282
- package/test/tiles/list/tile-list.test.ts +552 -552
- package/test/tiles/tile-dispatcher.test.ts +283 -187
- package/test/utils/format-date.test.ts +89 -89
- package/tsconfig.json +20 -20
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CollectionExtraInfo,
|
|
3
|
-
PageElementName,
|
|
4
|
-
SearchServiceInterface,
|
|
5
|
-
SearchType,
|
|
6
|
-
SortDirection,
|
|
7
|
-
SortParam,
|
|
8
|
-
} from '@internetarchive/search-service';
|
|
9
|
-
import type {
|
|
10
|
-
FacetLoadStrategy,
|
|
11
|
-
SelectedFacets,
|
|
12
|
-
SortField,
|
|
13
|
-
TvClipFilterType,
|
|
14
|
-
} from '../models';
|
|
15
|
-
import type { CollectionBrowserDataSourceInterface } from './collection-browser-data-source-interface';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Properties of collection browser that affect the overall search query
|
|
19
|
-
*/
|
|
20
|
-
export interface CollectionBrowserQueryState {
|
|
21
|
-
baseQuery?: string;
|
|
22
|
-
identifiers?: string[];
|
|
23
|
-
withinCollection?: string;
|
|
24
|
-
withinProfile?: string;
|
|
25
|
-
profileElement?: PageElementName;
|
|
26
|
-
searchType: SearchType;
|
|
27
|
-
selectedFacets?: SelectedFacets;
|
|
28
|
-
internalFilters?: SelectedFacets;
|
|
29
|
-
minSelectedDate?: string;
|
|
30
|
-
maxSelectedDate?: string;
|
|
31
|
-
selectedTitleFilter: string | null;
|
|
32
|
-
selectedCreatorFilter: string | null;
|
|
33
|
-
tvClipFilter?: TvClipFilterType;
|
|
34
|
-
selectedSort?: SortField;
|
|
35
|
-
sortDirection: SortDirection | null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Interface representing search-related state and operations required by the
|
|
40
|
-
* data source on its host component.
|
|
41
|
-
*/
|
|
42
|
-
export interface CollectionBrowserSearchInterface
|
|
43
|
-
extends CollectionBrowserQueryState {
|
|
44
|
-
searchService?: SearchServiceInterface;
|
|
45
|
-
isTVCollection: boolean;
|
|
46
|
-
readonly sortParam: SortParam | null;
|
|
47
|
-
readonly defaultSortField: SortField | null;
|
|
48
|
-
readonly facetLoadStrategy: FacetLoadStrategy;
|
|
49
|
-
readonly initialPageNumber: number;
|
|
50
|
-
readonly maxPagesToManage: number;
|
|
51
|
-
readonly currentVisiblePageNumbers: number[];
|
|
52
|
-
readonly clearResultsOnEmptyQuery?: boolean;
|
|
53
|
-
readonly dataSource?: CollectionBrowserDataSourceInterface;
|
|
54
|
-
|
|
55
|
-
getSessionId(): Promise<string>;
|
|
56
|
-
setSearchResultsLoading(loading: boolean): void;
|
|
57
|
-
setFacetsLoading(loading: boolean): void;
|
|
58
|
-
setTotalResultCount(count: number): void;
|
|
59
|
-
setTileCount(count: number): void;
|
|
60
|
-
applyDefaultCollectionSort(collectionInfo?: CollectionExtraInfo): void;
|
|
61
|
-
emitEmptyResults(): void;
|
|
62
|
-
emitSearchError(): void;
|
|
63
|
-
emitQueryStateChanged(): void;
|
|
64
|
-
refreshVisibleResults(): void;
|
|
65
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
CollectionExtraInfo,
|
|
3
|
+
PageElementName,
|
|
4
|
+
SearchServiceInterface,
|
|
5
|
+
SearchType,
|
|
6
|
+
SortDirection,
|
|
7
|
+
SortParam,
|
|
8
|
+
} from '@internetarchive/search-service';
|
|
9
|
+
import type {
|
|
10
|
+
FacetLoadStrategy,
|
|
11
|
+
SelectedFacets,
|
|
12
|
+
SortField,
|
|
13
|
+
TvClipFilterType,
|
|
14
|
+
} from '../models';
|
|
15
|
+
import type { CollectionBrowserDataSourceInterface } from './collection-browser-data-source-interface';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Properties of collection browser that affect the overall search query
|
|
19
|
+
*/
|
|
20
|
+
export interface CollectionBrowserQueryState {
|
|
21
|
+
baseQuery?: string;
|
|
22
|
+
identifiers?: string[];
|
|
23
|
+
withinCollection?: string;
|
|
24
|
+
withinProfile?: string;
|
|
25
|
+
profileElement?: PageElementName;
|
|
26
|
+
searchType: SearchType;
|
|
27
|
+
selectedFacets?: SelectedFacets;
|
|
28
|
+
internalFilters?: SelectedFacets;
|
|
29
|
+
minSelectedDate?: string;
|
|
30
|
+
maxSelectedDate?: string;
|
|
31
|
+
selectedTitleFilter: string | null;
|
|
32
|
+
selectedCreatorFilter: string | null;
|
|
33
|
+
tvClipFilter?: TvClipFilterType;
|
|
34
|
+
selectedSort?: SortField;
|
|
35
|
+
sortDirection: SortDirection | null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Interface representing search-related state and operations required by the
|
|
40
|
+
* data source on its host component.
|
|
41
|
+
*/
|
|
42
|
+
export interface CollectionBrowserSearchInterface
|
|
43
|
+
extends CollectionBrowserQueryState {
|
|
44
|
+
searchService?: SearchServiceInterface;
|
|
45
|
+
isTVCollection: boolean;
|
|
46
|
+
readonly sortParam: SortParam | null;
|
|
47
|
+
readonly defaultSortField: SortField | null;
|
|
48
|
+
readonly facetLoadStrategy: FacetLoadStrategy;
|
|
49
|
+
readonly initialPageNumber: number;
|
|
50
|
+
readonly maxPagesToManage: number;
|
|
51
|
+
readonly currentVisiblePageNumbers: number[];
|
|
52
|
+
readonly clearResultsOnEmptyQuery?: boolean;
|
|
53
|
+
readonly dataSource?: CollectionBrowserDataSourceInterface;
|
|
54
|
+
|
|
55
|
+
getSessionId(): Promise<string>;
|
|
56
|
+
setSearchResultsLoading(loading: boolean): void;
|
|
57
|
+
setFacetsLoading(loading: boolean): void;
|
|
58
|
+
setTotalResultCount(count: number): void;
|
|
59
|
+
setTileCount(count: number): void;
|
|
60
|
+
applyDefaultCollectionSort(collectionInfo?: CollectionExtraInfo): void;
|
|
61
|
+
emitEmptyResults(): void;
|
|
62
|
+
emitSearchError(): void;
|
|
63
|
+
emitQueryStateChanged(): void;
|
|
64
|
+
refreshVisibleResults(): void;
|
|
65
|
+
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
PageElementName,
|
|
3
|
-
PageType,
|
|
4
|
-
} from '@internetarchive/search-service';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A Map from collection identifiers to their corresponding collection titles.
|
|
8
|
-
*/
|
|
9
|
-
export type CollectionTitles = Map<string, string>;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* A Map from channel names to their corresponding, more human-readable network name.
|
|
13
|
-
*/
|
|
14
|
-
export type TVChannelAliases = Map<string, string>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The subset of search service params that uniquely specify the type of results
|
|
18
|
-
* that are sought by an instance of collection browser.
|
|
19
|
-
*/
|
|
20
|
-
export type PageSpecifierParams = {
|
|
21
|
-
/**
|
|
22
|
-
* What high-level type of page is being fetched for (search results, collection, or profile)
|
|
23
|
-
*/
|
|
24
|
-
pageType: PageType;
|
|
25
|
-
/**
|
|
26
|
-
* The target identifier for collection or profile pages (e.g., "prelinger", "@brewster", ...)
|
|
27
|
-
*/
|
|
28
|
-
pageTarget?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Which specific elements of a profile page to fetch. Corresponds to individual tab data
|
|
31
|
-
* (e.g., "uploads", "reviews", ...)
|
|
32
|
-
*/
|
|
33
|
-
pageElements?: PageElementName[];
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* List of profile page elements that do not currently allow faceting
|
|
38
|
-
*/
|
|
39
|
-
export const FACETLESS_PAGE_ELEMENTS: PageElementName[] = [
|
|
40
|
-
'forum_posts',
|
|
41
|
-
'lending',
|
|
42
|
-
'web_archives',
|
|
43
|
-
];
|
|
1
|
+
import type {
|
|
2
|
+
PageElementName,
|
|
3
|
+
PageType,
|
|
4
|
+
} from '@internetarchive/search-service';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Map from collection identifiers to their corresponding collection titles.
|
|
8
|
+
*/
|
|
9
|
+
export type CollectionTitles = Map<string, string>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A Map from channel names to their corresponding, more human-readable network name.
|
|
13
|
+
*/
|
|
14
|
+
export type TVChannelAliases = Map<string, string>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The subset of search service params that uniquely specify the type of results
|
|
18
|
+
* that are sought by an instance of collection browser.
|
|
19
|
+
*/
|
|
20
|
+
export type PageSpecifierParams = {
|
|
21
|
+
/**
|
|
22
|
+
* What high-level type of page is being fetched for (search results, collection, or profile)
|
|
23
|
+
*/
|
|
24
|
+
pageType: PageType;
|
|
25
|
+
/**
|
|
26
|
+
* The target identifier for collection or profile pages (e.g., "prelinger", "@brewster", ...)
|
|
27
|
+
*/
|
|
28
|
+
pageTarget?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Which specific elements of a profile page to fetch. Corresponds to individual tab data
|
|
31
|
+
* (e.g., "uploads", "reviews", ...)
|
|
32
|
+
*/
|
|
33
|
+
pageElements?: PageElementName[];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* List of profile page elements that do not currently allow faceting
|
|
38
|
+
*/
|
|
39
|
+
export const FACETLESS_PAGE_ELEMENTS: PageElementName[] = [
|
|
40
|
+
'forum_posts',
|
|
41
|
+
'lending',
|
|
42
|
+
'web_archives',
|
|
43
|
+
];
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
import type { SortParam } from '@internetarchive/search-service';
|
|
4
|
-
import { TileDisplayValueProvider } from './tile-display-value-provider';
|
|
5
|
-
import type { TileModel } from '../models';
|
|
6
|
-
import { DateFormat, formatDate } from '../utils/format-date';
|
|
7
|
-
|
|
8
|
-
export abstract class BaseTileComponent extends LitElement {
|
|
9
|
-
@property({ type: Object }) model?: TileModel;
|
|
10
|
-
|
|
11
|
-
@property({ type: Number }) currentWidth?: number;
|
|
12
|
-
|
|
13
|
-
@property({ type: Number }) currentHeight?: number;
|
|
14
|
-
|
|
15
|
-
@property({ type: String }) baseNavigationUrl?: string;
|
|
16
|
-
|
|
17
|
-
@property({ type: String }) baseImageUrl?: string;
|
|
18
|
-
|
|
19
|
-
@property({ type: String }) collectionPagePath?: string;
|
|
20
|
-
|
|
21
|
-
@property({ type: Object }) sortParam: SortParam | null = null;
|
|
22
|
-
|
|
23
|
-
@property({ type: Object }) defaultSortParam: SortParam | null = null;
|
|
24
|
-
|
|
25
|
-
@property({ type: String }) creatorFilter?: string;
|
|
26
|
-
|
|
27
|
-
@property({ type: Number }) mobileBreakpoint?: number;
|
|
28
|
-
|
|
29
|
-
@property({ type: Boolean }) loggedIn = false;
|
|
30
|
-
|
|
31
|
-
@property({ type: Boolean }) suppressBlurring = false;
|
|
32
|
-
|
|
33
|
-
@property({ type: Boolean }) useLocalTime = false;
|
|
34
|
-
|
|
35
|
-
protected displayValueProvider = new TileDisplayValueProvider();
|
|
36
|
-
|
|
37
|
-
protected willUpdate(changed: PropertyValues<this>) {
|
|
38
|
-
// Ensure the TileDisplayValueProvider stays up-to-date as properties change
|
|
39
|
-
if (
|
|
40
|
-
changed.has('model') ||
|
|
41
|
-
changed.has('baseNavigationUrl') ||
|
|
42
|
-
changed.has('collectionPagePath') ||
|
|
43
|
-
changed.has('sortParam') ||
|
|
44
|
-
changed.has('defaultSortParam') ||
|
|
45
|
-
changed.has('creatorFilter')
|
|
46
|
-
) {
|
|
47
|
-
this.displayValueProvider = new TileDisplayValueProvider({
|
|
48
|
-
model: this.model,
|
|
49
|
-
baseNavigationUrl: this.baseNavigationUrl,
|
|
50
|
-
collectionPagePath: this.collectionPagePath,
|
|
51
|
-
sortParam: this.sortParam ?? this.defaultSortParam ?? undefined,
|
|
52
|
-
creatorFilter: this.creatorFilter,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The formatted date string for given date and format type, taking into
|
|
59
|
-
* account whether this tile component should be using local time or UTC.
|
|
60
|
-
*/
|
|
61
|
-
protected getFormattedDate(date?: Date, format?: DateFormat): string {
|
|
62
|
-
const { useLocalTime } = this;
|
|
63
|
-
return formatDate(date, format, { useLocalTime });
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import type { SortParam } from '@internetarchive/search-service';
|
|
4
|
+
import { TileDisplayValueProvider } from './tile-display-value-provider';
|
|
5
|
+
import type { TileModel } from '../models';
|
|
6
|
+
import { DateFormat, formatDate } from '../utils/format-date';
|
|
7
|
+
|
|
8
|
+
export abstract class BaseTileComponent extends LitElement {
|
|
9
|
+
@property({ type: Object }) model?: TileModel;
|
|
10
|
+
|
|
11
|
+
@property({ type: Number }) currentWidth?: number;
|
|
12
|
+
|
|
13
|
+
@property({ type: Number }) currentHeight?: number;
|
|
14
|
+
|
|
15
|
+
@property({ type: String }) baseNavigationUrl?: string;
|
|
16
|
+
|
|
17
|
+
@property({ type: String }) baseImageUrl?: string;
|
|
18
|
+
|
|
19
|
+
@property({ type: String }) collectionPagePath?: string;
|
|
20
|
+
|
|
21
|
+
@property({ type: Object }) sortParam: SortParam | null = null;
|
|
22
|
+
|
|
23
|
+
@property({ type: Object }) defaultSortParam: SortParam | null = null;
|
|
24
|
+
|
|
25
|
+
@property({ type: String }) creatorFilter?: string;
|
|
26
|
+
|
|
27
|
+
@property({ type: Number }) mobileBreakpoint?: number;
|
|
28
|
+
|
|
29
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
30
|
+
|
|
31
|
+
@property({ type: Boolean }) suppressBlurring = false;
|
|
32
|
+
|
|
33
|
+
@property({ type: Boolean }) useLocalTime = false;
|
|
34
|
+
|
|
35
|
+
protected displayValueProvider = new TileDisplayValueProvider();
|
|
36
|
+
|
|
37
|
+
protected willUpdate(changed: PropertyValues<this>) {
|
|
38
|
+
// Ensure the TileDisplayValueProvider stays up-to-date as properties change
|
|
39
|
+
if (
|
|
40
|
+
changed.has('model') ||
|
|
41
|
+
changed.has('baseNavigationUrl') ||
|
|
42
|
+
changed.has('collectionPagePath') ||
|
|
43
|
+
changed.has('sortParam') ||
|
|
44
|
+
changed.has('defaultSortParam') ||
|
|
45
|
+
changed.has('creatorFilter')
|
|
46
|
+
) {
|
|
47
|
+
this.displayValueProvider = new TileDisplayValueProvider({
|
|
48
|
+
model: this.model,
|
|
49
|
+
baseNavigationUrl: this.baseNavigationUrl,
|
|
50
|
+
collectionPagePath: this.collectionPagePath,
|
|
51
|
+
sortParam: this.sortParam ?? this.defaultSortParam ?? undefined,
|
|
52
|
+
creatorFilter: this.creatorFilter,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The formatted date string for given date and format type, taking into
|
|
59
|
+
* account whether this tile component should be using local time or UTC.
|
|
60
|
+
*/
|
|
61
|
+
protected getFormattedDate(date?: Date, format?: DateFormat): string {
|
|
62
|
+
const { useLocalTime } = this;
|
|
63
|
+
return formatDate(date, format, { useLocalTime });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
import { css, html, nothing, TemplateResult } from 'lit';
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
-
import { msg } from '@lit/localize';
|
|
4
|
-
import { BaseTileComponent } from '../base-tile-component';
|
|
5
|
-
|
|
6
|
-
import { baseTileStyles } from './styles/tile-grid-shared-styles';
|
|
7
|
-
import '../image-block';
|
|
8
|
-
import './tile-stats';
|
|
9
|
-
|
|
10
|
-
@customElement('account-tile')
|
|
11
|
-
export class AccountTile extends BaseTileComponent {
|
|
12
|
-
/*
|
|
13
|
-
* Reactive properties inherited from BaseTileComponent:
|
|
14
|
-
* - model?: TileModel;
|
|
15
|
-
* - currentWidth?: number;
|
|
16
|
-
* - currentHeight?: number;
|
|
17
|
-
* - baseNavigationUrl?: string;
|
|
18
|
-
* - baseImageUrl?: string;
|
|
19
|
-
* - collectionPagePath?: string;
|
|
20
|
-
* - sortParam: SortParam | null = null;
|
|
21
|
-
* - creatorFilter?: string;
|
|
22
|
-
* - mobileBreakpoint?: number;
|
|
23
|
-
* - loggedIn = false;
|
|
24
|
-
* - suppressBlurring = false;
|
|
25
|
-
* - useLocalTime = false;
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
@property({ type: Boolean }) showInfoButton = false;
|
|
29
|
-
|
|
30
|
-
render() {
|
|
31
|
-
return html`
|
|
32
|
-
<div class="container">
|
|
33
|
-
${this.infoButtonTemplate}
|
|
34
|
-
<div class="tile-details">
|
|
35
|
-
<div class="item-info">
|
|
36
|
-
${this.getAvatarTemplate} ${this.getTitleTemplate}
|
|
37
|
-
${this.getArchivistTemplate}
|
|
38
|
-
</div>
|
|
39
|
-
${this.getTileStatsTemplate}
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private get getAvatarTemplate(): TemplateResult {
|
|
46
|
-
return html`
|
|
47
|
-
<image-block
|
|
48
|
-
.model=${this.model}
|
|
49
|
-
.baseImageUrl=${this.baseImageUrl}
|
|
50
|
-
.viewSize=${'grid'}
|
|
51
|
-
.suppressBlurring=${this.suppressBlurring}
|
|
52
|
-
>
|
|
53
|
-
</image-block>
|
|
54
|
-
`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private get getTitleTemplate() {
|
|
58
|
-
return html`<div id="title">
|
|
59
|
-
<h4 class="truncated">${this.model?.identifier}</h4>
|
|
60
|
-
</div>`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private get getArchivistTemplate() {
|
|
64
|
-
return html`<div class="archivist-since">
|
|
65
|
-
<span>${this.displayValueProvider.accountLabel}</span>
|
|
66
|
-
</div>`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private get getTileStatsTemplate() {
|
|
70
|
-
return html`<tile-stats
|
|
71
|
-
.mediatype=${this.model?.mediatype}
|
|
72
|
-
.itemCount=${this.model?.itemCount}
|
|
73
|
-
.favCount=${this.model?.favCount}
|
|
74
|
-
.commentCount=${this.model?.commentCount}
|
|
75
|
-
>
|
|
76
|
-
</tile-stats>`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private get infoButtonTemplate(): TemplateResult | typeof nothing {
|
|
80
|
-
// ⓘ is an information icon
|
|
81
|
-
return this.showInfoButton
|
|
82
|
-
? html`<button class="info-button" @click=${this.infoButtonPressed}>
|
|
83
|
-
ⓘ
|
|
84
|
-
<span class="sr-only">${msg('More info')}</span>
|
|
85
|
-
</button>`
|
|
86
|
-
: nothing;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private infoButtonPressed(e: PointerEvent) {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
const event = new CustomEvent<{ x: number; y: number }>(
|
|
92
|
-
'infoButtonPressed',
|
|
93
|
-
{ detail: { x: e.clientX, y: e.clientY } },
|
|
94
|
-
);
|
|
95
|
-
this.dispatchEvent(event);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* CSS
|
|
100
|
-
*/
|
|
101
|
-
static get styles() {
|
|
102
|
-
const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;
|
|
103
|
-
|
|
104
|
-
return [
|
|
105
|
-
baseTileStyles,
|
|
106
|
-
css`
|
|
107
|
-
.container {
|
|
108
|
-
border: 1px solid ${tileBorderColor};
|
|
109
|
-
}
|
|
110
|
-
`,
|
|
111
|
-
];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
1
|
+
import { css, html, nothing, TemplateResult } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { msg } from '@lit/localize';
|
|
4
|
+
import { BaseTileComponent } from '../base-tile-component';
|
|
5
|
+
|
|
6
|
+
import { baseTileStyles } from './styles/tile-grid-shared-styles';
|
|
7
|
+
import '../image-block';
|
|
8
|
+
import './tile-stats';
|
|
9
|
+
|
|
10
|
+
@customElement('account-tile')
|
|
11
|
+
export class AccountTile extends BaseTileComponent {
|
|
12
|
+
/*
|
|
13
|
+
* Reactive properties inherited from BaseTileComponent:
|
|
14
|
+
* - model?: TileModel;
|
|
15
|
+
* - currentWidth?: number;
|
|
16
|
+
* - currentHeight?: number;
|
|
17
|
+
* - baseNavigationUrl?: string;
|
|
18
|
+
* - baseImageUrl?: string;
|
|
19
|
+
* - collectionPagePath?: string;
|
|
20
|
+
* - sortParam: SortParam | null = null;
|
|
21
|
+
* - creatorFilter?: string;
|
|
22
|
+
* - mobileBreakpoint?: number;
|
|
23
|
+
* - loggedIn = false;
|
|
24
|
+
* - suppressBlurring = false;
|
|
25
|
+
* - useLocalTime = false;
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
@property({ type: Boolean }) showInfoButton = false;
|
|
29
|
+
|
|
30
|
+
render() {
|
|
31
|
+
return html`
|
|
32
|
+
<div class="container">
|
|
33
|
+
${this.infoButtonTemplate}
|
|
34
|
+
<div class="tile-details">
|
|
35
|
+
<div class="item-info">
|
|
36
|
+
${this.getAvatarTemplate} ${this.getTitleTemplate}
|
|
37
|
+
${this.getArchivistTemplate}
|
|
38
|
+
</div>
|
|
39
|
+
${this.getTileStatsTemplate}
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private get getAvatarTemplate(): TemplateResult {
|
|
46
|
+
return html`
|
|
47
|
+
<image-block
|
|
48
|
+
.model=${this.model}
|
|
49
|
+
.baseImageUrl=${this.baseImageUrl}
|
|
50
|
+
.viewSize=${'grid'}
|
|
51
|
+
.suppressBlurring=${this.suppressBlurring}
|
|
52
|
+
>
|
|
53
|
+
</image-block>
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private get getTitleTemplate() {
|
|
58
|
+
return html`<div id="title">
|
|
59
|
+
<h4 class="truncated">${this.model?.identifier}</h4>
|
|
60
|
+
</div>`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private get getArchivistTemplate() {
|
|
64
|
+
return html`<div class="archivist-since">
|
|
65
|
+
<span>${this.displayValueProvider.accountLabel}</span>
|
|
66
|
+
</div>`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private get getTileStatsTemplate() {
|
|
70
|
+
return html`<tile-stats
|
|
71
|
+
.mediatype=${this.model?.mediatype}
|
|
72
|
+
.itemCount=${this.model?.itemCount}
|
|
73
|
+
.favCount=${this.model?.favCount}
|
|
74
|
+
.commentCount=${this.model?.commentCount}
|
|
75
|
+
>
|
|
76
|
+
</tile-stats>`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private get infoButtonTemplate(): TemplateResult | typeof nothing {
|
|
80
|
+
// ⓘ is an information icon
|
|
81
|
+
return this.showInfoButton
|
|
82
|
+
? html`<button class="info-button" @click=${this.infoButtonPressed}>
|
|
83
|
+
ⓘ
|
|
84
|
+
<span class="sr-only">${msg('More info')}</span>
|
|
85
|
+
</button>`
|
|
86
|
+
: nothing;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private infoButtonPressed(e: PointerEvent) {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
const event = new CustomEvent<{ x: number; y: number }>(
|
|
92
|
+
'infoButtonPressed',
|
|
93
|
+
{ detail: { x: e.clientX, y: e.clientY } },
|
|
94
|
+
);
|
|
95
|
+
this.dispatchEvent(event);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* CSS
|
|
100
|
+
*/
|
|
101
|
+
static get styles() {
|
|
102
|
+
const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;
|
|
103
|
+
|
|
104
|
+
return [
|
|
105
|
+
baseTileStyles,
|
|
106
|
+
css`
|
|
107
|
+
.container {
|
|
108
|
+
border: 1px solid ${tileBorderColor};
|
|
109
|
+
}
|
|
110
|
+
`,
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
}
|