UNPKG

@ionic/core

Version:
179 lines (178 loc) • 7.25 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import { Host, h } from "@stencil/core"; import { createColorClasses, openURL } from "../../utils/theme"; import { getIonMode } from "../../global/ionic-global"; export class RouterLink { constructor() { /** * When using a router, it specifies the transition direction when navigating to * another page using `href`. */ this.routerDirection = 'forward'; this.onClick = (ev) => { openURL(this.href, ev, this.routerDirection, this.routerAnimation); }; } render() { const mode = getIonMode(this); const attrs = { href: this.href, rel: this.rel, target: this.target, }; return (h(Host, { key: 'd7f2affcde45c5fbb6cb46cd1c30008ee92a68c5', onClick: this.onClick, class: createColorClasses(this.color, { [mode]: true, 'ion-activatable': true, }) }, h("a", Object.assign({ key: 'babafae85ca5c6429958d383feff0493ff8cf33e' }, attrs), h("slot", { key: '50314e9555bbf6dffa0c50c3f763009dee59b10b' })))); } static get is() { return "ion-router-link"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["router-link.scss"] }; } static get styleUrls() { return { "$": ["router-link.css"] }; } static get properties() { return { "color": { "type": "string", "attribute": "color", "mutable": false, "complexType": { "original": "Color", "resolved": "\"danger\" | \"dark\" | \"light\" | \"medium\" | \"primary\" | \"secondary\" | \"success\" | \"tertiary\" | \"warning\" | string & Record<never, never> | undefined", "references": { "Color": { "location": "import", "path": "../../interface", "id": "src/interface.d.ts::Color" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "The color to use from your application's color palette.\nDefault options are: `\"primary\"`, `\"secondary\"`, `\"tertiary\"`, `\"success\"`, `\"warning\"`, `\"danger\"`, `\"light\"`, `\"medium\"`, and `\"dark\"`.\nFor more information on colors, see [theming](/docs/theming/basics)." }, "getter": false, "setter": false, "reflect": true }, "href": { "type": "string", "attribute": "href", "mutable": false, "complexType": { "original": "string | undefined", "resolved": "string | undefined", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Contains a URL or a URL fragment that the hyperlink points to.\nIf this property is set, an anchor tag will be rendered." }, "getter": false, "setter": false, "reflect": false }, "rel": { "type": "string", "attribute": "rel", "mutable": false, "complexType": { "original": "string | undefined", "resolved": "string | undefined", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the relationship of the target object to the link object.\nThe value is a space-separated list of [link types](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types)." }, "getter": false, "setter": false, "reflect": false }, "routerDirection": { "type": "string", "attribute": "router-direction", "mutable": false, "complexType": { "original": "RouterDirection", "resolved": "\"back\" | \"forward\" | \"root\"", "references": { "RouterDirection": { "location": "import", "path": "../router/utils/interface", "id": "src/components/router/utils/interface.ts::RouterDirection" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "When using a router, it specifies the transition direction when navigating to\nanother page using `href`." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "'forward'" }, "routerAnimation": { "type": "unknown", "attribute": "router-animation", "mutable": false, "complexType": { "original": "AnimationBuilder | undefined", "resolved": "((baseEl: any, opts?: any) => Animation) | undefined", "references": { "AnimationBuilder": { "location": "import", "path": "../../interface", "id": "src/interface.d.ts::AnimationBuilder" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "When using a router, it specifies the transition animation when navigating to\nanother page using `href`." }, "getter": false, "setter": false }, "target": { "type": "string", "attribute": "target", "mutable": false, "complexType": { "original": "string | undefined", "resolved": "string | undefined", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies where to display the linked URL.\nOnly applies when an `href` is provided.\nSpecial keywords: `\"_blank\"`, `\"_self\"`, `\"_parent\"`, `\"_top\"`." }, "getter": false, "setter": false, "reflect": false } }; } }