Skip to content

Commit 8f0027c

Browse files
authored
Merge pull request #669 from dxc-technology/aida-link-types
Types for Link component
2 parents a5464eb + 9c1a7c0 commit 8f0027c

File tree

2 files changed

+64
-17
lines changed

2 files changed

+64
-17
lines changed

projects/dxc-ngx-cdk-site/src/app/components/examples/link/properties/link-table-properties/link-table-properties.component.html

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
<dxc-heading [level]="4" weight="normal" text="Properties" [margin]="{bottom:'small'}"></dxc-heading>
1+
<dxc-heading
2+
[level]="4"
3+
weight="normal"
4+
text="Properties"
5+
[margin]="{ bottom: 'small' }"
6+
></dxc-heading>
27
<dxc-table>
38
<tr>
49
<th>Name</th>
@@ -58,9 +63,7 @@
5863
<tr>
5964
<td>tabIndexValue: number</td>
6065
<td><code>0</code></td>
61-
<td>
62-
Value of the tabindex.
63-
</td>
66+
<td>Value of the tabindex.</td>
6467
</tr>
6568
<tr>
6669
<td>margin: string | object</td>
@@ -78,8 +81,8 @@
7881
<td>onClick: EventEmitter</td>
7982
<td></td>
8083
<td>
81-
If defined, the link will be displayed as a button.
82-
This function will be called when the user clicks the link.
84+
This event will emit in case the user clicks the component. If defined,
85+
the link will be displayed as a button.
8386
</td>
8487
</tr>
8588
</dxc-table>

projects/dxc-ngx-cdk/src/lib/dxc-link/dxc-link.component.ts

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ import {
1818
} from "@angular/core";
1919
import { DxcLinkIconComponent } from "./dxc-link-icon/dxc-link-icon.component";
2020

21+
type Space =
22+
| "xxsmall"
23+
| "xsmall"
24+
| "small"
25+
| "medium"
26+
| "large"
27+
| "xlarge"
28+
| "xxlarge";
29+
type Margin = {
30+
top?: Space;
31+
bottom?: Space;
32+
left?: Space;
33+
right?: Space;
34+
};
35+
2136
@Component({
2237
selector: "dxc-link",
2338
templateUrl: "./dxc-link.component.html",
@@ -32,57 +47,86 @@ export class DxcLinkComponent {
3247
this._underlined = coerceBooleanProperty(value);
3348
}
3449
private _underlined = true;
50+
/**
51+
* If true, the color is inherited from parent.
52+
*/
3553
@Input()
3654
get inheritColor(): boolean {
3755
return this._inheritColor;
3856
}
3957
set inheritColor(value: boolean) {
4058
this._inheritColor = coerceBooleanProperty(value);
4159
}
42-
private _inheritColor;
60+
private _inheritColor = false;
61+
/**
62+
* If true, the link is disabled.
63+
*/
4364
@Input()
4465
get disabled(): boolean {
4566
return this._disabled;
4667
}
4768
set disabled(value: boolean) {
4869
this._disabled = coerceBooleanProperty(value);
4970
}
50-
private _disabled;
71+
private _disabled = false;
72+
/**
73+
* Link text.
74+
*/
5175
@Input() text: string;
76+
/**
77+
* @Deprecated Source of the icon.
78+
*/
5279
@Input() iconSrc: string;
80+
/**
81+
* Indicates the position of the icon in the component.
82+
*/
5383
@Input() iconPosition: string;
84+
/**
85+
* Page to be opened when the user clicks on the link.
86+
*/
5487
@Input() href: string;
88+
/**
89+
* If true, the page is opened in a new browser tab.
90+
*/
5591
@Input()
5692
get newWindow(): boolean {
5793
return this._newWindow;
5894
}
5995
set newWindow(value: boolean) {
6096
this._newWindow = coerceBooleanProperty(value);
6197
}
62-
private _newWindow;
63-
@Input() margin: string;
98+
private _newWindow = false;
99+
/**
100+
* Size of the margin to be applied to the component
101+
* ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
102+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties
103+
* in order to specify different margin sizes.
104+
*/
105+
@Input() margin: Space | Margin;
106+
/**
107+
* Value of the tabindex.
108+
*/
64109
@Input()
65110
get tabIndexValue(): number {
66111
return this._tabIndexValue;
67112
}
68113
set tabIndexValue(value: number) {
69114
this._tabIndexValue = coerceNumberProperty(value);
70115
}
71-
private _tabIndexValue;
72-
116+
private _tabIndexValue = 0;
117+
/**
118+
* This event will emit in case the user clicks the component. If defined,
119+
* the link will be displayed as a button.
120+
*/
73121
@Output() onClick = new EventEmitter<any>();
74122

75123
@HostBinding("class") className;
76-
77-
isClickDefined = false;
78-
79124
@ContentChildren(DxcLinkIconComponent)
80125
dxcLinkIcon: QueryList<DxcLinkIconComponent>;
81-
82126
styledLink: string = css`
83127
display: inline;
84128
`;
85-
129+
isClickDefined = false;
86130
styledButton: string;
87131

88132
defaultInputs = new BehaviorSubject<any>({

0 commit comments

Comments
 (0)