@postnord/web-components
Version:
PostNord Web Components
113 lines (112 loc) • 4.44 kB
JavaScript
/*!
* Built with Stencil
* By PostNord.
*/
import { h, Host } from "@stencil/core";
import { open_in_new } from "pn-design-assets/pn-assets/icons.js";
import { URLS } from "./urls";
import { translations } from "./translations";
import { SE, NO, en, awaitTopbar } from "../../../globals/helpers";
/**
* The default market and language is SE/en.
*
* Make sure you set the market **and** language prop.
* Example: Setting the `language` prop `da` will not display anything, as `da` does not exist on the `SE` market.
*
* @deprecated This component has been replaced with the {@link https://portal.postnord.com/web-components/?path=/docs/external-components-pn-footer-nav--docs pn-footer-nav}.
*/
export class PnFooter {
constructor() {
this.market = null;
this.language = null;
}
hostElement;
async componentWillLoad() {
if (this.market && this.language)
return;
await awaitTopbar(this.hostElement);
}
getLink(name) {
return URLS?.[this.market || SE]?.[name]?.[this.language || en];
}
getText(name) {
if (name === 'domain')
return this.getLink(name)?.replace('https://www.', '');
return translations?.[name]?.[this.language];
}
renderLink(name) {
const url = this.getLink(name);
const text = this.getText(name);
if (url && text) {
return h("pn-text-link", { label: text, target: "_blank", rel: "noopener noreferrer", href: url, icon: open_in_new });
}
}
render() {
return (h(Host, { key: '1aabdc7109561bf4bc8898a868a62ae876748393' }, h("div", { key: '890e9c401a690c620c4b6eace747a8a66a59c0d4', class: "pn-footer-row" }, h("p", { key: '77f30b40fe86d763499898145656da51c323a4a1' }, this.getText('questions')), this.renderLink('contact')), h("div", { key: 'de758452b670ebe4677067b8c90eae0808237402', class: "pn-footer-row" }, this.market !== NO && this.renderLink('terms'), this.renderLink('privacy'), this.renderLink('cookies')), h("div", { key: 'c29172ff11e9d21bbe084487fef6c8e38620cf5d', class: "pn-footer-row" }, h("p", { key: 'c585618b0ed711185d9c23cf9cea5417db2c8142' }, this.getText('info')), this.renderLink('domain'))));
}
static get is() { return "pn-footer"; }
static get originalStyleUrls() {
return {
"$": ["pn-footer.scss"]
};
}
static get styleUrls() {
return {
"$": ["pn-footer.css"]
};
}
static get properties() {
return {
"market": {
"type": "string",
"mutable": false,
"complexType": {
"original": "PnMarkets",
"resolved": "\"\" | \"DK\" | \"FI\" | \"NO\" | \"SE\"",
"references": {
"PnMarkets": {
"location": "import",
"path": "@/globals/types",
"id": "src/globals/types.ts::PnMarkets"
}
}
},
"required": false,
"optional": true,
"docs": {
"tags": [],
"text": "Set the market for the footer."
},
"attribute": "market",
"reflect": false,
"defaultValue": "null"
},
"language": {
"type": "string",
"mutable": false,
"complexType": {
"original": "PnLanguages",
"resolved": "\"\" | \"da\" | \"en\" | \"fi\" | \"no\" | \"sv\"",
"references": {
"PnLanguages": {
"location": "import",
"path": "@/globals/types",
"id": "src/globals/types.ts::PnLanguages"
}
}
},
"required": false,
"optional": true,
"docs": {
"tags": [],
"text": "Set the language for the footer."
},
"attribute": "language",
"reflect": false,
"defaultValue": "null"
}
};
}
static get elementRef() { return "hostElement"; }
}
//# sourceMappingURL=pn-footer.js.map