Skip to content

Commit

Permalink
refactor: use basic as default status (#2136)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Badge, button, progress bar, toastr components now use basic status as a default.
  • Loading branch information
yggg committed Dec 19, 2019
1 parent c36c4b8 commit cc9b47e
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class NbActionComponent {
* 'primary', 'info', 'success', 'warning', 'danger'
* @param {string} val
*/
@Input() badgeStatus: NbComponentStatus;
@Input() badgeStatus: NbComponentStatus = 'basic';

/**
* Badge position.
Expand Down
4 changes: 2 additions & 2 deletions src/framework/theme/components/badge/badge.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ describe('NbBadgeComponent', () => {
expect(fixture.debugElement.nativeElement.textContent).toEqual(text);
});

it('should has primary status by default', () => {
expect(badgeComponent.status).toEqual('primary');
it('should has basic status by default', () => {
expect(badgeComponent.status).toEqual('basic');
});

it('should set status class', () => {
Expand Down
14 changes: 13 additions & 1 deletion src/framework/theme/components/badge/badge.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { Component, HostBinding, Input } from '@angular/core';

import { NbComponentStatus } from '../component-status';
import { emptyStatusWarning } from '../helpers';

export type NbBadgePhysicalPosition = 'top left' | 'top right' | 'bottom left' | 'bottom right';
export type NbBadgeLogicalPosition = 'top start' | 'top end' | 'bottom start' | 'bottom end';
Expand Down Expand Up @@ -110,7 +111,18 @@ export class NbBadgeComponent {
* Badge status (adds specific styles):
* 'basic', 'primary', 'info', 'success', 'warning', 'danger', 'control'
*/
@Input() status: NbComponentStatus = 'primary';
@Input()
get status(): NbComponentStatus {
return this._status;
}
set status(value: NbComponentStatus) {
if ((value as string) === '') {
emptyStatusWarning('NbBadge');
value = 'basic';
}
this._status = value;
}
protected _status: NbComponentStatus = 'basic';

@HostBinding('class.status-primary')
get primary(): boolean {
Expand Down
6 changes: 3 additions & 3 deletions src/framework/theme/components/button/button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type NbButtonAppearance = 'filled' | 'outline' | 'ghost' | 'hero';
/**
* Basic button component.
*
* Default button size is `medium` and status color is `primary`:
* Default button size is `medium` and status color is `basic`:
* @stacked-example(Button Showcase, button/button-showcase.component)
*
* ```html
Expand Down Expand Up @@ -540,9 +540,9 @@ export class NbButtonComponent implements AfterViewInit {

/**
* Button status (adds specific styles):
* `basic`, `primary`, `info`, `success`, `warning`, `danger`, `control`.
* `primary`, `info`, `success`, `warning`, `danger`
*/
@Input() status: NbComponentStatus = 'primary';
@Input() status: NbComponentStatus = 'basic';

/**
* Button shapes: `rectangle`, `round`, `semi-round`
Expand Down
2 changes: 1 addition & 1 deletion src/framework/theme/components/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function lastChildNotComment(node: Node) {
}

/*
* @breaking-change Remove @5.0.0
* @breaking-change Remove @6.0.0
*/
export function emptyStatusWarning(source: string) {
console.warn(`${source}: Using empty string as a status is deprecated. Use \`basic\` instead.`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ export class NbProgressBarComponent {
@Input() value: number = 0;

/**
* Progress bar background (`basic`, `primary` (default), `info`, `success`, `warning`, `danger`, `control`)
* Progress bar background (`basic` (default), `primary`, `info`, `success`, `warning`, `danger`, `control`)
*/
@Input() status: NbComponentStatus = 'primary';
@Input() status: NbComponentStatus = 'basic';

/**
* Progress bar size (`tiny`, `small`, `medium` (default), `large`, `giant`)
Expand Down
2 changes: 1 addition & 1 deletion src/framework/theme/components/tabset/tabset.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class NbTabComponent {
* 'primary', 'info', 'success', 'warning', 'danger'
* @param {string} val
*/
@Input() badgeStatus: NbComponentStatus;
@Input() badgeStatus: NbComponentStatus = 'basic';

/**
* Badge position.
Expand Down
6 changes: 3 additions & 3 deletions src/framework/theme/components/toastr/toastr-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class NbToastrConfig {
/**
* Status chooses color scheme for the toast.
* */
status: NbComponentStatus = 'primary';
status: NbComponentStatus = 'basic';
/**
* Duration is timeout between toast appears and disappears.
* */
Expand Down Expand Up @@ -87,7 +87,7 @@ export class NbToastrConfig {
constructor(config: Partial<NbToastrConfig>) {
if ((config.status as string) === '') {
emptyStatusWarning('NbToastr');
config.status = 'primary';
config.status = 'basic';
}

this.patchIcon(config);
Expand All @@ -97,7 +97,7 @@ export class NbToastrConfig {
protected patchIcon(config: Partial<NbToastrConfig>) {
if (!('icon' in config)) {
config.icon = {
icon: this.icons[config.status || 'primary'],
icon: this.icons[config.status || 'basic'],
pack: 'nebular-essentials',
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('toastr-service', () => {
expect(attachSpy).toHaveBeenCalled();
const [[{ config }]] = attachSpy.calls.allArgs();
expect(config.position).toBe(NbGlobalLogicalPosition.BOTTOM_START, 'incorrect position');
expect(config.status).toBe('primary', 'incorrect status');
expect(config.status).toBe('basic', 'incorrect status');
expect(config.duration).toBe(1234, 'incorrect duration');
expect(config.destroyByClick).toBe(true, 'incorrect destroyByClick');
expect(config.preventDuplicates).toBe(true, 'incorrect preventDuplicates');
Expand Down
4 changes: 2 additions & 2 deletions src/framework/theme/components/toastr/toastr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class NbToastrContainerRegistry {
* @stacked-example(Position, toastr/toastr-positions.component)
*
* `status` - coloring and icon of the toast.
* Default is `primary`.
* Default is `basic`.
*
* @stacked-example(Status, toastr/toastr-statuses.component)
*
Expand Down Expand Up @@ -313,7 +313,7 @@ export class NbToastrService {
}

/**
* Shows basic toast with message, title and user config.
* Shows default toast with message, title and user config.
* */
default(message, title?, config?: Partial<NbToastrConfig>): NbToastRef {
return this.show(message, title, { ...config, status: 'basic' });
Expand Down
2 changes: 1 addition & 1 deletion src/framework/theme/components/user/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class NbUserComponent {
* `primary`, `info`, `success`, `warning`, `danger`
* @param {string} val
*/
@Input() badgeStatus: NbComponentStatus;
@Input() badgeStatus: NbComponentStatus = 'basic';

/**
* Badge position.
Expand Down

0 comments on commit cc9b47e

Please sign in to comment.