UNPKG

@nebular/theme

Version:
191 lines 6.56 kB
/** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ import { Component, HostBinding, Input } from '@angular/core'; import { NbStatusService } from '../../services/status.service'; /** * Progress Bar is a component for indicating progress. * * Simple usage: * * ```html * <nb-progress-bar [value]="50"></nb-progress-bar> * ``` * ### Installation * * Import `NbProgressBarModule` to your feature module. * ```ts * @NgModule({ * imports: [ * // ... * NbProgressBarModule, * ], * }) * export class PageModule { } * ``` * ### Usage * * Progress bar accepts property `value` in range 0-100 * @stacked-example(Progress bar, progress-bar/progress-bar-showcase.component) * * Progress bar background could be configured by providing a `status` property: * @stacked-example(Progress bar status, progress-bar/progress-bar-status.component) * * Progress bar size (height and font-size) could be configured by providing a `size` property: * @stacked-example(Progress bar size, progress-bar/progress-bar-size.component) * * `displayValue` property shows current value inside progress bar. It's also possible to add custom text inside: * @stacked-example(Progress bar value, progress-bar/progress-bar-value.component) * * Progress bar supports `width` and `background-color` transition: * @stacked-example(Progress bar interactive, progress-bar/progress-bar-interactive.component) * * @styles * * progress-bar-animation-duration: * progress-bar-border-radius: * progress-bar-text-font-family: * progress-bar-tiny-height: * progress-bar-tiny-text-font-size: * progress-bar-tiny-text-font-weight: * progress-bar-tiny-text-line-height: * progress-bar-small-height: * progress-bar-small-text-font-size: * progress-bar-small-text-font-weight: * progress-bar-small-text-line-height: * progress-bar-medium-height: * progress-bar-medium-text-font-size: * progress-bar-medium-text-font-weight: * progress-bar-medium-text-line-height: * progress-bar-large-height: * progress-bar-large-text-font-size: * progress-bar-large-text-font-weight: * progress-bar-large-text-line-height: * progress-bar-giant-height: * progress-bar-giant-text-font-size: * progress-bar-giant-text-font-weight: * progress-bar-giant-text-line-height: * progress-bar-basic-background-color: * progress-bar-basic-filled-background-color: * progress-bar-basic-text-color: * progress-bar-primary-background-color: * progress-bar-primary-filled-background-color: * progress-bar-primary-text-color: * progress-bar-success-background-color: * progress-bar-success-filled-background-color: * progress-bar-success-text-color: * progress-bar-info-background-color: * progress-bar-info-filled-background-color: * progress-bar-info-text-color: * progress-bar-warning-background-color: * progress-bar-warning-filled-background-color: * progress-bar-warning-text-color: * progress-bar-danger-background-color: * progress-bar-danger-filled-background-color: * progress-bar-danger-text-color: * progress-bar-control-background-color: * progress-bar-control-filled-background-color: * progress-bar-control-text-color: */ export class NbProgressBarComponent { constructor(statusService) { this.statusService = statusService; /** * Progress bar value in percent (0 - 100) */ this.value = 0; /** * Progress bar background (`basic` (default), `primary`, `info`, `success`, `warning`, `danger`, `control`) */ this.status = 'basic'; /** * Progress bar size (`tiny`, `small`, `medium` (default), `large`, `giant`) */ this.size = 'medium'; /** * Displays value inside progress bar */ this.displayValue = false; } get tiny() { return this.size === 'tiny'; } get small() { return this.size === 'small'; } get medium() { return this.size === 'medium'; } get large() { return this.size === 'large'; } get giant() { return this.size === 'giant'; } get primary() { return this.status === 'primary'; } get success() { return this.status === 'success'; } get info() { return this.status === 'info'; } get warning() { return this.status === 'warning'; } get danger() { return this.status === 'danger'; } get basic() { return this.status === 'basic'; } get control() { return this.status === 'control'; } get additionalClasses() { if (this.statusService.isCustomStatus(this.status)) { return [this.statusService.getStatusClass(this.status)]; } return []; } } NbProgressBarComponent.decorators = [ { type: Component, args: [{ selector: 'nb-progress-bar', template: ` <div class="progress-container"> <div class="progress-value" [style.width.%]="value"> <span *ngIf="displayValue">{{ value }}%</span> <ng-content></ng-content> </div> </div> `, styles: [":host{display:block}.progress-container{overflow:hidden}.progress-value{height:100%;text-align:center;overflow:hidden}\n"] },] } ]; NbProgressBarComponent.ctorParameters = () => [ { type: NbStatusService } ]; NbProgressBarComponent.propDecorators = { value: [{ type: Input }], status: [{ type: Input }], size: [{ type: Input }], displayValue: [{ type: Input }], tiny: [{ type: HostBinding, args: ['class.size-tiny',] }], small: [{ type: HostBinding, args: ['class.size-small',] }], medium: [{ type: HostBinding, args: ['class.size-medium',] }], large: [{ type: HostBinding, args: ['class.size-large',] }], giant: [{ type: HostBinding, args: ['class.size-giant',] }], primary: [{ type: HostBinding, args: ['class.status-primary',] }], success: [{ type: HostBinding, args: ['class.status-success',] }], info: [{ type: HostBinding, args: ['class.status-info',] }], warning: [{ type: HostBinding, args: ['class.status-warning',] }], danger: [{ type: HostBinding, args: ['class.status-danger',] }], basic: [{ type: HostBinding, args: ['class.status-basic',] }], control: [{ type: HostBinding, args: ['class.status-control',] }], additionalClasses: [{ type: HostBinding, args: ['class',] }] }; //# sourceMappingURL=progress-bar.component.js.map