@coras-io/embed 0.11.0 → 0.13.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 +21 -0
- package/README.md +18 -8
- package/dist/components/attraction-card/base/attraction-card.mixin.js +17 -0
- package/dist/components/attraction-card/base/attraction-card.styles.js +10 -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/button/button.component.d.ts +6 -0
- package/dist/components/button/button.component.js +31 -8
- package/dist/components/button/button.styles.js +8 -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/sdk/url.d.ts +44 -2
- package/dist/sdk/url.js +54 -6
- 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-categories/location-categories.component.d.ts +2 -1
- package/dist/views/details-page/partials/location-categories/location-categories.component.js +18 -5
- 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/partials/confirmation/confirmation.component.d.ts +2 -0
- package/dist/views/payment-page/partials/confirmation/confirmation.component.js +26 -6
- package/dist/views/payment-page/partials/confirmation/confirmation.styles.js +4 -0
- 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 +6 -3
- package/dist/views/suggestion-widget/suggestion-widget.component.js +18 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @coras-io/embed
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b792a0b: Finish the embed's crawlable navigation. With an `href`, `coras-attraction-short-card` and `coras-attraction-long-card` stretch the title link's hit area over the whole card, so a click on the photo or the card body behaves like a click on the title; the title text stays the only link. With `hrefFor`, the details page's category "Explore" buttons, the suggestion widget's "See all activities" button and the order confirmation's Help Centre link render as real links too, and `coras-button` takes an `href` attribute that renders it as a link with the button's look. New in `@coras-io/embed/url`: `createCorasRouting({ url, navigate, replace })` returns the `hrefFor`, `onNavigate` and `onStateChange` mount options from one URL helper or strategy, so a host wires its router in one call and its links always match its routes; and two opt-in URL strategy options, `localeCase: "lower"` to write a lower-case locale segment and `defaultCurrency` to leave a default currency out of built URLs. The default strategy is unchanged. For every link a plain click still emits `onNavigate` without a page load, and a modified or middle click opens the page in a new tab. Without `href` or `hrefFor` nothing changes.
|
|
8
|
+
|
|
9
|
+
## 0.12.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 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
|
|
14
|
+
- 7ea7055: Images are smaller to download.
|
|
15
|
+
|
|
16
|
+
- 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.
|
|
17
|
+
- `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.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 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).
|
|
22
|
+
- 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.
|
|
23
|
+
|
|
3
24
|
## 0.11.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -31,17 +31,27 @@ copy instead of two; `@coinbase/cdp-core` is the only exact pin.
|
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
import { mount } from "@coras-io/embed";
|
|
34
|
+
import { createCorasRouting, createCorasUrlState } from "@coras-io/embed/url";
|
|
35
|
+
|
|
36
|
+
const coras = createCorasUrlState({
|
|
37
|
+
localeCase: "lower",
|
|
38
|
+
currencyInPath: false,
|
|
39
|
+
defaultCurrency: "EUR",
|
|
40
|
+
});
|
|
34
41
|
|
|
35
42
|
const app = mount({
|
|
36
43
|
container,
|
|
37
44
|
page: "landing",
|
|
38
45
|
config: { apiUrl, distributorId, assetsUrl, locale, currency },
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
...createCorasRouting({
|
|
47
|
+
url: coras,
|
|
48
|
+
navigate: (href) => router.push(href),
|
|
49
|
+
replace: (href) => router.replace(href),
|
|
50
|
+
}),
|
|
41
51
|
});
|
|
42
52
|
```
|
|
43
53
|
|
|
44
|
-
`mount()` owns the container, chrome (navbar and footer), page swapping, and the host-routing contract (`coras:navigate
|
|
54
|
+
`mount()` owns the container, chrome (navbar and footer), page swapping, and the host-routing contract (`coras:navigate`, `coras:state-change` and the `hrefFor` option that renders the embed's navigation as real links). `createCorasRouting` returns those three options from one URL helper; the strategy above is the shape the Coras sites use, and the SDK default (`/en-IE/EUR/...`) stays available. It returns an app handle with `ready`, `state`, `update()`, `navigate()`, `prefetch()`, and `unmount()`.
|
|
45
55
|
|
|
46
56
|
Page custom elements are internal. You never import them directly.
|
|
47
57
|
|
|
@@ -56,10 +66,10 @@ For the full guide and event reference, see the Coras docs at https://docs.coras
|
|
|
56
66
|
|
|
57
67
|
## Other entry points
|
|
58
68
|
|
|
59
|
-
| Entry point | Purpose
|
|
60
|
-
| ------------------------- |
|
|
61
|
-
| `@coras-io/embed/url` | URL and state helpers: `parseCorasUrl`, `buildCorasUrl`, `createCorasUrlState`. |
|
|
62
|
-
| `@coras-io/embed/errors` | Typed error classes for host integration code.
|
|
63
|
-
| `@coras-io/embed/helpers` | Locale and currency helpers: `getLocale`, `getCurrency`.
|
|
69
|
+
| Entry point | Purpose |
|
|
70
|
+
| ------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
71
|
+
| `@coras-io/embed/url` | URL and state helpers: `parseCorasUrl`, `buildCorasUrl`, `createCorasUrlState`, `createCorasRouting`. |
|
|
72
|
+
| `@coras-io/embed/errors` | Typed error classes for host integration code. |
|
|
73
|
+
| `@coras-io/embed/helpers` | Locale and currency helpers: `getLocale`, `getCurrency`. |
|
|
64
74
|
|
|
65
75
|
Public TypeScript types come from the package root alongside `mount()`.
|
|
@@ -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
|
+
* whose hit area covers the whole card; a plain click anywhere on the card
|
|
40
|
+
* still reaches the card's click listener, which 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
|
};
|
|
@@ -44,6 +44,7 @@ export default css `
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
.wrapper {
|
|
47
|
+
position: relative;
|
|
47
48
|
container-type: inline-size;
|
|
48
49
|
height: 100%;
|
|
49
50
|
width: 100%;
|
|
@@ -59,13 +60,22 @@ export default css `
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
.title {
|
|
63
|
+
display: block;
|
|
62
64
|
font-size: var(--attraction-card-title-font-size);
|
|
63
65
|
line-height: var(--attraction-card-title-line-height);
|
|
64
66
|
font-weight: var(--attraction-card-title-font-weight);
|
|
65
67
|
color: var(--attraction-card-text-color);
|
|
68
|
+
text-decoration: none;
|
|
66
69
|
text-overflow: ellipsis;
|
|
67
70
|
}
|
|
68
71
|
|
|
72
|
+
/* The link's hit area is the whole card; the text stays the only link. */
|
|
73
|
+
a.title::after {
|
|
74
|
+
content: "";
|
|
75
|
+
position: absolute;
|
|
76
|
+
inset: 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
.date {
|
|
70
80
|
font-size: var(--attraction-card-details-font-size);
|
|
71
81
|
line-height: var(--attraction-card-details-line-height);
|
|
@@ -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 {
|
|
@@ -18,11 +18,17 @@ export declare class CorasButton extends LitElement {
|
|
|
18
18
|
clickable: boolean;
|
|
19
19
|
error: boolean;
|
|
20
20
|
loading: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Renders the button as a link to this URL, with the button's look. A
|
|
23
|
+
* disabled or loading button stays a button, since a link cannot be disabled.
|
|
24
|
+
*/
|
|
25
|
+
href: string;
|
|
21
26
|
constructor();
|
|
22
27
|
connectedCallback(): void;
|
|
23
28
|
disconnectedCallback(): void;
|
|
24
29
|
click(): void;
|
|
25
30
|
private handleHostClick;
|
|
26
31
|
private computeClasses;
|
|
32
|
+
private renderContent;
|
|
27
33
|
render(): import("lit").TemplateResult<1>;
|
|
28
34
|
}
|
|
@@ -27,6 +27,11 @@ export class CorasButton extends LitElement {
|
|
|
27
27
|
this.clickable = true;
|
|
28
28
|
this.error = false;
|
|
29
29
|
this.loading = false;
|
|
30
|
+
/**
|
|
31
|
+
* Renders the button as a link to this URL, with the button's look. A
|
|
32
|
+
* disabled or loading button stays a button, since a link cannot be disabled.
|
|
33
|
+
*/
|
|
34
|
+
this.href = "";
|
|
30
35
|
this.internals = this.attachInternals();
|
|
31
36
|
}
|
|
32
37
|
connectedCallback() {
|
|
@@ -90,26 +95,41 @@ export class CorasButton extends LitElement {
|
|
|
90
95
|
loading: this.loading,
|
|
91
96
|
};
|
|
92
97
|
}
|
|
98
|
+
renderContent() {
|
|
99
|
+
return when(this.loading, () => html `<coras-loading-spinner size="small"></coras-loading-spinner>`, () => html `
|
|
100
|
+
<slot name="prefix" part="prefix"></slot>
|
|
101
|
+
<slot part="label"></slot>
|
|
102
|
+
<slot name="suffix" part="suffix"></slot>
|
|
103
|
+
`);
|
|
104
|
+
}
|
|
93
105
|
render() {
|
|
106
|
+
const inactive = this.disabled || this.loading;
|
|
107
|
+
if (this.href && !inactive) {
|
|
108
|
+
return html `
|
|
109
|
+
<a
|
|
110
|
+
part="base"
|
|
111
|
+
href=${this.href}
|
|
112
|
+
class="${classMap(this.computeClasses())}"
|
|
113
|
+
>
|
|
114
|
+
${this.renderContent()}
|
|
115
|
+
</a>
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
94
118
|
return html `
|
|
95
119
|
<button
|
|
96
120
|
part="base"
|
|
97
121
|
type="${this.type}"
|
|
98
|
-
?disabled="${
|
|
99
|
-
aria-disabled="${
|
|
122
|
+
?disabled="${inactive}"
|
|
123
|
+
aria-disabled="${inactive ? "true" : "false"}"
|
|
100
124
|
class="${classMap(this.computeClasses())}"
|
|
101
125
|
>
|
|
102
|
-
${
|
|
103
|
-
<slot name="prefix" part="prefix"></slot>
|
|
104
|
-
<slot part="label"></slot>
|
|
105
|
-
<slot name="suffix" part="suffix"></slot>
|
|
106
|
-
`)}
|
|
126
|
+
${this.renderContent()}
|
|
107
127
|
</button>
|
|
108
128
|
`;
|
|
109
129
|
}
|
|
110
130
|
}
|
|
111
131
|
__decorate([
|
|
112
|
-
query("button")
|
|
132
|
+
query("button, a")
|
|
113
133
|
], CorasButton.prototype, "button", void 0);
|
|
114
134
|
__decorate([
|
|
115
135
|
property({ type: String })
|
|
@@ -147,3 +167,6 @@ __decorate([
|
|
|
147
167
|
__decorate([
|
|
148
168
|
property({ type: Boolean })
|
|
149
169
|
], CorasButton.prototype, "loading", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
property({ type: String })
|
|
172
|
+
], CorasButton.prototype, "href", void 0);
|
|
@@ -105,7 +105,14 @@ export default css `
|
|
|
105
105
|
pointer-events: none;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
button
|
|
108
|
+
/* Outranks the shared :host a default, so a linked button keeps the button's look. */
|
|
109
|
+
:host a {
|
|
110
|
+
font-weight: var(--button-font-weight);
|
|
111
|
+
text-decoration: none;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
button,
|
|
115
|
+
a {
|
|
109
116
|
align-items: center;
|
|
110
117
|
background-color: transparent;
|
|
111
118
|
border-radius: var(--button-border-radius);
|
|
@@ -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>;
|