@scania/tegel
Version:
Tegel Design System
107 lines (106 loc) • 3.43 kB
JavaScript
import { h } from "@stencil/core";
/**
* @slot <default> - <b>Unnamed slot.</b> For a link element. Eg. <code><a><a></code>.
*/
export class TdsLink {
constructor() {
this.disabled = false;
this.underline = true;
this.standalone = false;
}
connectedCallback() {
const links = this.host.querySelectorAll('a');
if (links.length > 1) {
console.warn('tds-link is only intended to wrap one <a> tag');
}
const link = links[0];
if (link) {
if (this.disabled) {
link.setAttribute('tabindex', '-1');
link.setAttribute('aria-disabled', 'true');
}
else {
link.removeAttribute('tabindex');
link.removeAttribute('aria-disabled');
}
}
}
render() {
return (h("span", { key: '7f0f25738cc23b6f1cb77be9dd80ea14b9b399bc', class: {
'disabled': this.disabled,
'no-underline': !this.underline,
'standalone': this.standalone,
} }, h("slot", { key: '73203886b4064a43a2b3ede33ce650f280ebe9c5' })));
}
static get is() { return "tds-link"; }
static get encapsulation() { return "shadow"; }
static get originalStyleUrls() {
return {
"$": ["link.scss"]
};
}
static get styleUrls() {
return {
"$": ["link.css"]
};
}
static get properties() {
return {
"disabled": {
"type": "boolean",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "Disables the Link"
},
"attribute": "disabled",
"reflect": false,
"defaultValue": "false"
},
"underline": {
"type": "boolean",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "Displays the Link with an underline."
},
"attribute": "underline",
"reflect": false,
"defaultValue": "true"
},
"standalone": {
"type": "boolean",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "Displays the Link as a standalone component. Not part of a paragraph."
},
"attribute": "standalone",
"reflect": false,
"defaultValue": "false"
}
};
}
static get elementRef() { return "host"; }
}