Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Commit

Permalink
Merge pull request #222 from ashwin-sureshkumar/issue-10
Browse files Browse the repository at this point in the history
Implement showcase of companies using RxJS
  • Loading branch information
ladyleet authored Dec 29, 2017
2 parents a6affdc + 8c5164c commit 5059b48
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 8 deletions.
16 changes: 16 additions & 0 deletions src/app/companies/companies-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Company } from './companies.model';

export const COMPANIES_LIST: Company[] = [
{
name: 'Google',
location: 'California',
logo: '../../assets/companies/google.png',
website: 'http://google.com'
},
{
name: 'Microsoft',
location: 'Seattle',
logo: '../../assets/companies/microsoft.png',
website: 'http://microsoft.com'
}
];
20 changes: 20 additions & 0 deletions src/app/companies/companies.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
<div fxLayout="row" fxLayoutAlign="space-evenly center" fxLayoutGap="10px" fxLayoutWrap class="companies-container">
<mat-card *ngFor="let company of companies | async" fxFlex.xs="100" fxFlex.sm="45" fxFlex.md="30" fxFlex.lg="23">
<mat-card-header>
<div mat-card-avatar>
<img [src]="company.logo" class="company-logo">
</div>
<mat-card-title>{{company.name}}</mat-card-title>
<mat-card-subtitle>
{{company.location}}
<a class="website-button" mat-icon-button aria-label="website" [href]="company.website" target="_blank">
<mat-icon>
link
</mat-icon>
</a>
</mat-card-subtitle>
</mat-card-header>
<mat-card-content>

</mat-card-content>
</mat-card>
</div>
27 changes: 27 additions & 0 deletions src/app/companies/companies.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.example-header-image {
background-image: url('../../assets/img/Rx_Logo-96-96.png');
background-size: cover;
}

.companies-container {
margin: 0 15px;
}

.website-button {
position: absolute;
right: 0;
top: 0;
}

mat-card {
margin-top: 15px;
}

mat-card-avatar {
margin-right: 10px;
}

.company-logo{
height: 40px;
width: 40px;
}
13 changes: 11 additions & 2 deletions src/app/companies/companies.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { Component } from '@angular/core';
import { COMPANIES_LIST } from './companies-list';
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { MatDialog } from '@angular/material';

import { CompanyService } from './company.service';
import { Company } from './companies.model';

@Component({
selector: 'app-companies',
templateUrl: './companies.component.html',
styleUrls: ['./companies.component.scss']
})
export class CompaniesComponent {
constructor() {}
companies: Observable<Company[]>;
constructor(private companyService: CompanyService) {
this.companies = this.companyService.getCompanies();
}
}
6 changes: 6 additions & 0 deletions src/app/companies/companies.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface Company {
name: string;
location: string;
website: string;
logo: string;
}
11 changes: 8 additions & 3 deletions src/app/companies/companies.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { CommonModule } from '@angular/common';
import { MaterialModule } from './../material/material.module';
import { NgModule } from '@angular/core';

import { CompaniesComponent } from './companies.component';
import { CompaniesRoutingModule } from './companies-routing.module';

import { environment } from '../../environments/environment';
import { CompanyService } from './company.service';
@NgModule({
imports: [CompaniesRoutingModule],
declarations: [CompaniesComponent]
imports: [CommonModule, CompaniesRoutingModule, MaterialModule],
declarations: [CompaniesComponent],
providers: [CompanyService]
})
export class CompaniesModule {}
20 changes: 20 additions & 0 deletions src/app/companies/company.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { TestBed, inject } from '@angular/core/testing';

import { CompanyService } from './company.service';
import { environment } from '../../environments/environment';

describe('CompanyService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [],
providers: [CompanyService]
});
});

it(
'should be created',
inject([CompanyService], (service: CompanyService) => {
expect(service).toBeTruthy();
})
);
});
12 changes: 12 additions & 0 deletions src/app/companies/company.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { COMPANIES_LIST } from './companies-list';
import { Company } from './companies.model';

@Injectable()
export class CompanyService {
getCompanies(): Observable<Company[]> {
return of(COMPANIES_LIST);
}
}
8 changes: 5 additions & 3 deletions src/app/material/material.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { FlexLayoutModule } from '@angular/flex-layout';
import {
MatToolbarModule,
MatIconModule,
MatButtonModule,
MatListModule,
MatSidenavModule,
MatButtonModule,
MatExpansionModule,
MatCardModule,
MatInputModule,
Expand All @@ -20,27 +20,29 @@ import {
imports: [
MatToolbarModule,
MatIconModule,
MatButtonModule,
MatListModule,
MatSidenavModule,
MatButtonModule,
MatExpansionModule,
MatCardModule,
MatInputModule,
MatMenuModule,
MatTooltipModule,
FlexLayoutModule,
MatSnackBarModule
],
exports: [
MatToolbarModule,
MatIconModule,
MatButtonModule,
MatListModule,
MatSidenavModule,
MatButtonModule,
MatExpansionModule,
MatCardModule,
MatInputModule,
MatMenuModule,
MatTooltipModule,
FlexLayoutModule,
MatSnackBarModule
]
})
Expand Down
Binary file added src/assets/companies/google.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/companies/microsoft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5059b48

Please sign in to comment.