Skip to content

Commit

Permalink
feat(calendar): rtl support
Browse files Browse the repository at this point in the history
  • Loading branch information
Tibing committed Aug 6, 2018
1 parent e1c7d6d commit c6b5442
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
margin-left: 0.5rem;
}

.nb-arrow-dropleft {
margin-right: 0.5rem;
}

&:hover {
color: nb-theme(calendar-hover-item-bg);
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@

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

import { NbLayoutDirectionService } from '../../../../services/direction.service';


@Component({
selector: 'nb-calendar-header',
template: `
<div class="header">
<span class="title" (click)="navigateToday.emit()">
{{ date | nbCalendarDate }} <i class="nb-arrow-dropright"></i>
{{ date | nbCalendarDate }}
<i [ngClass]="{ 'nb-arrow-dropright': isLtr, 'nb-arrow-dropleft': isRtl }"></i>
</span>
<span class="sub-title">Today</span>
</div>
Expand All @@ -21,4 +24,15 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
export class NbCalendarHeaderComponent {
@Input() date: Date = new Date();
@Output() navigateToday: EventEmitter<void> = new EventEmitter();

constructor(private directionService: NbLayoutDirectionService) {
}

get isRtl(): boolean {
return this.directionService.isRtl();
}

get isLtr(): boolean {
return this.directionService.isLtr();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,34 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';

import { NbLayoutDirectionService } from '../../../../services/direction.service';


@Component({
selector: 'nb-calendar-pageable-navigation',
styleUrls: ['./calendar-pageable-navigation.component.scss'],
template: `
<i class="nb-arrow-left" (click)="prev.emit()"></i>
<i [ngClass]="{'nb-arrow-left': isLtr, 'nb-arrow-right': isRtl }" (click)="prev.emit()"></i>
<nb-calendar-navigation [date]="date" (changeMode)="changeMode.emit()"></nb-calendar-navigation>
<i class="nb-arrow-right" (click)="next.emit()"></i>
<i [ngClass]="{'nb-arrow-right': isLtr, 'nb-arrow-left': isRtl }" (click)="next.emit()"></i>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NbCalendarPageableNavigationComponent {
@Input() date: Date;
@Output() changeMode = new EventEmitter<void>();
@Output() next = new EventEmitter<void>();
@Output() prev = new EventEmitter<void>();

constructor(private directionService: NbLayoutDirectionService) {
}

get isRtl(): boolean {
return this.directionService.isRtl();
}

get isLtr(): boolean {
return this.directionService.isLtr();
}
}

0 comments on commit c6b5442

Please sign in to comment.