@internetarchive/collection-browser 4.4.0 → 4.5.0
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/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/src/app-root.d.ts +8 -0
- package/dist/src/app-root.js +26 -0
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +8 -0
- package/dist/src/collection-browser.js +19 -1
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.d.ts +6 -0
- package/dist/src/collection-facets/facet-row.js +158 -140
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/facets-template.js +25 -23
- package/dist/src/collection-facets/facets-template.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/styles/tile-action-styles.d.ts +14 -0
- package/dist/src/styles/tile-action-styles.js +59 -0
- package/dist/src/styles/tile-action-styles.js.map +1 -0
- package/dist/src/tiles/base-tile-component.d.ts +17 -1
- package/dist/src/tiles/base-tile-component.js +50 -1
- package/dist/src/tiles/base-tile-component.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +139 -138
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/item-image.js +28 -28
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact-header.js +71 -46
- package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.d.ts +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +138 -100
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +1 -1
- package/dist/src/tiles/list/tile-list.js +316 -298
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/models.d.ts +11 -0
- package/dist/src/tiles/models.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.d.ts +14 -0
- package/dist/src/tiles/tile-dispatcher.js +319 -216
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.js +2 -1
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.js +55 -23
- package/dist/test/collection-facets/facet-row.test.js.map +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +79 -79
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +136 -136
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +101 -87
- package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
- package/index.ts +29 -28
- package/package.json +2 -2
- package/src/app-root.ts +30 -0
- package/src/collection-browser.ts +16 -1
- package/src/collection-facets/facet-row.ts +309 -299
- package/src/collection-facets/facets-template.ts +85 -83
- package/src/data-source/collection-browser-data-source.ts +1465 -1465
- package/src/styles/tile-action-styles.ts +59 -0
- package/src/tiles/base-tile-component.ts +124 -65
- package/src/tiles/grid/item-tile.ts +347 -346
- package/src/tiles/item-image.ts +214 -214
- package/src/tiles/list/tile-list-compact-header.ts +112 -86
- package/src/tiles/list/tile-list-compact.ts +278 -239
- package/src/tiles/list/tile-list.ts +718 -700
- package/src/tiles/models.ts +21 -8
- package/src/tiles/tile-dispatcher.ts +637 -527
- package/src/tiles/tile-display-value-provider.ts +133 -134
- package/test/collection-facets/facet-row.test.ts +421 -375
- package/test/tiles/grid/item-tile.test.ts +520 -520
- package/test/tiles/list/tile-list.test.ts +576 -576
- package/test/tiles/tile-dispatcher.test.ts +320 -300
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared styles for tile action buttons rendered in grid, list-detail, and
|
|
5
|
+
* list-compact display modes. Layout positioning is handled by each tile
|
|
6
|
+
* component; these styles cover only the button appearance and the row
|
|
7
|
+
* container's default flex behavior.
|
|
8
|
+
*
|
|
9
|
+
* Customizable via CSS custom properties:
|
|
10
|
+
* - `--tileActionColor` (defaults to --primaryErrorCTAFill, then #d9534f)
|
|
11
|
+
* - `--tileActionBg` (default: #fff)
|
|
12
|
+
* - `--tileActionBorderColor` (defaults to --primaryErrorCTAFill, then #d9534f)
|
|
13
|
+
* - `--tileActionHoverBg` (defaults to --primaryErrorCTAFillRGB at 20% alpha)
|
|
14
|
+
* - `--tileActionHoverColor` (defaults to --tileActionColor)
|
|
15
|
+
*/
|
|
16
|
+
export const tileActionStyles = css`
|
|
17
|
+
.tile-actions {
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
display: flex;
|
|
20
|
+
gap: var(--tileActionGap, 0);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tile-action-btn {
|
|
24
|
+
flex: 1;
|
|
25
|
+
padding: 6px 5px;
|
|
26
|
+
border: 2px solid
|
|
27
|
+
var(--tileActionBorderColor, var(--primaryErrorCTAFill, #d9534f));
|
|
28
|
+
border-radius: var(--tileActionBorderRadius, 0);
|
|
29
|
+
/* Inherit from the surrounding tile rather than the UA default for <button> */
|
|
30
|
+
font-family: inherit;
|
|
31
|
+
font-size: 1.2rem;
|
|
32
|
+
font-weight: bold;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
color: var(--tileActionColor, var(--primaryErrorCTAFill, #d9534f));
|
|
35
|
+
background: var(--tileActionBg, #fff);
|
|
36
|
+
transition:
|
|
37
|
+
background 0.15s,
|
|
38
|
+
color 0.15s;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* When buttons are flush against each other (no gap), overlap their shared
|
|
43
|
+
* edge by 1px so adjacent borders don't double up.
|
|
44
|
+
*/
|
|
45
|
+
.tile-action-btn + .tile-action-btn {
|
|
46
|
+
margin-left: -1px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.tile-action-btn:hover {
|
|
50
|
+
background: var(
|
|
51
|
+
--tileActionHoverBg,
|
|
52
|
+
rgba(var(--primaryErrorCTAFillRGB, 229, 28, 38), 0.2)
|
|
53
|
+
);
|
|
54
|
+
color: var(
|
|
55
|
+
--tileActionHoverColor,
|
|
56
|
+
var(--tileActionColor, var(--primaryErrorCTAFill, #d9534f))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
@@ -1,65 +1,124 @@
|
|
|
1
|
-
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@property({ type:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
changed.has('
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
import { html, LitElement, nothing, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import type { SortParam } from '@internetarchive/search-service';
|
|
5
|
+
import { TileDisplayValueProvider } from './tile-display-value-provider';
|
|
6
|
+
import type { TileModel } from '../models';
|
|
7
|
+
import { DateFormat, formatDate } from '../utils/format-date';
|
|
8
|
+
import type { TileAction } from './models';
|
|
9
|
+
|
|
10
|
+
export abstract class BaseTileComponent extends LitElement {
|
|
11
|
+
@property({ type: Object }) model?: TileModel;
|
|
12
|
+
|
|
13
|
+
/** Action buttons to display on this tile (rendered by subclasses) */
|
|
14
|
+
@property({ type: Array }) tileActions: TileAction[] = [];
|
|
15
|
+
|
|
16
|
+
@property({ type: Number }) currentWidth?: number;
|
|
17
|
+
|
|
18
|
+
@property({ type: Number }) currentHeight?: number;
|
|
19
|
+
|
|
20
|
+
@property({ type: String }) baseNavigationUrl?: string;
|
|
21
|
+
|
|
22
|
+
@property({ type: String }) baseImageUrl?: string;
|
|
23
|
+
|
|
24
|
+
@property({ type: String }) collectionPagePath?: string;
|
|
25
|
+
|
|
26
|
+
@property({ type: Object }) sortParam: SortParam | null = null;
|
|
27
|
+
|
|
28
|
+
@property({ type: Object }) defaultSortParam: SortParam | null = null;
|
|
29
|
+
|
|
30
|
+
@property({ type: String }) creatorFilter?: string;
|
|
31
|
+
|
|
32
|
+
@property({ type: Number }) mobileBreakpoint?: number;
|
|
33
|
+
|
|
34
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
35
|
+
|
|
36
|
+
@property({ type: Boolean }) suppressBlurring = false;
|
|
37
|
+
|
|
38
|
+
@property({ type: Boolean }) useLocalTime = false;
|
|
39
|
+
|
|
40
|
+
protected displayValueProvider = new TileDisplayValueProvider();
|
|
41
|
+
|
|
42
|
+
protected willUpdate(changed: PropertyValues<this>) {
|
|
43
|
+
// Ensure the TileDisplayValueProvider stays up-to-date as properties change
|
|
44
|
+
if (
|
|
45
|
+
changed.has('model') ||
|
|
46
|
+
changed.has('baseNavigationUrl') ||
|
|
47
|
+
changed.has('collectionPagePath') ||
|
|
48
|
+
changed.has('sortParam') ||
|
|
49
|
+
changed.has('defaultSortParam') ||
|
|
50
|
+
changed.has('creatorFilter')
|
|
51
|
+
) {
|
|
52
|
+
this.displayValueProvider = new TileDisplayValueProvider({
|
|
53
|
+
model: this.model,
|
|
54
|
+
baseNavigationUrl: this.baseNavigationUrl,
|
|
55
|
+
collectionPagePath: this.collectionPagePath,
|
|
56
|
+
sortParam: this.sortParam ?? this.defaultSortParam ?? undefined,
|
|
57
|
+
creatorFilter: this.creatorFilter,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The formatted date string for given date and format type, taking into
|
|
64
|
+
* account whether this tile component should be using local time or UTC.
|
|
65
|
+
*/
|
|
66
|
+
protected getFormattedDate(date?: Date, format?: DateFormat): string {
|
|
67
|
+
const { useLocalTime } = this;
|
|
68
|
+
return formatDate(date, format, { useLocalTime });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Renders the action buttons configured for this tile, or `nothing` if
|
|
73
|
+
* there are none. Optional `extraClass` is appended to the container's
|
|
74
|
+
* class list so subclasses can target their own layout tweaks.
|
|
75
|
+
*/
|
|
76
|
+
protected renderTileActions(
|
|
77
|
+
extraClass: string = '',
|
|
78
|
+
): TemplateResult | typeof nothing {
|
|
79
|
+
if (!this.tileActions.length) return nothing;
|
|
80
|
+
|
|
81
|
+
const containerClasses = classMap({
|
|
82
|
+
'tile-actions': true,
|
|
83
|
+
...(extraClass && { [extraClass]: true }),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return html`
|
|
87
|
+
<div class=${containerClasses}>
|
|
88
|
+
${this.tileActions.map(
|
|
89
|
+
action => html`
|
|
90
|
+
<button
|
|
91
|
+
class="tile-action-btn"
|
|
92
|
+
@click=${(e: Event) => this.handleTileActionClick(e, action)}
|
|
93
|
+
>
|
|
94
|
+
${action.label}
|
|
95
|
+
</button>
|
|
96
|
+
`,
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Click handler for tile action buttons. Stops propagation so the click
|
|
104
|
+
* doesn't activate a wrapping tile link, and dispatches a
|
|
105
|
+
* `tileActionClicked` event (bubbling + composed) carrying the action ID
|
|
106
|
+
* and the tile model.
|
|
107
|
+
*/
|
|
108
|
+
protected handleTileActionClick(e: Event, action: TileAction): void {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
e.stopPropagation();
|
|
111
|
+
// Pre-set the hover pane controller's clicking flag so that focus
|
|
112
|
+
// restoration after a consumer-opened modal won't trigger the hover pane.
|
|
113
|
+
this.dispatchEvent(
|
|
114
|
+
new PointerEvent('pointerdown', { bubbles: true, composed: true }),
|
|
115
|
+
);
|
|
116
|
+
this.dispatchEvent(
|
|
117
|
+
new CustomEvent('tileActionClicked', {
|
|
118
|
+
detail: { actionId: action.id, model: this.model },
|
|
119
|
+
bubbles: true,
|
|
120
|
+
composed: true,
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|