Skip to content

Commit

Permalink
feat(theme): add new Chat UI components set
Browse files Browse the repository at this point in the history
  • Loading branch information
nnixaa authored Jun 25, 2018
1 parent f76ce1f commit ebfcd0e
Show file tree
Hide file tree
Showing 38 changed files with 2,526 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { InjectionToken, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {
NbThemeModule,
NbSidebarModule,
Expand All @@ -29,6 +30,7 @@ const docs = require('../output.json');
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
HttpClientModule,
NbSidebarModule,
Expand Down
26 changes: 26 additions & 0 deletions docs/assets/images/components/chat-ui.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ export const structure = [
'NbRouteTabsetComponent',
],
},
{
type: 'tabs',
name: 'Chat UI',
icon: 'chat-ui.svg',
source: [
'NbChatComponent',
'NbChatMessageComponent',
'NbChatFormComponent',
],
},
{
type: 'tabs',
name: 'Actions',
Expand Down
77 changes: 77 additions & 0 deletions e2e/chat.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { browser, element, by } from 'protractor';
import { colors, chatSizes as sizes } from './component-shared';
import { waitFor } from './e2e-helper';

let chats: any[] = [];

function prepareChats() {
const result: any[] = [];

let elementNumber: number = 1;
for (const { colorKey, color } of colors) {
for (const { sizeKey, height } of sizes) {
result.push({
size: sizeKey,
height: height,
colorKey,
color,
elementNumber,
});
elementNumber++;
}
}

return result;
}

describe('nb-chat', () => {

chats = prepareChats();

beforeEach((done) => {
browser.get('#/chat/chat-test.component').then(() => done());
});

chats.forEach(c => {

it(`should display ${c.colorKey} chat with ${c.size} size`, () => {
waitFor(`nb-chat:nth-child(${c.elementNumber})`);

element(by.css(`nb-chat:nth-child(${c.elementNumber})`)).getCssValue('height').then(height => {
expect(height).toEqual(c.height);
});

element(by.css(`nb-chat:nth-child(${c.elementNumber}) .header`))
.getCssValue('background-color').then(bgColor => {
expect(bgColor).toEqual(c.color);
});
});
});

it('should add on message', () => {
const all: any = element.all(by.css('nb-chat:nth-child(1) nb-chat-message'));
all.count().then(allCount => {
element(by.css('nb-chat:nth-child(1) nb-chat-form input')).sendKeys('akveo');
element(by.css('nb-chat:nth-child(1) nb-chat-form .btn')).click();
expect(all.count()).toEqual(allCount + 1);
});
});

it('should not add on an empty message', () => {
const all: any = element.all(by.css('nb-chat:nth-child(1) nb-chat-message'));
all.count().then(allCount => {
element(by.css('nb-chat:nth-child(1) nb-chat-form .btn')).click();
expect(all.count()).toEqual(allCount);

element(by.css('nb-chat:nth-child(1) nb-chat-form input')).sendKeys(' ');
element(by.css('nb-chat:nth-child(1) nb-chat-form .btn')).click();
expect(all.count()).toEqual(allCount);
});
});
});
2 changes: 2 additions & 0 deletions e2e/component-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export const colors = [
{ colorKey: 'default', color: hexToRgbA('#a4abb3') },
{ colorKey: 'disabled', color: 'rgba(255, 255, 255, 0.4)' },
];

export const chatSizes = cardSizes;
28 changes: 21 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NbThemeModule } from '@nebular/theme';

import { NbAppComponent } from './app.component';
import { NbLayoutDirectionToggleComponent } from './layout-direction-toggle/layout-direction-toggle.component';
import { NbDynamicToAddComponent } from '../playground/shared/dynamic.component';
import { NbPlaygroundSharedModule } from '../playground/shared/shared.module';


@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
HttpClientModule,
RouterModule.forRoot([
Expand Down
Loading

0 comments on commit ebfcd0e

Please sign in to comment.