@postnord/web-components
Version:
PostNord Web Components
37 lines (32 loc) • 2.2 kB
JavaScript
/*!
* Built with Stencil
* By PostNord.
*/
;
var index = require('./index-DWu-2oJc.js');
const pnPageNavItemCss = () => `${index.transformTag("pn-page-nav-item")}{position:relative;color:#ffffff;margin-right:0.5em;z-index:2;white-space:nowrap;scroll-snap-align:center;outline:none;-webkit-tap-highlight-color:transparent;transform:translateZ(0)}${index.transformTag("pn-page-nav-item")} a{text-decoration:none;color:#ffffff;height:100%;width:100%;padding:0.5em;font-weight:500;border-radius:3em;border:0.0625em solid transparent;display:inline-flex;align-items:center;cursor:pointer;outline:none;transition:box-shadow 0.15s}${index.transformTag("pn-page-nav-item")} a:focus{box-shadow:0 0 0 0.1em #d3cecb}${index.transformTag("pn-page-nav-item")} a>${index.transformTag("pn-icon")}{margin-right:0.5em}${index.transformTag("pn-page-nav-item")}:last-of-type{margin-right:0}`;
const PnPageNavItem = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.itemselection = index.createEvent(this, "itemselection", 7);
}
get hostElement() { return index.getElement(this); }
/** The item value. Used by `pn-page-nav` to determine pre-selected item. */
value;
/** Pass an href to the items if you want to have links that lead outside of your app. */
href;
/** The SVG content of the icon you want. */
icon;
/** Event is emitted when you select an item. */
itemselection;
select(e) {
if (this.value && !this.href)
e.preventDefault();
this.itemselection.emit(this.value);
}
render() {
return (index.h(index.Host, { key: 'b4249e533daa9f96259d5379fdfcd90d87f3cc11' }, index.h("li", { key: '86b933f5d6b4bc827826c679a6ddf04efca08ee9' }, index.h("a", { key: '217797b771a53db8bbf53272eaafe816fc668ebc', href: this.href || '#', class: "pn-page-nav-item", onClick: e => this.select(e) }, this.icon && index.h("pn-icon", { key: '8de359aa34e50caa65a66db5620590f24d409dae', icon: this.icon, color: "white" }), index.h("slot", { key: '5610d030d68f2e7f3f8eac68c02a01c3f9624f5e' })))));
}
};
PnPageNavItem.style = pnPageNavItemCss();
exports.pn_page_nav_item = PnPageNavItem;