Skip to content

Commit 20bf14d

Browse files
committed
Minor fixes
1 parent 112d7ae commit 20bf14d

File tree

8 files changed

+47
-12
lines changed

8 files changed

+47
-12
lines changed

projects/iqui-ngx/src/lib/components/basics/button/index.html

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22
<ng-template #content><ng-content></ng-content></ng-template>
33

44
<!-- Button -->
5-
<button *ngIf="!href" [iquiFormParent]="_iquiFormParent" [attr.disabled]="disabled || null" [ngClass]="ngClass" [class]="_composedClassValue">
5+
<button *ngIf="!_href && !_routerLink" [iquiFormParent]="_iquiFormParent" [attr.disabled]="disabled || null" [ngClass]="ngClass" [class]="_composedClassValue">
66
<span class="iqui-button-content d-flex align-items-center">
77
<ng-container *ngTemplateOutlet="content"></ng-container>
88
</span>
99
</button>
1010

11-
<!-- Anchor -->
12-
<a *ngIf="!!href" [attr.disabled]="disabled || null" [ngClass]="ngClass" [class]="_composedClassValue" [href]="href" [target]="target">
11+
<!-- Anchor (linking to URL) -->
12+
<a *ngIf="!!_href" [attr.disabled]="disabled || null" [ngClass]="ngClass" [class]="_composedClassValue" [href]="_href" [target]="target">
13+
<span class="iqui-button-content d-flex align-items-center">
14+
<ng-container *ngTemplateOutlet="content"></ng-container>
15+
</span>
16+
</a>
17+
18+
<!-- Anchor (routing to local URL) -->
19+
<a *ngIf="!!_routerLink" [attr.disabled]="disabled || null" [ngClass]="ngClass" [class]="_composedClassValue" [routerLink]="_routerLink">
1320
<span class="iqui-button-content d-flex align-items-center">
1421
<ng-container *ngTemplateOutlet="content"></ng-container>
1522
</span>

projects/iqui-ngx/src/lib/components/basics/button/index.ts

+21-8
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ export type TButtonComponentSize = TBootstrapSize;
3737
* Usage:
3838
*
3939
* <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" ]\
4747
* >\
4848
* Button content\
4949
* </iqui-button>
@@ -109,6 +109,19 @@ export class ButtonComponent extends UsesFormElementDirectives {
109109
@Input()
110110
public target: '_self' | '_blank' = '_self';
111111

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+
112125
/**
113126
* Composes class value based on property values
114127
*/
@@ -119,7 +132,7 @@ export class ButtonComponent extends UsesFormElementDirectives {
119132
// Mark size (.btn-sm)
120133
this.size ? 'btn-' + this.size : null,
121134
// 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')),
123136
// Mark as disabled, if disabled (.disabled)
124137
this.disabled ? 'disabled' : null,
125138
// Pass-through host class

projects/iqui-ngx/src/lib/components/basics/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Import dependencies
22
import { NgModule } from '@angular/core';
33
import { CommonModule } from '@angular/common';
4+
import { RouterModule } from '@angular/router';
45

56
// Import dependency modules
67
import { FunctionalModule } from '../functional';
@@ -37,9 +38,12 @@ export { PhraseInputComponent };
3738
* Implements components that are basic building blocks of any application or more-complex component
3839
*/
3940
@NgModule({
40-
imports: [CommonModule, FunctionalModule, FormModule],
41+
imports: [CommonModule, RouterModule, FunctionalModule, FormModule],
4142
declarations: [ButtonComponent, DropdownButtonComponent, PhraseInputComponent],
4243
exports: [
44+
// Export angular dependencies
45+
CommonModule,
46+
RouterModule,
4347
// Export dependency modules
4448
FunctionalModule,
4549
FormModule,

projects/iqui-ngx/src/lib/components/code/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export { HighlightJsComponent, HighlightJsTextareaDirective, HighlightJsInjectTo
2424
imports: [CommonModule, BasicsModule, FormModule],
2525
declarations: [HighlightJsComponent, HighlightJsTextareaDirective, HighlightJsInjectTopDirective, HighlightJsInjectBottomDirective],
2626
exports: [
27+
// Export angular dependencies
28+
CommonModule,
2729
// Export dependency modules
2830
CommonModule,
2931
BasicsModule,

projects/iqui-ngx/src/lib/components/form/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export { SelectComponent } from './components/select';
6363
OptionDirective,
6464
],
6565
exports: [
66+
// Export angular dependencies
67+
CommonModule,
6668
// Export dependency modules
6769
TextFieldModule,
6870
// Export child components

projects/iqui-ngx/src/lib/components/functional/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export { BookmarkableDirective, BookmarkableService };
6161
BookmarkableDirective,
6262
],
6363
exports: [
64+
// Export angular dependencies
65+
CommonModule,
6466
// Export dependency modules
6567
OverlayModule,
6668
// Export child components

projects/iqui-ngx/src/lib/components/showcasing/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export { PlaygroundComponent, PlaygroundTextareaDirective };
1818
imports: [CommonModule, FormModule, CodeModule],
1919
declarations: [PlaygroundComponent, PlaygroundTextareaDirective],
2020
exports: [
21+
// Export angular dependencies
22+
CommonModule,
2123
// Export dependency modules
2224
FormModule,
2325
CodeModule,

projects/iqui-ngx/src/lib/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ export { providers };
104104
declarations: [],
105105
providers: [...providers],
106106
exports: [
107+
// Export angular dependencies
108+
CommonModule,
109+
BrowserModule,
107110
// (Re)export individual modules, making them included into any app the root module is included in
108111
...modules,
109112
],

0 commit comments

Comments
 (0)