@@ -37,13 +37,13 @@ export type TButtonComponentSize = TBootstrapSize;
37
37
* Usage:
38
38
*
39
39
* <iqui-button\
40
- * [ disabled = "true|false" ]\
41
- * [ class = "..." ]\
42
- * [ ngClass = "{...}" ]\
43
- * [ size = "sm|lg" ]\
44
- * [ theme = "primary|secondary|success|warning|danger|info|light|dark|link" ]\
45
- * [ href = "https://example.com" ]\
46
- * [ target = "_blank|_self" ]\
40
+ * [ disabled = "true|false" ]\
41
+ * [ class = "..." ]\
42
+ * [ ngClass = "{...}" ]\
43
+ * [ size = "sm|lg" ]\
44
+ * [ theme = "primary|secondary|success|warning|danger|info|light|dark|link" ]\
45
+ * [ href = "https://example.com" ]\
46
+ * [ target = "_blank|_self" ]\
47
47
* >\
48
48
* Button content\
49
49
* </iqui-button>
@@ -109,6 +109,19 @@ export class ButtonComponent extends UsesFormElementDirectives {
109
109
@Input ( )
110
110
public target : '_self' | '_blank' = '_self' ;
111
111
112
+ /**
113
+ * Returns remote URL to link to if [href] property contains a remote URL as a value
114
+ */
115
+ public get _href ( ) {
116
+ return this . href && this . href . includes ( '://' ) ? this . href : undefined ;
117
+ }
118
+ /**
119
+ * Returns local URL to route to if [href] property contains a local URL as a value
120
+ */
121
+ public get _routerLink ( ) {
122
+ return this . href && ! this . href . includes ( '://' ) ? this . href : undefined ;
123
+ }
124
+
112
125
/**
113
126
* Composes class value based on property values
114
127
*/
@@ -119,7 +132,7 @@ export class ButtonComponent extends UsesFormElementDirectives {
119
132
// Mark size (.btn-sm)
120
133
this . size ? 'btn-' + this . size : null ,
121
134
// Mark theme color (.btn-primary, .btn-link, etc ...)
122
- 'btn-' + ( this . theme || ( ! this . href ? 'secondary' : 'link' ) ) ,
135
+ 'btn-' + ( this . theme || ( ! this . _href && ! this . _routerLink ? 'secondary' : 'link' ) ) ,
123
136
// Mark as disabled, if disabled (.disabled)
124
137
this . disabled ? 'disabled' : null ,
125
138
// Pass-through host class
0 commit comments