@coras-io/embed 0.11.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 +15 -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 +5 -0
- package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.component.js +16 -3
- package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.styles.js +3 -1
- package/dist/components/image/image.component.d.ts +12 -0
- package/dist/components/image/image.component.js +49 -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 +22 -41
- 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,20 @@
|
|
|
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
|
+
|
|
3
18
|
## 0.11.0
|
|
4
19
|
|
|
5
20
|
### 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,6 +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;
|
|
5
10
|
connectedCallback(): void;
|
|
6
11
|
render(): import("lit").TemplateResult<1>;
|
|
7
12
|
}
|
|
@@ -6,11 +6,17 @@ 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; }
|
|
16
22
|
// The list item is the host: an <li> inside this shadow root would not be a
|
|
@@ -23,9 +29,13 @@ export class CorasBreadcrumbItem extends LitElement {
|
|
|
23
29
|
render() {
|
|
24
30
|
return html `
|
|
25
31
|
<div part="base" class="breadcrumb-item">
|
|
26
|
-
${this.
|
|
27
|
-
? html `<
|
|
28
|
-
|
|
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>`}
|
|
29
39
|
</div>
|
|
30
40
|
`;
|
|
31
41
|
}
|
|
@@ -33,3 +43,6 @@ export class CorasBreadcrumbItem extends LitElement {
|
|
|
33
43
|
__decorate([
|
|
34
44
|
property({ type: Boolean })
|
|
35
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 {
|
|
@@ -47,6 +47,12 @@ export declare class CorasImage extends LitElement {
|
|
|
47
47
|
focalX: number | null;
|
|
48
48
|
focalY: number | null;
|
|
49
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;
|
|
50
56
|
/** Layout preset; drives default `sizes` and srcset width caps. */
|
|
51
57
|
preset: ImagePreset | "";
|
|
52
58
|
/** Comma-separated width override; ignored when empty. */
|
|
@@ -65,12 +71,18 @@ export declare class CorasImage extends LitElement {
|
|
|
65
71
|
* `<source>` will use it instead of re-cropping `src` with imgix `ar=`.
|
|
66
72
|
*/
|
|
67
73
|
mobileSrc: string;
|
|
74
|
+
/** Pixel size of the image at `mobile-src`. */
|
|
75
|
+
mobileSourceWidth: number;
|
|
76
|
+
mobileSourceHeight: number;
|
|
68
77
|
private _loaded;
|
|
69
78
|
private _errored;
|
|
70
79
|
willUpdate(changed: Map<string, unknown>): void;
|
|
71
80
|
private get aspectRatio();
|
|
72
81
|
private get mobileAspectRatio();
|
|
73
82
|
private get widthList();
|
|
83
|
+
private get sourceSize();
|
|
84
|
+
private get mobileSourceSize();
|
|
85
|
+
private candidateWidths;
|
|
74
86
|
private buildSrc;
|
|
75
87
|
private resolveSrcset;
|
|
76
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.
|
|
@@ -52,7 +52,13 @@ export class CorasImage extends LitElement {
|
|
|
52
52
|
/** Focal point, normalised 0..1. Only used when `crop="focalpoint"`. */
|
|
53
53
|
this.focalX = null;
|
|
54
54
|
this.focalY = null;
|
|
55
|
-
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;
|
|
56
62
|
/** Layout preset; drives default `sizes` and srcset width caps. */
|
|
57
63
|
this.preset = "";
|
|
58
64
|
/** Comma-separated width override; ignored when empty. */
|
|
@@ -71,6 +77,9 @@ export class CorasImage extends LitElement {
|
|
|
71
77
|
* `<source>` will use it instead of re-cropping `src` with imgix `ar=`.
|
|
72
78
|
*/
|
|
73
79
|
this.mobileSrc = "";
|
|
80
|
+
/** Pixel size of the image at `mobile-src`. */
|
|
81
|
+
this.mobileSourceWidth = 0;
|
|
82
|
+
this.mobileSourceHeight = 0;
|
|
74
83
|
this._loaded = false;
|
|
75
84
|
this._errored = false;
|
|
76
85
|
this.handleLoad = () => {
|
|
@@ -107,6 +116,23 @@ export class CorasImage extends LitElement {
|
|
|
107
116
|
.map((w) => Number(w.trim()))
|
|
108
117
|
.filter((w) => Number.isFinite(w) && w > 0);
|
|
109
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
|
+
}
|
|
110
136
|
buildSrc(targetWidth, aspectRatio) {
|
|
111
137
|
return buildImgixUrl(this.src, {
|
|
112
138
|
w: targetWidth,
|
|
@@ -126,7 +152,8 @@ export class CorasImage extends LitElement {
|
|
|
126
152
|
return this.srcset;
|
|
127
153
|
if (!this.shouldGenerateSrcset())
|
|
128
154
|
return "";
|
|
129
|
-
|
|
155
|
+
const widths = this.candidateWidths(aspectRatio, this.sourceSize);
|
|
156
|
+
return buildSrcset(this.src, widths, {
|
|
130
157
|
aspectRatio,
|
|
131
158
|
fit: "crop",
|
|
132
159
|
crop: this.crop,
|
|
@@ -176,7 +203,11 @@ export class CorasImage extends LitElement {
|
|
|
176
203
|
}
|
|
177
204
|
renderImg(srcset, sizes) {
|
|
178
205
|
const aspect = this.aspectRatio;
|
|
179
|
-
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;
|
|
180
211
|
const fallbackSrc = fallbackWidth && this.shouldGenerateSrcset()
|
|
181
212
|
? this.buildSrc(fallbackWidth, aspect)
|
|
182
213
|
: this.src;
|
|
@@ -200,7 +231,7 @@ export class CorasImage extends LitElement {
|
|
|
200
231
|
const mobileAspect = this.mobileAspectRatio;
|
|
201
232
|
const mobileBase = this.mobileSrc || this.src;
|
|
202
233
|
const mobileSrcset = mobileAspect
|
|
203
|
-
? buildSrcset(mobileBase, this.
|
|
234
|
+
? buildSrcset(mobileBase, this.candidateWidths(mobileAspect, this.mobileSourceSize), {
|
|
204
235
|
aspectRatio: mobileAspect,
|
|
205
236
|
fit: "crop",
|
|
206
237
|
crop: this.crop,
|
|
@@ -282,6 +313,12 @@ __decorate([
|
|
|
282
313
|
__decorate([
|
|
283
314
|
property({ type: Number })
|
|
284
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);
|
|
285
322
|
__decorate([
|
|
286
323
|
property({ type: String })
|
|
287
324
|
], CorasImage.prototype, "preset", void 0);
|
|
@@ -300,6 +337,12 @@ __decorate([
|
|
|
300
337
|
__decorate([
|
|
301
338
|
property({ type: String, attribute: "mobile-src" })
|
|
302
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);
|
|
303
346
|
__decorate([
|
|
304
347
|
state()
|
|
305
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;
|
|
@@ -32,7 +32,8 @@ import { renderSearchResultsOption } from "../../components/search-results-item/
|
|
|
32
32
|
import { SearchMixin } from "../../mixins/search-mixin/search-mixin.js";
|
|
33
33
|
import { addRecentlySelectedSearches, DrawerSubmenu, getLocaleLabel, getRecentlySelectedSearches, searchResultTypeToLocationPageMap, } from "./navbar.utils.js";
|
|
34
34
|
import styles from "./navbar.styles.js";
|
|
35
|
-
import { pageDispatchContext, } from "../../contexts/events.context.js";
|
|
35
|
+
import { pageDispatchContext, pageHrefContext, } from "../../contexts/events.context.js";
|
|
36
|
+
import { claimLinkClick } from "../../core/utils/link-click.js";
|
|
36
37
|
import { assetsURLContext, currenciesContext, currencyContext, distributorIdContext, localeContext, localesContext, } from "../../contexts/properties.context.js";
|
|
37
38
|
import { currentPageContext } from "../../contexts/current-page.context.js";
|
|
38
39
|
import { clientContext } from "../../contexts/client.context.js";
|
|
@@ -96,11 +97,11 @@ let CorasNavBar = class CorasNavBar extends SearchMixin(LitElement) {
|
|
|
96
97
|
// The logo is a home link. The embed owns no router, so it dispatches a
|
|
97
98
|
// `landing` navigation the host applies (a no-op when already on landing).
|
|
98
99
|
this.handleLogoClick = () => {
|
|
99
|
-
this.dispatchPageUpdate(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
this.dispatchPageUpdate(this.homeTarget);
|
|
101
|
+
};
|
|
102
|
+
this.handleHomeLinkClick = (event) => {
|
|
103
|
+
if (claimLinkClick(event))
|
|
104
|
+
this.handleLogoClick();
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
107
|
static { this.styles = styles; }
|
|
@@ -649,6 +650,13 @@ let CorasNavBar = class CorasNavBar extends SearchMixin(LitElement) {
|
|
|
649
650
|
</coras-drawer>
|
|
650
651
|
`;
|
|
651
652
|
}
|
|
653
|
+
get homeTarget() {
|
|
654
|
+
return {
|
|
655
|
+
page: "landing",
|
|
656
|
+
locale: this.locale,
|
|
657
|
+
currency: this.currency,
|
|
658
|
+
};
|
|
659
|
+
}
|
|
652
660
|
// The host's `brand` slot wins and keeps its own semantics: slotted content is
|
|
653
661
|
// projected as-is, never wrapped, so a slotted link/button is not nested inside
|
|
654
662
|
// our button (invalid interactive-in-interactive) and owns its own navigation.
|
|
@@ -666,8 +674,9 @@ let CorasNavBar = class CorasNavBar extends SearchMixin(LitElement) {
|
|
|
666
674
|
}
|
|
667
675
|
// A distributor with its own website links the logo straight there, the way its
|
|
668
676
|
// main site does, and a real anchor keeps that a link (middle-click, new tab,
|
|
669
|
-
// status bar). Without one
|
|
670
|
-
//
|
|
677
|
+
// status bar). Without one the logo links to the host's landing URL when the
|
|
678
|
+
// host gave the mount an `hrefFor`, routed in the app on a plain click, and
|
|
679
|
+
// otherwise stays a button dispatching the `landing` navigation.
|
|
671
680
|
renderBrandHome(logo) {
|
|
672
681
|
const image = html `<img
|
|
673
682
|
class="brand-logo"
|
|
@@ -677,12 +686,23 @@ let CorasNavBar = class CorasNavBar extends SearchMixin(LitElement) {
|
|
|
677
686
|
/>`;
|
|
678
687
|
// The URL comes from host config, so it is gated here rather than trusted.
|
|
679
688
|
const href = safeUrl(this.logoHref);
|
|
680
|
-
|
|
689
|
+
if (href) {
|
|
690
|
+
return html `<a
|
|
691
|
+
class="brand-button"
|
|
692
|
+
part="brand-button"
|
|
693
|
+
href=${href}
|
|
694
|
+
aria-label=${msg("Go to the home page")}
|
|
695
|
+
>${image}</a
|
|
696
|
+
>`;
|
|
697
|
+
}
|
|
698
|
+
const homeHref = this._pageHref?.(this.homeTarget);
|
|
699
|
+
return homeHref
|
|
681
700
|
? html `<a
|
|
682
701
|
class="brand-button"
|
|
683
702
|
part="brand-button"
|
|
684
|
-
href=${
|
|
703
|
+
href=${homeHref}
|
|
685
704
|
aria-label=${msg("Go to the home page")}
|
|
705
|
+
@click=${this.handleHomeLinkClick}
|
|
686
706
|
>${image}</a
|
|
687
707
|
>`
|
|
688
708
|
: html `<button
|
|
@@ -819,6 +839,9 @@ __decorate([
|
|
|
819
839
|
__decorate([
|
|
820
840
|
consume({ context: pageDispatchContext })
|
|
821
841
|
], CorasNavBar.prototype, "dispatchPageUpdate", void 0);
|
|
842
|
+
__decorate([
|
|
843
|
+
consume({ context: pageHrefContext })
|
|
844
|
+
], CorasNavBar.prototype, "_pageHref", void 0);
|
|
822
845
|
__decorate([
|
|
823
846
|
consume({ context: basketContext, subscribe: true })
|
|
824
847
|
], CorasNavBar.prototype, "basket", void 0);
|
|
@@ -30,4 +30,12 @@ export type PageDispatchPayload = BasePageState & AllPageSpecificFields;
|
|
|
30
30
|
export declare const pageDispatchContext: {
|
|
31
31
|
__context__: (params: PageDispatchInput) => void;
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* The host URL of the state a `dispatchPageUpdate` call would move to, for
|
|
35
|
+
* rendering that control as a link. `undefined` when the host gave the mount
|
|
36
|
+
* no `hrefFor`, so the control stays a button.
|
|
37
|
+
*/
|
|
38
|
+
export declare const pageHrefContext: {
|
|
39
|
+
__context__: (params: PageDispatchInput) => string | undefined;
|
|
40
|
+
};
|
|
33
41
|
export {};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { createContext } from "@lit/context";
|
|
2
2
|
export const pageDispatchContext = createContext("coras-page-dispatch");
|
|
3
|
+
/**
|
|
4
|
+
* The host URL of the state a `dispatchPageUpdate` call would move to, for
|
|
5
|
+
* rendering that control as a link. `undefined` when the host gave the mount
|
|
6
|
+
* no `hrefFor`, so the control stays a button.
|
|
7
|
+
*/
|
|
8
|
+
export const pageHrefContext = createContext("coras-page-href");
|