@coras-io/embed 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -32,6 +32,7 @@ export declare class CorasNavBar extends CorasNavBar_base implements SearchMixin
|
|
|
32
32
|
logo?: string;
|
|
33
33
|
logoDark?: string;
|
|
34
34
|
navbarLogo?: string;
|
|
35
|
+
logoHref?: string;
|
|
35
36
|
private readonly colorScheme;
|
|
36
37
|
locale: SupportedLocales;
|
|
37
38
|
locales: SupportedLocales[];
|
|
@@ -99,6 +100,7 @@ export declare class CorasNavBar extends CorasNavBar_base implements SearchMixin
|
|
|
99
100
|
private renderMobileMenuDrawer;
|
|
100
101
|
private handleLogoClick;
|
|
101
102
|
private renderBrand;
|
|
103
|
+
private renderBrandHome;
|
|
102
104
|
private renderSearchOnlyHeader;
|
|
103
105
|
private renderFullHeader;
|
|
104
106
|
willUpdate(): void;
|
|
@@ -10,6 +10,7 @@ import { ColorSchemeController } from "../../core/color-scheme.js";
|
|
|
10
10
|
import { when } from "lit/directives/when.js";
|
|
11
11
|
import { localized, msg } from "@lit/localize";
|
|
12
12
|
import { consume, ContextConsumer } from "@lit/context";
|
|
13
|
+
import { safeUrl } from "@coras-io/brand-tokens";
|
|
13
14
|
import "../../components/button/button.js";
|
|
14
15
|
import "../../components/icon/icon.js";
|
|
15
16
|
import "../../components/input-field/input-field.js";
|
|
@@ -620,21 +621,40 @@ let CorasNavBar = class CorasNavBar extends SearchMixin(SignalWatcher(LitElement
|
|
|
620
621
|
? this.logoDark
|
|
621
622
|
: this.logo);
|
|
622
623
|
return html `
|
|
623
|
-
<slot name="brand">
|
|
624
|
-
${logo
|
|
625
|
-
? html `<button
|
|
626
|
-
class="brand-button"
|
|
627
|
-
part="brand-button"
|
|
628
|
-
type="button"
|
|
629
|
-
aria-label=${msg("Go to the home page")}
|
|
630
|
-
@click=${this.handleLogoClick}
|
|
631
|
-
>
|
|
632
|
-
<img class="brand-logo" part="brand-logo" src=${logo} alt="" />
|
|
633
|
-
</button>`
|
|
634
|
-
: nothing}
|
|
635
|
-
</slot>
|
|
624
|
+
<slot name="brand"> ${logo ? this.renderBrandHome(logo) : nothing} </slot>
|
|
636
625
|
`;
|
|
637
626
|
}
|
|
627
|
+
// A distributor with its own website links the logo straight there, the way its
|
|
628
|
+
// main site does, and a real anchor keeps that a link (middle-click, new tab,
|
|
629
|
+
// status bar). Without one there is no URL to link to, so the logo stays a
|
|
630
|
+
// button dispatching the `landing` navigation for the host to route.
|
|
631
|
+
renderBrandHome(logo) {
|
|
632
|
+
const image = html `<img
|
|
633
|
+
class="brand-logo"
|
|
634
|
+
part="brand-logo"
|
|
635
|
+
src=${logo}
|
|
636
|
+
alt=""
|
|
637
|
+
/>`;
|
|
638
|
+
// The URL comes from host config, so it is gated here rather than trusted.
|
|
639
|
+
const href = safeUrl(this.logoHref);
|
|
640
|
+
return href
|
|
641
|
+
? html `<a
|
|
642
|
+
class="brand-button"
|
|
643
|
+
part="brand-button"
|
|
644
|
+
href=${href}
|
|
645
|
+
aria-label=${msg("Go to the home page")}
|
|
646
|
+
>${image}</a
|
|
647
|
+
>`
|
|
648
|
+
: html `<button
|
|
649
|
+
class="brand-button"
|
|
650
|
+
part="brand-button"
|
|
651
|
+
type="button"
|
|
652
|
+
aria-label=${msg("Go to the home page")}
|
|
653
|
+
@click=${this.handleLogoClick}
|
|
654
|
+
>
|
|
655
|
+
${image}
|
|
656
|
+
</button>`;
|
|
657
|
+
}
|
|
638
658
|
renderSearchOnlyHeader() {
|
|
639
659
|
return html `
|
|
640
660
|
<header class="search-only">
|
|
@@ -711,6 +731,9 @@ __decorate([
|
|
|
711
731
|
__decorate([
|
|
712
732
|
property({ type: String, attribute: "navbar-logo" })
|
|
713
733
|
], CorasNavBar.prototype, "navbarLogo", void 0);
|
|
734
|
+
__decorate([
|
|
735
|
+
property({ type: String, attribute: "logo-href" })
|
|
736
|
+
], CorasNavBar.prototype, "logoHref", void 0);
|
|
714
737
|
__decorate([
|
|
715
738
|
consume({ context: localeContext, subscribe: true })
|
|
716
739
|
], CorasNavBar.prototype, "locale", void 0);
|
package/dist/sdk/types.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ export type CorasConfig = {
|
|
|
87
87
|
colorScheme?: CorasColorScheme;
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
90
|
+
* Host-set options for the SDK-created Coras navbar. Each `show*` key maps 1:1 to
|
|
91
91
|
* a navbar control; an omitted key keeps the navbar's default (everything
|
|
92
92
|
* shown). Used with `{ use: "managed", props: { … } }`.
|
|
93
93
|
*/
|
|
@@ -102,6 +102,13 @@ export type CorasNavbarProps = {
|
|
|
102
102
|
showCurrencySelector?: boolean;
|
|
103
103
|
showBasket?: boolean;
|
|
104
104
|
showSearch?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Where the brand logo links, for a distributor whose booking site sits beside
|
|
107
|
+
* a main website. Set it and the logo becomes a plain link there; leave it
|
|
108
|
+
* unset and the logo stays a button that emits a `landing` navigation for the
|
|
109
|
+
* host to route. Only `https:` and same-origin URLs are honoured.
|
|
110
|
+
*/
|
|
111
|
+
logoHref?: string;
|
|
105
112
|
};
|
|
106
113
|
/**
|
|
107
114
|
* Host content-injection points on the Coras navbar. Names describe the region
|