@fluid-topics/ftds-link 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/build/define.d.ts +1 -0
- package/build/define.js +3 -0
- package/build/definitions.d.ts +5 -0
- package/build/definitions.js +4 -0
- package/build/ftds-link.d.ts +25 -0
- package/build/ftds-link.js +91 -0
- package/build/ftds-link.light.js +724 -0
- package/build/ftds-link.min.js +865 -0
- package/build/ftds-link.properties.d.ts +4 -0
- package/build/ftds-link.properties.js +1 -0
- package/build/ftds-link.styles.d.ts +2 -0
- package/build/ftds-link.styles.js +95 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +4 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
The design system link component
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ftds-link
|
|
7
|
+
yarn add @fluid-topics/ftds-link
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { html } from "lit"
|
|
14
|
+
import "@fluid-topics/ftds-link"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ftds-link foo="bar"></ftds-link> `
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/define.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ClassInfo } from "lit/directives/class-map.js";
|
|
2
|
+
import { ElementDefinitionsMap, FtdsBase } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtdsTypographyVariants } from "@fluid-topics/ftds-typography";
|
|
4
|
+
import { FtdsLinkProperties } from "./ftds-link.properties";
|
|
5
|
+
export declare enum LinkTarget {
|
|
6
|
+
SELF = "_self",
|
|
7
|
+
BLANK = "_blank"
|
|
8
|
+
}
|
|
9
|
+
export declare class FtdsLink extends FtdsBase implements FtdsLinkProperties {
|
|
10
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
11
|
+
get linkClasses(): ClassInfo;
|
|
12
|
+
href: string;
|
|
13
|
+
variant: FtdsTypographyVariants;
|
|
14
|
+
underlined: boolean;
|
|
15
|
+
openInNewTabLabel: string;
|
|
16
|
+
target: LinkTarget;
|
|
17
|
+
static styles: import("lit").CSSResult[];
|
|
18
|
+
private readonly icon;
|
|
19
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
20
|
+
private resolveIcon;
|
|
21
|
+
get resolveVariantClasses(): {
|
|
22
|
+
[x: string]: boolean;
|
|
23
|
+
};
|
|
24
|
+
private onSlotchange;
|
|
25
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html } from "lit";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
9
|
+
import { classMap, } from "lit/directives/class-map.js";
|
|
10
|
+
import { FtdsBase, isSafari, safariEllipsisFix, } from "@fluid-topics/ft-wc-utils";
|
|
11
|
+
import { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ftds-typography";
|
|
12
|
+
import { FtdsIcon, FtdsIcons, } from "@fluid-topics/ftds-icon";
|
|
13
|
+
import { styles } from "./ftds-link.styles";
|
|
14
|
+
export var LinkTarget;
|
|
15
|
+
(function (LinkTarget) {
|
|
16
|
+
LinkTarget["SELF"] = "_self";
|
|
17
|
+
LinkTarget["BLANK"] = "_blank";
|
|
18
|
+
})(LinkTarget || (LinkTarget = {}));
|
|
19
|
+
export class FtdsLink extends FtdsBase {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.href = "";
|
|
23
|
+
this.variant = FtdsTypographyVariants.body2medium;
|
|
24
|
+
this.underlined = false;
|
|
25
|
+
this.openInNewTabLabel = "This link will be opened in a new tab";
|
|
26
|
+
this.target = LinkTarget.SELF;
|
|
27
|
+
this.icon = FtdsIcons.ARROW_UP_RIGHT_FROM_SQUARE;
|
|
28
|
+
}
|
|
29
|
+
get linkClasses() {
|
|
30
|
+
return {
|
|
31
|
+
"ftds-link": true,
|
|
32
|
+
"ftds-link--underlined": this.underlined,
|
|
33
|
+
...this.resolveVariantClasses,
|
|
34
|
+
...this.getDesignSystemBaseClasses(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
return html `
|
|
39
|
+
<a part="link"
|
|
40
|
+
target="${this.target}"
|
|
41
|
+
href="${this.href}"
|
|
42
|
+
class="${classMap(this.linkClasses)}">
|
|
43
|
+
<ftds-typography part="label"
|
|
44
|
+
variant="${this.variant}"
|
|
45
|
+
element="span"
|
|
46
|
+
class="ftds-link--label ${isSafari ? "ft-safari-ellipsis-fix" : ""}">
|
|
47
|
+
<span><slot @slotchange=${this.onSlotchange}></slot></span>
|
|
48
|
+
</ftds-typography>
|
|
49
|
+
${this.resolveIcon()}
|
|
50
|
+
</a>
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
resolveIcon() {
|
|
54
|
+
return this.target === LinkTarget.BLANK ? html `
|
|
55
|
+
<ftds-icon aria-label="${this.openInNewTabLabel}" part="icon" .icon=${this.icon}>
|
|
56
|
+
</ftds-icon>
|
|
57
|
+
` : html ``;
|
|
58
|
+
}
|
|
59
|
+
get resolveVariantClasses() {
|
|
60
|
+
const prefix = "ftds-link--variant-";
|
|
61
|
+
return {
|
|
62
|
+
[prefix + this.variant]: true,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
onSlotchange() {
|
|
66
|
+
this.requestUpdate();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
FtdsLink.elementDefinitions = {
|
|
70
|
+
"ftds-typography": FtdsTypography,
|
|
71
|
+
"ftds-icon": FtdsIcon,
|
|
72
|
+
};
|
|
73
|
+
FtdsLink.styles = [
|
|
74
|
+
safariEllipsisFix,
|
|
75
|
+
styles,
|
|
76
|
+
];
|
|
77
|
+
__decorate([
|
|
78
|
+
property()
|
|
79
|
+
], FtdsLink.prototype, "href", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
property()
|
|
82
|
+
], FtdsLink.prototype, "variant", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
property({ type: Boolean })
|
|
85
|
+
], FtdsLink.prototype, "underlined", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
property()
|
|
88
|
+
], FtdsLink.prototype, "openInNewTabLabel", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
property()
|
|
91
|
+
], FtdsLink.prototype, "target", void 0);
|