Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(action): provide new attributes for link and title #1046

Merged
merged 5 commits into from
Jan 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 48 additions & 13 deletions src/framework/theme/components/actions/actions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import {
Component,
Input,
HostBinding,
} from '@angular/core';
import { Component, HostBinding, Input } from '@angular/core';

import { convertToBoolProperty } from '../helpers';

Expand All @@ -18,19 +14,60 @@ import { convertToBoolProperty } from '../helpers';
@Component({
selector: 'nb-action',
template: `
<a class="icon-container" href="#" *ngIf="icon; else showContent" (click)="$event.preventDefault()">
<i class="control-icon {{ icon }}"></i>
</a>
<ng-template #showContent>
<ng-container *ngIf="icon; else projectedContent">
<a class="icon-container"
[routerLink]="link"
[title]="title"
*ngIf="link">
<i class="control-icon {{ icon }}"></i>
</a>
<a class="icon-container"
[href]="href"
[title]="title"
*ngIf="href && !link">
<i class="control-icon {{ icon }}"></i>
</a>
<a class="icon-container"
href="#"
[title]="title"
*ngIf="!href && !link"
(click)="$event.preventDefault()">
<i class="control-icon {{ icon }}"></i>
</a>
</ng-container>

<ng-template #projectedContent>
<ng-content></ng-content>
</ng-template>
<nb-badge *ngIf="badgeText" [text]="badgeText" [status]="badgeStatus" [position]="badgePosition"></nb-badge>

<nb-badge *ngIf="badgeText"
[text]="badgeText"
[status]="badgeStatus"
[position]="badgePosition">
</nb-badge>
`,
})
export class NbActionComponent {

@HostBinding('class.disabled') disabledValue: boolean = false;

/**
* Router link to use
* @type string
*/
@Input() link: string;

/**
* Regular HREF link
* @type: string
*/
@Input() href: string;

/**
* Optional title for mouseover
* @type string
*/
@Input() title: string = '';

/**
* Icon class to display
* @type string
Expand Down Expand Up @@ -67,7 +104,6 @@ export class NbActionComponent {
* @type string
*/
@Input() badgePosition: string;

}

/**
Expand Down Expand Up @@ -129,7 +165,6 @@ export class NbActionComponent {
`,
})
export class NbActionsComponent {

static readonly SIZE_SMALL = 'small';
static readonly SIZE_MEDIUM = 'medium';
static readonly SIZE_LARGE = 'large';
Expand Down