@coras-io/embed 0.10.0 → 0.12.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/CHANGELOG.md +26 -0
- package/dist/components/attraction-card/base/attraction-card.mixin.js +17 -0
- package/dist/components/attraction-card/base/attraction-card.styles.js +2 -0
- package/dist/components/attraction-card/base/attraction-card.types.d.ts +2 -0
- package/dist/components/attraction-card/long/attraction-long-card.component.js +4 -2
- package/dist/components/attraction-card/short/attraction-short-card.component.d.ts +2 -0
- package/dist/components/attraction-card/short/attraction-short-card.component.js +16 -4
- package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.component.d.ts +6 -0
- package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.component.js +25 -5
- package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.styles.js +3 -1
- package/dist/components/image/image.component.d.ts +15 -0
- package/dist/components/image/image.component.js +55 -6
- package/dist/components/text-section/text-section.component.js +1 -1
- package/dist/components/text-section/text-section.styles.js +1 -1
- package/dist/containers/footer/footer.component.d.ts +2 -0
- package/dist/containers/footer/footer.component.js +29 -22
- package/dist/containers/navbar/navbar.component.d.ts +3 -0
- package/dist/containers/navbar/navbar.component.js +33 -10
- package/dist/contexts/events.context.d.ts +8 -0
- package/dist/contexts/events.context.js +6 -0
- package/dist/core/images/srcset.d.ts +16 -0
- package/dist/core/images/srcset.js +21 -0
- package/dist/core/images/url.d.ts +1 -0
- package/dist/core/images/url.js +3 -1
- package/dist/core/utils/link-click.d.ts +8 -0
- package/dist/core/utils/link-click.js +20 -0
- package/dist/index.d.ts +1 -1
- package/dist/mixins/base.mixin.d.ts +3 -0
- package/dist/mixins/base.mixin.js +29 -1
- package/dist/sdk/mount.js +1 -0
- package/dist/sdk/types.d.ts +12 -0
- package/dist/views/chrome-only-page/chrome-only-page.component.d.ts +2 -0
- package/dist/views/details-page/details-page.component.d.ts +4 -1
- package/dist/views/details-page/details-page.component.js +27 -43
- package/dist/views/details-page/details-page.styles.js +3 -0
- package/dist/views/details-page/partials/location-highlights/location-highlights.component.d.ts +2 -1
- package/dist/views/details-page/partials/location-highlights/location-highlights.component.js +12 -5
- package/dist/views/help-page/help-page.component.d.ts +2 -0
- package/dist/views/landing-page/landing-page.component.d.ts +4 -1
- package/dist/views/landing-page/landing-page.component.js +21 -16
- package/dist/views/payment-page/payment-page.component.d.ts +2 -0
- package/dist/views/search-page/search-page.component.d.ts +5 -2
- package/dist/views/search-page/search-page.component.js +41 -48
- package/dist/views/suggestion-widget/suggestion-widget.component.d.ts +5 -2
- package/dist/views/suggestion-widget/suggestion-widget.component.js +7 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @coras-io/embed
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 488bc2b: Render the embed's internal navigation as real links for search engines. A new `hrefFor` mount option gives the SDK the host URL of a navigation intent; with it, attraction cards, breadcrumbs, the navbar logo and the footer's help links render `<a href>` links. A plain click still emits `onNavigate` without loading the page, and a modified or middle click opens the link the browser's way. Without `hrefFor` nothing changes. `coras-attraction-short-card`, `coras-attraction-long-card` and `coras-breadcrumb-item` take a new `href` attribute
|
|
8
|
+
- 7ea7055: Images are smaller to download.
|
|
9
|
+
|
|
10
|
+
- The default imgix quality is 45 instead of 85. This is the value imgix itself uses for `auto=compress`. Set `quality` on `coras-image` to ask for another value.
|
|
11
|
+
- `coras-image` has new `source-width` and `source-height` attributes (and `mobile-source-width` and `mobile-source-height` for `mobile-src`). When they are set, the generated `srcset` never asks for an image larger than the source. The details page gallery and the attraction cards set them from the API.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 9e554a8: The details page loads the images of the "Other highlights" cards lazily, so they no longer compete with the main image while the page loads. `coras-attraction-short-card` has a new `loading` attribute (`eager` by default, as before).
|
|
16
|
+
- 4eefe8b: `coras-text-section` renders its label as an `h2`. The section titles on the details page ("About", "Highlights", "Itinerary") are now real headings, so a heading inside the attraction's own text no longer skips a level.
|
|
17
|
+
|
|
18
|
+
## 0.11.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 3686a85: Load the first image of the details page at once and ahead of the other images, so the page's main image shows sooner. `coras-image` takes a new `fetch-priority` attribute for this
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 3686a85: Make breadcrumb items real items of the breadcrumb list for screen readers
|
|
27
|
+
- 3686a85: Stop the footer from jumping while the details page loads: the loading skeleton now fills the screen, as the loaded page does
|
|
28
|
+
|
|
3
29
|
## 0.10.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { html, } from "lit";
|
|
8
8
|
import { property } from "lit/decorators.js";
|
|
9
9
|
import { formatDateTimeForDisplay } from "../../../core/utils/datetime.js";
|
|
10
|
+
import { claimLinkClick } from "../../../core/utils/link-click.js";
|
|
10
11
|
import "../../category-tag/category-tag.js";
|
|
11
12
|
import "../../star-rating/star-rating.js";
|
|
12
13
|
import styles from "./attraction-card.styles.js";
|
|
@@ -33,8 +34,21 @@ export const AttractionCardMixin = (superClass) => {
|
|
|
33
34
|
this.date = "";
|
|
34
35
|
this.timezone = "";
|
|
35
36
|
this.locale = "en-GB";
|
|
37
|
+
/**
|
|
38
|
+
* The attraction page's URL. Set, the title becomes a link crawlers follow;
|
|
39
|
+
* a plain click on it still reaches the card's click listener, which
|
|
40
|
+
* navigates in the app.
|
|
41
|
+
*/
|
|
42
|
+
this.href = "";
|
|
36
43
|
}
|
|
37
44
|
static { this.styles = styles; }
|
|
45
|
+
renderTitle() {
|
|
46
|
+
return this.href
|
|
47
|
+
? html `<a class="title" href=${this.href} @click=${claimLinkClick}
|
|
48
|
+
>${this.name}</a
|
|
49
|
+
>`
|
|
50
|
+
: html `<div class="title">${this.name}</div>`;
|
|
51
|
+
}
|
|
38
52
|
renderRatingOrDate() {
|
|
39
53
|
if (this.rating > 0) {
|
|
40
54
|
return html `
|
|
@@ -99,5 +113,8 @@ export const AttractionCardMixin = (superClass) => {
|
|
|
99
113
|
__decorate([
|
|
100
114
|
property({ type: String })
|
|
101
115
|
], AttractionCardBase.prototype, "locale", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
property({ type: String })
|
|
118
|
+
], AttractionCardBase.prototype, "href", void 0);
|
|
102
119
|
return AttractionCardBase;
|
|
103
120
|
};
|
|
@@ -59,10 +59,12 @@ export default css `
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
.title {
|
|
62
|
+
display: block;
|
|
62
63
|
font-size: var(--attraction-card-title-font-size);
|
|
63
64
|
line-height: var(--attraction-card-title-line-height);
|
|
64
65
|
font-weight: var(--attraction-card-title-font-weight);
|
|
65
66
|
color: var(--attraction-card-text-color);
|
|
67
|
+
text-decoration: none;
|
|
66
68
|
text-overflow: ellipsis;
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -16,6 +16,8 @@ export type AttractionCardMixinType = {
|
|
|
16
16
|
date: string;
|
|
17
17
|
timezone: string;
|
|
18
18
|
locale: AttractionCardLocale;
|
|
19
|
+
href: string;
|
|
20
|
+
renderTitle(): TemplateResult;
|
|
19
21
|
renderRatingOrDate(): TemplateResult;
|
|
20
22
|
renderImage(): TemplateResult;
|
|
21
23
|
renderContent(): TemplateResult;
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { html, LitElement, } from "lit";
|
|
7
|
+
import { html, LitElement, nothing, } from "lit";
|
|
8
8
|
import { msg, localized } from "@lit/localize";
|
|
9
9
|
import { AttractionCardMixin } from "../base/attraction-card.mixin.js";
|
|
10
10
|
import { selectCorasImage } from "../../../core/images/selection.js";
|
|
@@ -27,6 +27,8 @@ let CorasAttractionLongCard = class CorasAttractionLongCard extends AttractionCa
|
|
|
27
27
|
<div class="image">
|
|
28
28
|
<coras-image
|
|
29
29
|
src=${selected?.primary.url ?? this.image}
|
|
30
|
+
source-width=${selected?.primary.width ?? nothing}
|
|
31
|
+
source-height=${selected?.primary.height ?? nothing}
|
|
30
32
|
alt=${this.name}
|
|
31
33
|
width=${SIZE}
|
|
32
34
|
height=${SIZE}
|
|
@@ -39,7 +41,7 @@ let CorasAttractionLongCard = class CorasAttractionLongCard extends AttractionCa
|
|
|
39
41
|
renderContent() {
|
|
40
42
|
return html `
|
|
41
43
|
<div class="content">
|
|
42
|
-
|
|
44
|
+
${this.renderTitle()}
|
|
43
45
|
<div class="category category--in-content">
|
|
44
46
|
<coras-category-tag
|
|
45
47
|
type="text"
|
|
@@ -3,6 +3,8 @@ import "../../image/image.js";
|
|
|
3
3
|
declare const CorasAttractionShortCard_base: import("../../../contexts/utils.js").Constructor<import("../base/attraction-card.types.js").AttractionCardMixinType> & typeof LitElement;
|
|
4
4
|
export declare class CorasAttractionShortCard extends CorasAttractionShortCard_base {
|
|
5
5
|
static styles: CSSResultGroup;
|
|
6
|
+
/** Set to `lazy` where the card starts below the first screen. */
|
|
7
|
+
loading: "eager" | "lazy";
|
|
6
8
|
renderImage(): TemplateResult;
|
|
7
9
|
renderContent(): TemplateResult;
|
|
8
10
|
renderDetails(): TemplateResult;
|
|
@@ -4,7 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { html, LitElement, } from "lit";
|
|
7
|
+
import { html, nothing, LitElement, } from "lit";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
8
9
|
import { msg, localized } from "@lit/localize";
|
|
9
10
|
import { AttractionCardMixin } from "../base/attraction-card.mixin.js";
|
|
10
11
|
import { selectCorasImage } from "../../../core/images/selection.js";
|
|
@@ -14,6 +15,11 @@ const DESKTOP_SIZE = 220;
|
|
|
14
15
|
const MOBILE_WIDTH = 330;
|
|
15
16
|
const MOBILE_HEIGHT = 220;
|
|
16
17
|
let CorasAttractionShortCard = class CorasAttractionShortCard extends AttractionCardMixin(LitElement) {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
/** Set to `lazy` where the card starts below the first screen. */
|
|
21
|
+
this.loading = "eager";
|
|
22
|
+
}
|
|
17
23
|
static { this.styles = [
|
|
18
24
|
super.styles,
|
|
19
25
|
styles,
|
|
@@ -32,6 +38,10 @@ let CorasAttractionShortCard = class CorasAttractionShortCard extends Attraction
|
|
|
32
38
|
<coras-image
|
|
33
39
|
src=${src}
|
|
34
40
|
mobile-src=${mobileSrc}
|
|
41
|
+
source-width=${desktop?.primary.width ?? nothing}
|
|
42
|
+
source-height=${desktop?.primary.height ?? nothing}
|
|
43
|
+
mobile-source-width=${mobile?.primary.width ?? nothing}
|
|
44
|
+
mobile-source-height=${mobile?.primary.height ?? nothing}
|
|
35
45
|
alt=${this.name}
|
|
36
46
|
width=${DESKTOP_SIZE}
|
|
37
47
|
height=${DESKTOP_SIZE}
|
|
@@ -39,7 +49,7 @@ let CorasAttractionShortCard = class CorasAttractionShortCard extends Attraction
|
|
|
39
49
|
mobile-height=${MOBILE_HEIGHT}
|
|
40
50
|
art-direction="card"
|
|
41
51
|
preset="card-grid"
|
|
42
|
-
loading
|
|
52
|
+
loading=${this.loading}
|
|
43
53
|
></coras-image>
|
|
44
54
|
</div>
|
|
45
55
|
`;
|
|
@@ -47,8 +57,7 @@ let CorasAttractionShortCard = class CorasAttractionShortCard extends Attraction
|
|
|
47
57
|
renderContent() {
|
|
48
58
|
return html `
|
|
49
59
|
<div class="content">
|
|
50
|
-
|
|
51
|
-
${this.renderRatingOrDate()}
|
|
60
|
+
${this.renderTitle()} ${this.renderRatingOrDate()}
|
|
52
61
|
</div>
|
|
53
62
|
`;
|
|
54
63
|
}
|
|
@@ -69,6 +78,9 @@ let CorasAttractionShortCard = class CorasAttractionShortCard extends Attraction
|
|
|
69
78
|
`;
|
|
70
79
|
}
|
|
71
80
|
};
|
|
81
|
+
__decorate([
|
|
82
|
+
property({ type: String })
|
|
83
|
+
], CorasAttractionShortCard.prototype, "loading", void 0);
|
|
72
84
|
CorasAttractionShortCard = __decorate([
|
|
73
85
|
localized()
|
|
74
86
|
], CorasAttractionShortCard);
|
|
@@ -2,5 +2,11 @@ import { type CSSResultGroup, LitElement } from "lit";
|
|
|
2
2
|
export declare class CorasBreadcrumbItem extends LitElement {
|
|
3
3
|
static styles: CSSResultGroup;
|
|
4
4
|
clickable: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The crumb's URL. Set, the crumb is a link crawlers follow; a plain click on
|
|
7
|
+
* it still reaches the item's click listener, which navigates in the app.
|
|
8
|
+
*/
|
|
9
|
+
href: string;
|
|
10
|
+
connectedCallback(): void;
|
|
5
11
|
render(): import("lit").TemplateResult<1>;
|
|
6
12
|
}
|
|
@@ -6,23 +6,43 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { html, LitElement } from "lit";
|
|
8
8
|
import { property } from "lit/decorators.js";
|
|
9
|
+
import { claimLinkClick } from "../../../core/utils/link-click.js";
|
|
9
10
|
import styles from "./breadcrumb-item.styles.js";
|
|
10
11
|
export class CorasBreadcrumbItem extends LitElement {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
13
14
|
this.clickable = false;
|
|
15
|
+
/**
|
|
16
|
+
* The crumb's URL. Set, the crumb is a link crawlers follow; a plain click on
|
|
17
|
+
* it still reaches the item's click listener, which navigates in the app.
|
|
18
|
+
*/
|
|
19
|
+
this.href = "";
|
|
14
20
|
}
|
|
15
21
|
static { this.styles = styles; }
|
|
22
|
+
// The list item is the host: an <li> inside this shadow root would not be a
|
|
23
|
+
// child of the list that <coras-breadcrumbs> renders.
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback();
|
|
26
|
+
if (!this.hasAttribute("role"))
|
|
27
|
+
this.setAttribute("role", "listitem");
|
|
28
|
+
}
|
|
16
29
|
render() {
|
|
17
30
|
return html `
|
|
18
|
-
<
|
|
19
|
-
${this.
|
|
20
|
-
? html `<
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
<div part="base" class="breadcrumb-item">
|
|
32
|
+
${this.href
|
|
33
|
+
? html `<a class="link" href=${this.href} @click=${claimLinkClick}
|
|
34
|
+
><slot></slot
|
|
35
|
+
></a>`
|
|
36
|
+
: this.clickable
|
|
37
|
+
? html `<button type="button" class="link"><slot></slot></button>`
|
|
38
|
+
: html `<span aria-current="page"><slot></slot></span>`}
|
|
39
|
+
</div>
|
|
23
40
|
`;
|
|
24
41
|
}
|
|
25
42
|
}
|
|
26
43
|
__decorate([
|
|
27
44
|
property({ type: Boolean })
|
|
28
45
|
], CorasBreadcrumbItem.prototype, "clickable", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
property({ type: String })
|
|
48
|
+
], CorasBreadcrumbItem.prototype, "href", void 0);
|
|
@@ -22,12 +22,14 @@ export default css `
|
|
|
22
22
|
padding: 0;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
.
|
|
25
|
+
/* Outranks the shared :host a default, so a linked crumb keeps the text colour and weight. */
|
|
26
|
+
.breadcrumb-item .link {
|
|
26
27
|
padding: 0;
|
|
27
28
|
border: 0;
|
|
28
29
|
background: none;
|
|
29
30
|
font: inherit;
|
|
30
31
|
color: inherit;
|
|
32
|
+
text-decoration: none;
|
|
31
33
|
cursor: pointer;
|
|
32
34
|
|
|
33
35
|
&:hover {
|
|
@@ -2,6 +2,7 @@ import { type CSSResultGroup, LitElement, nothing } from "lit";
|
|
|
2
2
|
import { type ImagePreset } from "../../core/images/srcset.js";
|
|
3
3
|
import { type ImgixCrop } from "../../core/images/url.js";
|
|
4
4
|
type Loading = "lazy" | "eager";
|
|
5
|
+
type FetchPriority = "high" | "low" | "auto";
|
|
5
6
|
type Decoding = "async" | "sync" | "auto";
|
|
6
7
|
type Fit = "cover" | "contain";
|
|
7
8
|
type Placeholder = "skeleton" | "color" | "none";
|
|
@@ -34,6 +35,8 @@ export declare class CorasImage extends LitElement {
|
|
|
34
35
|
height: number;
|
|
35
36
|
alt: string;
|
|
36
37
|
loading: Loading;
|
|
38
|
+
/** Set to `high` on the one image that is the page's main content. */
|
|
39
|
+
fetchPriority: FetchPriority;
|
|
37
40
|
decoding: Decoding;
|
|
38
41
|
fit: Fit;
|
|
39
42
|
placeholder: Placeholder;
|
|
@@ -44,6 +47,12 @@ export declare class CorasImage extends LitElement {
|
|
|
44
47
|
focalX: number | null;
|
|
45
48
|
focalY: number | null;
|
|
46
49
|
quality: number;
|
|
50
|
+
/**
|
|
51
|
+
* Pixel size of the image at `src`. When both are set, no generated
|
|
52
|
+
* candidate asks the CDN to enlarge the image.
|
|
53
|
+
*/
|
|
54
|
+
sourceWidth: number;
|
|
55
|
+
sourceHeight: number;
|
|
47
56
|
/** Layout preset; drives default `sizes` and srcset width caps. */
|
|
48
57
|
preset: ImagePreset | "";
|
|
49
58
|
/** Comma-separated width override; ignored when empty. */
|
|
@@ -62,12 +71,18 @@ export declare class CorasImage extends LitElement {
|
|
|
62
71
|
* `<source>` will use it instead of re-cropping `src` with imgix `ar=`.
|
|
63
72
|
*/
|
|
64
73
|
mobileSrc: string;
|
|
74
|
+
/** Pixel size of the image at `mobile-src`. */
|
|
75
|
+
mobileSourceWidth: number;
|
|
76
|
+
mobileSourceHeight: number;
|
|
65
77
|
private _loaded;
|
|
66
78
|
private _errored;
|
|
67
79
|
willUpdate(changed: Map<string, unknown>): void;
|
|
68
80
|
private get aspectRatio();
|
|
69
81
|
private get mobileAspectRatio();
|
|
70
82
|
private get widthList();
|
|
83
|
+
private get sourceSize();
|
|
84
|
+
private get mobileSourceSize();
|
|
85
|
+
private candidateWidths;
|
|
71
86
|
private buildSrc;
|
|
72
87
|
private resolveSrcset;
|
|
73
88
|
private resolveSizes;
|
|
@@ -9,8 +9,8 @@ import { property, state } from "lit/decorators.js";
|
|
|
9
9
|
import { classMap } from "lit/directives/class-map.js";
|
|
10
10
|
import { styleMap } from "lit/directives/style-map.js";
|
|
11
11
|
import { fireInternalEvent } from "../../core/events.js";
|
|
12
|
-
import { buildSizes, buildSrcset, RESPONSIVE_WIDTHS, } from "../../core/images/srcset.js";
|
|
13
|
-
import { buildImgixUrl } from "../../core/images/url.js";
|
|
12
|
+
import { buildSizes, buildSrcset, maxWidthWithinSource, RESPONSIVE_WIDTHS, widthsWithinSource, } from "../../core/images/srcset.js";
|
|
13
|
+
import { buildImgixUrl, DEFAULT_QUALITY, } from "../../core/images/url.js";
|
|
14
14
|
import styles from "./image.styles.js";
|
|
15
15
|
/**
|
|
16
16
|
* Shared image primitive.
|
|
@@ -41,6 +41,8 @@ export class CorasImage extends LitElement {
|
|
|
41
41
|
this.height = 0;
|
|
42
42
|
this.alt = "";
|
|
43
43
|
this.loading = "lazy";
|
|
44
|
+
/** Set to `high` on the one image that is the page's main content. */
|
|
45
|
+
this.fetchPriority = "auto";
|
|
44
46
|
this.decoding = "async";
|
|
45
47
|
this.fit = "cover";
|
|
46
48
|
this.placeholder = "skeleton";
|
|
@@ -50,7 +52,13 @@ export class CorasImage extends LitElement {
|
|
|
50
52
|
/** Focal point, normalised 0..1. Only used when `crop="focalpoint"`. */
|
|
51
53
|
this.focalX = null;
|
|
52
54
|
this.focalY = null;
|
|
53
|
-
this.quality =
|
|
55
|
+
this.quality = DEFAULT_QUALITY;
|
|
56
|
+
/**
|
|
57
|
+
* Pixel size of the image at `src`. When both are set, no generated
|
|
58
|
+
* candidate asks the CDN to enlarge the image.
|
|
59
|
+
*/
|
|
60
|
+
this.sourceWidth = 0;
|
|
61
|
+
this.sourceHeight = 0;
|
|
54
62
|
/** Layout preset; drives default `sizes` and srcset width caps. */
|
|
55
63
|
this.preset = "";
|
|
56
64
|
/** Comma-separated width override; ignored when empty. */
|
|
@@ -69,6 +77,9 @@ export class CorasImage extends LitElement {
|
|
|
69
77
|
* `<source>` will use it instead of re-cropping `src` with imgix `ar=`.
|
|
70
78
|
*/
|
|
71
79
|
this.mobileSrc = "";
|
|
80
|
+
/** Pixel size of the image at `mobile-src`. */
|
|
81
|
+
this.mobileSourceWidth = 0;
|
|
82
|
+
this.mobileSourceHeight = 0;
|
|
72
83
|
this._loaded = false;
|
|
73
84
|
this._errored = false;
|
|
74
85
|
this.handleLoad = () => {
|
|
@@ -105,6 +116,23 @@ export class CorasImage extends LitElement {
|
|
|
105
116
|
.map((w) => Number(w.trim()))
|
|
106
117
|
.filter((w) => Number.isFinite(w) && w > 0);
|
|
107
118
|
}
|
|
119
|
+
get sourceSize() {
|
|
120
|
+
return this.sourceWidth && this.sourceHeight
|
|
121
|
+
? { width: this.sourceWidth, height: this.sourceHeight }
|
|
122
|
+
: undefined;
|
|
123
|
+
}
|
|
124
|
+
get mobileSourceSize() {
|
|
125
|
+
if (!this.mobileSrc)
|
|
126
|
+
return this.sourceSize;
|
|
127
|
+
return this.mobileSourceWidth && this.mobileSourceHeight
|
|
128
|
+
? { width: this.mobileSourceWidth, height: this.mobileSourceHeight }
|
|
129
|
+
: undefined;
|
|
130
|
+
}
|
|
131
|
+
candidateWidths(aspectRatio, source) {
|
|
132
|
+
return source
|
|
133
|
+
? widthsWithinSource(this.widthList, source, aspectRatio)
|
|
134
|
+
: this.widthList;
|
|
135
|
+
}
|
|
108
136
|
buildSrc(targetWidth, aspectRatio) {
|
|
109
137
|
return buildImgixUrl(this.src, {
|
|
110
138
|
w: targetWidth,
|
|
@@ -124,7 +152,8 @@ export class CorasImage extends LitElement {
|
|
|
124
152
|
return this.srcset;
|
|
125
153
|
if (!this.shouldGenerateSrcset())
|
|
126
154
|
return "";
|
|
127
|
-
|
|
155
|
+
const widths = this.candidateWidths(aspectRatio, this.sourceSize);
|
|
156
|
+
return buildSrcset(this.src, widths, {
|
|
128
157
|
aspectRatio,
|
|
129
158
|
fit: "crop",
|
|
130
159
|
crop: this.crop,
|
|
@@ -174,7 +203,11 @@ export class CorasImage extends LitElement {
|
|
|
174
203
|
}
|
|
175
204
|
renderImg(srcset, sizes) {
|
|
176
205
|
const aspect = this.aspectRatio;
|
|
177
|
-
const
|
|
206
|
+
const source = this.sourceSize;
|
|
207
|
+
const preferredWidth = this.width || (this.preset ? this.widthList[0] : undefined);
|
|
208
|
+
const fallbackWidth = preferredWidth && source
|
|
209
|
+
? Math.min(preferredWidth, maxWidthWithinSource(source, aspect))
|
|
210
|
+
: preferredWidth;
|
|
178
211
|
const fallbackSrc = fallbackWidth && this.shouldGenerateSrcset()
|
|
179
212
|
? this.buildSrc(fallbackWidth, aspect)
|
|
180
213
|
: this.src;
|
|
@@ -188,6 +221,7 @@ export class CorasImage extends LitElement {
|
|
|
188
221
|
height=${this.height || nothing}
|
|
189
222
|
alt=${this.alt}
|
|
190
223
|
loading=${this.loading}
|
|
224
|
+
fetchpriority=${this.fetchPriority}
|
|
191
225
|
decoding=${this.decoding}
|
|
192
226
|
@load=${this.handleLoad}
|
|
193
227
|
@error=${this.handleError}
|
|
@@ -197,7 +231,7 @@ export class CorasImage extends LitElement {
|
|
|
197
231
|
const mobileAspect = this.mobileAspectRatio;
|
|
198
232
|
const mobileBase = this.mobileSrc || this.src;
|
|
199
233
|
const mobileSrcset = mobileAspect
|
|
200
|
-
? buildSrcset(mobileBase, this.
|
|
234
|
+
? buildSrcset(mobileBase, this.candidateWidths(mobileAspect, this.mobileSourceSize), {
|
|
201
235
|
aspectRatio: mobileAspect,
|
|
202
236
|
fit: "crop",
|
|
203
237
|
crop: this.crop,
|
|
@@ -252,6 +286,9 @@ __decorate([
|
|
|
252
286
|
__decorate([
|
|
253
287
|
property({ type: String })
|
|
254
288
|
], CorasImage.prototype, "loading", void 0);
|
|
289
|
+
__decorate([
|
|
290
|
+
property({ type: String, attribute: "fetch-priority" })
|
|
291
|
+
], CorasImage.prototype, "fetchPriority", void 0);
|
|
255
292
|
__decorate([
|
|
256
293
|
property({ type: String })
|
|
257
294
|
], CorasImage.prototype, "decoding", void 0);
|
|
@@ -276,6 +313,12 @@ __decorate([
|
|
|
276
313
|
__decorate([
|
|
277
314
|
property({ type: Number })
|
|
278
315
|
], CorasImage.prototype, "quality", void 0);
|
|
316
|
+
__decorate([
|
|
317
|
+
property({ type: Number, attribute: "source-width" })
|
|
318
|
+
], CorasImage.prototype, "sourceWidth", void 0);
|
|
319
|
+
__decorate([
|
|
320
|
+
property({ type: Number, attribute: "source-height" })
|
|
321
|
+
], CorasImage.prototype, "sourceHeight", void 0);
|
|
279
322
|
__decorate([
|
|
280
323
|
property({ type: String })
|
|
281
324
|
], CorasImage.prototype, "preset", void 0);
|
|
@@ -294,6 +337,12 @@ __decorate([
|
|
|
294
337
|
__decorate([
|
|
295
338
|
property({ type: String, attribute: "mobile-src" })
|
|
296
339
|
], CorasImage.prototype, "mobileSrc", void 0);
|
|
340
|
+
__decorate([
|
|
341
|
+
property({ type: Number, attribute: "mobile-source-width" })
|
|
342
|
+
], CorasImage.prototype, "mobileSourceWidth", void 0);
|
|
343
|
+
__decorate([
|
|
344
|
+
property({ type: Number, attribute: "mobile-source-height" })
|
|
345
|
+
], CorasImage.prototype, "mobileSourceHeight", void 0);
|
|
297
346
|
__decorate([
|
|
298
347
|
state()
|
|
299
348
|
], CorasImage.prototype, "_loaded", void 0);
|
|
@@ -17,7 +17,7 @@ export class CorasTextSection extends LitElement {
|
|
|
17
17
|
return html `
|
|
18
18
|
<div part="base">
|
|
19
19
|
${this.label
|
|
20
|
-
? html `<
|
|
20
|
+
? html `<h2 class="label" part="label">${this.label}</h2>`
|
|
21
21
|
: ""}
|
|
22
22
|
<div class="content" part="content">
|
|
23
23
|
<slot></slot>
|
|
@@ -4,6 +4,8 @@ import "../../components/footer-menu/footer-menu-item/footer-menu-item.js";
|
|
|
4
4
|
export declare class CorasFooter extends LitElement {
|
|
5
5
|
static styles: CSSResultGroup;
|
|
6
6
|
private _pageDispatch;
|
|
7
|
+
private _pageHref?;
|
|
8
|
+
private renderHelpItem;
|
|
7
9
|
private readonly colorScheme;
|
|
8
10
|
willUpdate(): void;
|
|
9
11
|
render(): import("lit").TemplateResult<1>;
|
|
@@ -5,19 +5,37 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { LitElement, html } from "lit";
|
|
8
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
8
9
|
import { localized, msg } from "@lit/localize";
|
|
9
10
|
import { consume } from "@lit/context";
|
|
10
11
|
import "../../components/footer-menu/footer-menu.js";
|
|
11
12
|
import "../../components/footer-menu/footer-menu-item/footer-menu-item.js";
|
|
12
13
|
import styles from "./footer.styles.js";
|
|
13
14
|
import { ColorSchemeController } from "../../core/color-scheme.js";
|
|
14
|
-
import { pageDispatchContext, } from "../../contexts/events.context.js";
|
|
15
|
+
import { pageDispatchContext, pageHrefContext, } from "../../contexts/events.context.js";
|
|
16
|
+
import { claimLinkClick } from "../../core/utils/link-click.js";
|
|
15
17
|
let CorasFooter = class CorasFooter extends LitElement {
|
|
16
18
|
constructor() {
|
|
17
19
|
super(...arguments);
|
|
18
20
|
this.colorScheme = new ColorSchemeController(this);
|
|
19
21
|
}
|
|
20
22
|
static { this.styles = styles; }
|
|
23
|
+
// A help link the host can route: a real link when the host builds URLs,
|
|
24
|
+
// and in-app navigation on a plain click either way.
|
|
25
|
+
renderHelpItem(label, target, slot) {
|
|
26
|
+
return html `
|
|
27
|
+
<coras-footer-menu-item
|
|
28
|
+
slot=${ifDefined(slot)}
|
|
29
|
+
href=${ifDefined(this._pageHref?.(target))}
|
|
30
|
+
@click=${(event) => {
|
|
31
|
+
if (claimLinkClick(event))
|
|
32
|
+
this._pageDispatch?.(target);
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
${label}
|
|
36
|
+
</coras-footer-menu-item>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
21
39
|
willUpdate() {
|
|
22
40
|
this.dataset.colorScheme = this.colorScheme.scheme;
|
|
23
41
|
}
|
|
@@ -25,27 +43,18 @@ let CorasFooter = class CorasFooter extends LitElement {
|
|
|
25
43
|
return html `
|
|
26
44
|
<div class="container">
|
|
27
45
|
<coras-footer-menu>
|
|
28
|
-
|
|
29
|
-
@click=${() => this._pageDispatch?.({
|
|
46
|
+
${this.renderHelpItem(msg("Terms & Conditions"), {
|
|
30
47
|
page: "help",
|
|
31
48
|
content: "terms-and-conditions",
|
|
32
49
|
})}
|
|
33
|
-
|
|
34
|
-
${msg("Terms & Conditions")}
|
|
35
|
-
</coras-footer-menu-item>
|
|
36
|
-
<coras-footer-menu-item
|
|
37
|
-
@click=${() => this._pageDispatch?.({
|
|
50
|
+
${this.renderHelpItem(msg("Privacy"), {
|
|
38
51
|
page: "help",
|
|
39
52
|
content: "privacy-policy",
|
|
40
53
|
})}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@click=${() => this._pageDispatch?.({ page: "help", content: "cookies" })}
|
|
46
|
-
>
|
|
47
|
-
${msg("Cookies")}
|
|
48
|
-
</coras-footer-menu-item>
|
|
54
|
+
${this.renderHelpItem(msg("Cookies"), {
|
|
55
|
+
page: "help",
|
|
56
|
+
content: "cookies",
|
|
57
|
+
})}
|
|
49
58
|
<coras-footer-menu-item
|
|
50
59
|
href="https://coras.io/contact"
|
|
51
60
|
target="_blank"
|
|
@@ -53,12 +62,7 @@ let CorasFooter = class CorasFooter extends LitElement {
|
|
|
53
62
|
>
|
|
54
63
|
${msg("Partner with Coras")}
|
|
55
64
|
</coras-footer-menu-item>
|
|
56
|
-
|
|
57
|
-
slot="right"
|
|
58
|
-
@click=${() => this._pageDispatch?.({ page: "help" })}
|
|
59
|
-
>
|
|
60
|
-
${msg("Help Centre")}
|
|
61
|
-
</coras-footer-menu-item>
|
|
65
|
+
${this.renderHelpItem(msg("Help Centre"), { page: "help" }, "right")}
|
|
62
66
|
</coras-footer-menu>
|
|
63
67
|
</div>
|
|
64
68
|
`;
|
|
@@ -67,6 +71,9 @@ let CorasFooter = class CorasFooter extends LitElement {
|
|
|
67
71
|
__decorate([
|
|
68
72
|
consume({ context: pageDispatchContext })
|
|
69
73
|
], CorasFooter.prototype, "_pageDispatch", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
consume({ context: pageHrefContext })
|
|
76
|
+
], CorasFooter.prototype, "_pageHref", void 0);
|
|
70
77
|
CorasFooter = __decorate([
|
|
71
78
|
localized()
|
|
72
79
|
], CorasFooter);
|
|
@@ -51,6 +51,7 @@ export declare class CorasNavBar extends CorasNavBar_base implements SearchMixin
|
|
|
51
51
|
private isBasketMobileOpen;
|
|
52
52
|
currentPage: PageName;
|
|
53
53
|
dispatchPageUpdate: (params: PageDispatchInput) => void;
|
|
54
|
+
private _pageHref?;
|
|
54
55
|
private get shouldRenderMobileMenu();
|
|
55
56
|
basket?: BasketContext;
|
|
56
57
|
private isMobile;
|
|
@@ -103,7 +104,9 @@ export declare class CorasNavBar extends CorasNavBar_base implements SearchMixin
|
|
|
103
104
|
private renderMobileMenuIcon;
|
|
104
105
|
private renderReturnButton;
|
|
105
106
|
private renderMobileMenuDrawer;
|
|
107
|
+
private get homeTarget();
|
|
106
108
|
private handleLogoClick;
|
|
109
|
+
private handleHomeLinkClick;
|
|
107
110
|
private renderBrand;
|
|
108
111
|
private renderBrandHome;
|
|
109
112
|
private renderSearchOnlyHeader;
|