Skip to content

Commit

Permalink
refactor(sidebar): remove deprecated properties (#2973)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
`NbSidebarComponent.toggleResponsive` method removed. Toggle `responsive` property.
`NbSidebarComponent`'s `STATE_EXPANDED`, `STATE_COLLAPSED`, `STATE_COMPACTED` static properties removed. Use `NbSidebarState` type values (`'expanded'`, `'collapsed'`, `'compacted'`).
`NbSidebarComponent`'s `RESPONSIVE_STATE_MOBILE`, `RESPONSIVE_STATE_TABLET`, `RESPONSIVE_STATE_PC`  static properties removed. Use `NbSidebarResponsiveState` type values (`'mobile'`, `'tablet'`, `'pc'`).
  • Loading branch information
yggg authored Dec 1, 2021
1 parent 06f620d commit 0ba32cd
Showing 1 changed file with 13 additions and 57 deletions.
70 changes: 13 additions & 57 deletions src/framework/theme/components/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ export type NbSidebarResponsiveState = 'mobile' | 'tablet' | 'pc';
*/
@Component({
selector: 'nb-sidebar-header',
template: `
<ng-content></ng-content>
`,
template: ` <ng-content></ng-content> `,
})
export class NbSidebarHeaderComponent {
}
export class NbSidebarHeaderComponent {}

/**
* Sidebar footer container.
Expand All @@ -50,12 +47,9 @@ export class NbSidebarHeaderComponent {
*/
@Component({
selector: 'nb-sidebar-footer',
template: `
<ng-content></ng-content>
`,
template: ` <ng-content></ng-content> `,
})
export class NbSidebarFooterComponent {
}
export class NbSidebarFooterComponent {}

/**
* Layout sidebar component.
Expand Down Expand Up @@ -133,8 +127,7 @@ export class NbSidebarFooterComponent {
selector: 'nb-sidebar',
styleUrls: ['./sidebar.component.scss'],
template: `
<div class="main-container"
[class.main-container-fixed]="containerFixedValue">
<div class="main-container" [class.main-container-fixed]="containerFixedValue">
<ng-content select="nb-sidebar-header"></ng-content>
<div class="scrollable" (click)="onClick($event)">
<ng-content></ng-content>
Expand All @@ -145,7 +138,6 @@ export class NbSidebarFooterComponent {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NbSidebarComponent implements OnInit, OnDestroy {

protected readonly responsiveValueChange$: Subject<boolean> = new Subject<boolean>();
protected responsiveState: NbSidebarResponsiveState = 'pc';

Expand Down Expand Up @@ -319,28 +311,32 @@ export class NbSidebarComponent implements OnInit, OnDestroy {
) {}

ngOnInit() {
this.sidebarService.onToggle()
this.sidebarService
.onToggle()
.pipe(
filter(({ tag }) => !this.tag || this.tag === tag),
takeUntil(this.destroy$),
)
.subscribe(({ compact }) => this.toggle(compact));

this.sidebarService.onExpand()
this.sidebarService
.onExpand()
.pipe(
filter(({ tag }) => !this.tag || this.tag === tag),
takeUntil(this.destroy$),
)
.subscribe(() => this.expand());

this.sidebarService.onCollapse()
this.sidebarService
.onCollapse()
.pipe(
filter(({ tag }) => !this.tag || this.tag === tag),
takeUntil(this.destroy$),
)
.subscribe(() => this.collapse());

this.sidebarService.onCompact()
this.sidebarService
.onCompact()
.pipe(
filter(({ tag }) => !this.tag || this.tag === tag),
takeUntil(this.destroy$),
Expand Down Expand Up @@ -446,7 +442,6 @@ export class NbSidebarComponent implements OnInit, OnDestroy {
takeUntil(this.destroy$),
)
.subscribe(([prev, current]: [NbMediaBreakpoint, NbMediaBreakpoint]) => {

const isCollapsed = this.collapsedBreakpoints.includes(current.name);
const isCompacted = this.compactedBreakpoints.includes(current.name);

Expand Down Expand Up @@ -495,43 +490,4 @@ export class NbSidebarComponent implements OnInit, OnDestroy {
this.cd.markForCheck();
}
}

/**
* @deprecated Use `responsive` property instead
* @breaking-change Remove @8.0.0
*/
toggleResponsive(enabled: boolean) {
this.responsive = enabled;
}
/**
* @deprecated Use NbSidebarState type instead
* @breaking-change Remove @8.0.0
*/
static readonly STATE_EXPANDED: string = 'expanded';
/**
* @deprecated Use NbSidebarState type instead
* @breaking-change Remove @8.0.0
*/
static readonly STATE_COLLAPSED: string = 'collapsed';
/**
* @deprecated Use NbSidebarState type instead
* @breaking-change Remove @8.0.0
*/
static readonly STATE_COMPACTED: string = 'compacted';

/**
* @deprecated Use NbSidebarResponsiveState type instead
* @breaking-change Remove @8.0.0
*/
static readonly RESPONSIVE_STATE_MOBILE: string = 'mobile';
/**
* @deprecated Use NbSidebarResponsiveState type instead
* @breaking-change Remove @8.0.0
*/
static readonly RESPONSIVE_STATE_TABLET: string = 'tablet';
/**
* @deprecated Use NbSidebarResponsiveState type instead
* @breaking-change Remove @8.0.0
*/
static readonly RESPONSIVE_STATE_PC: string = 'pc';
}

0 comments on commit 0ba32cd

Please sign in to comment.