Skip to content

Commit

Permalink
Merge branch 'master' into no-export-nb-table
Browse files Browse the repository at this point in the history
  • Loading branch information
yggg authored Mar 13, 2020
2 parents 4c43f04 + b63f004 commit 7eddfe2
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 9 deletions.
13 changes: 12 additions & 1 deletion src/framework/theme/components/chat/chat-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import { NbComponentStatus } from '../component-status';
[(ngModel)]="message"
[class.with-button]="showButton"
type="text"
placeholder="{{ fileOver ? 'Drop file to send' : 'Type a message' }}"
placeholder="{{ fileOver ? dropFilePlaceholder : messagePlaceholder }}"
(keyup.enter)="sendMessage()">
<button nbButton
[status]="getButtonStatus()"
Expand Down Expand Up @@ -102,6 +102,11 @@ export class NbChatFormComponent {
*/
@Input() message: string = '';

/**
* Message placeholder text
* @type {string}
*/
@Input() messagePlaceholder: string = 'Type a message';
/**
* Send button title
* @type {string}
Expand All @@ -126,6 +131,12 @@ export class NbChatFormComponent {
*/
@Input() dropFiles: boolean = false;

/**
* File drop placeholder text
* @type {string}
*/
@Input() dropFilePlaceholder: string = 'Drop file to send';

/**
*
* @type {EventEmitter<{ message: string, files: File[] }>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type NbChatMessageFile = NbChatMessageFileIconPreview | NbChatMessageFile
@Component({
selector: 'nb-chat-message-file',
template: `
<nb-chat-message-text [sender]="sender" [date]="date" [message]="message">
<nb-chat-message-text [sender]="sender" [date]="date" [dateFormat]="dateFormat" [message]="message">
{{ message }}
</nb-chat-message-text>
Expand Down Expand Up @@ -67,6 +67,12 @@ export class NbChatMessageFileComponent {
*/
@Input() date: Date;

/**
* Message send date format, default 'shortTime'
* @type {string}
*/
@Input() dateFormat: string = 'shortTime';

/**
* Message file path
* @type {Date}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { NbChatOptions } from './chat.options';
@Component({
selector: 'nb-chat-message-map',
template: `
<nb-chat-message-file [files]="[file]" [message]="message" [sender]="sender" [date]="date"></nb-chat-message-file>
<nb-chat-message-file [files]="[file]" [message]="message" [sender]="sender" [date]="date"
[dateFormat]="dateFormat"></nb-chat-message-file>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand All @@ -37,6 +38,12 @@ export class NbChatMessageMapComponent {
*/
@Input() date: Date;

/**
* Message send date format, default 'shortTime'
* @type {string}
*/
@Input() dateFormat: string = 'shortTime';

/**
* Map latitude
* @type {number}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
@Component({
selector: 'nb-chat-message-quote',
template: `
<p class="sender" *ngIf="sender || date">{{ sender }} <time>{{ date | date:'shortTime' }}</time></p>
<p class="sender" *ngIf="sender || date">{{ sender }} <time>{{ date | date: dateFormat }}</time></p>
<p class="quote">
{{ quote }}
</p>
Expand Down Expand Up @@ -42,6 +42,12 @@ export class NbChatMessageQuoteComponent {
*/
@Input() date: Date;

/**
* Message send date format, default 'shortTime'
* @type {string}
*/
@Input() dateFormat: string = 'shortTime';

/**
* Quoted message
* @type {Date}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
@Component({
selector: 'nb-chat-message-text',
template: `
<p class="sender" *ngIf="sender || date">{{ sender }} <time>{{ date | date:'shortTime' }}</time></p>
<p class="sender" *ngIf="sender || date">{{ sender }} <time>{{ date | date: dateFormat }}</time></p>
<p class="text" *ngIf="message">{{ message }}</p>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -37,4 +37,10 @@ export class NbChatMessageTextComponent {
*/
@Input() date: Date;

/**
* Message send date format, default 'shortTime'
* @type {string}
*/
@Input() dateFormat: string = 'shortTime';

}
15 changes: 12 additions & 3 deletions src/framework/theme/components/chat/chat-message.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ import { NbChatMessageFile } from './chat-message-file.component';
<ng-container [ngSwitch]="type">
<nb-chat-message-file *ngSwitchCase="'file'"
[sender]="sender" [date]="date" [message]="message" [files]="files">
[sender]="sender" [date]="date" [dateFormat]="dateFormat"
[message]="message" [files]="files">
</nb-chat-message-file>
<nb-chat-message-quote *ngSwitchCase="'quote'"
[sender]="sender" [date]="date" [message]="message" [quote]="quote">
[sender]="sender" [date]="date" [dateFormat]="dateFormat"
[message]="message" [quote]="quote">
</nb-chat-message-quote>
<nb-chat-message-map *ngSwitchCase="'map'"
Expand All @@ -80,7 +82,8 @@ import { NbChatMessageFile } from './chat-message-file.component';
</nb-chat-message-map>
<nb-chat-message-text *ngSwitchDefault
[sender]="sender" [date]="date" [message]="message">
[sender]="sender" [date]="date" [dateFormat]="dateFormat"
[message]="message">
</nb-chat-message-text>
</ng-container>
</div>
Expand Down Expand Up @@ -146,6 +149,12 @@ export class NbChatMessageComponent {
*/
@Input() date: Date;

/**
* Message send date format, default 'shortTime'
* @type {string}
*/
@Input() dateFormat: string;

/**
* Array of files `{ url: 'file url', icon: 'file icon class' }`
*/
Expand Down
4 changes: 3 additions & 1 deletion src/framework/theme/components/chat/chat.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ import { NbChatMessageComponent } from './chat-message.component';
<div class="scrollable" #scrollable>
<div class="messages">
<ng-content select="nb-chat-message"></ng-content>
<p class="no-messages" *ngIf="!messages?.length">No messages yet.</p>
<p class="no-messages" *ngIf="!messages?.length">{{ noMessagesPlaceholder }}</p>
</div>
</div>
<div class="form">
Expand Down Expand Up @@ -205,6 +205,8 @@ export class NbChatComponent implements OnChanges, AfterContentInit, AfterViewIn
}
protected _status: NbComponentStatus = 'basic';

@Input() noMessagesPlaceholder: string = 'No messages yet.';

/**
* Scroll chat to the bottom of the list when a new message arrives
*/
Expand Down

0 comments on commit 7eddfe2

Please sign in to comment.