@postnord/web-components
Version:
PostNord Web Components
115 lines (114 loc) • 4.43 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.
*/
export class PnFooter {
hostElement;
/** Set the market for the footer. */
market = null;
/** Set the language for the footer. */
language = null;
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: '9eeb6c90b62d1e6c20c55040a75e6277c7fd054d' }, h("div", { key: 'aed5a2a818db6e882145cab89f8d5890a8ee6e9a', class: "pn-footer-row" }, h("p", { key: '6722217eb5c38f377934be571be2126901545a2e' }, this.getText('questions')), this.renderLink('contact')), h("div", { key: 'e3e49c49d385926f1c994596649bcbe0b79fc553', class: "pn-footer-row" }, this.market !== NO && this.renderLink('terms'), this.renderLink('privacy'), this.renderLink('cookies')), h("div", { key: 'd9eabd2ef302e2f04bb2f054c56b4e905aa7e3ba', class: "pn-footer-row" }, h("p", { key: '0ea955a6a08e86fdad902890c6630ada7c004f9a' }, 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."
},
"getter": false,
"setter": false,
"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."
},
"getter": false,
"setter": false,
"attribute": "language",
"reflect": false,
"defaultValue": "null"
}
};
}
static get elementRef() { return "hostElement"; }
}
//# sourceMappingURL=pn-footer.js.map