Skip to content

Commit

Permalink
(feat) : Homepage layout
Browse files Browse the repository at this point in the history
Static layout for the home page with image and header
  • Loading branch information
hemantjadon committed Oct 2, 2016
1 parent e31de7c commit 43f0a17
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e/app.po.ts
Expand Up @@ -6,6 +6,6 @@ export class LoklakSearchPage {
}

getHeaderText() {
return element(by.css('app-root app-home h1')).getText();
return element(by.css('app-root app-home div.wrapper h1')).getText();
}
}
5 changes: 4 additions & 1 deletion src/app/home/home.component.html
@@ -1 +1,4 @@
<h1>{{header}}</h1>
<div class="wrapper">
<img src="{{headerImageUrl}}" alt="Loklak Cow" width="200" height="233">
<h1>{{header}}</h1>
</div>
19 changes: 19 additions & 0 deletions src/app/home/home.component.scss
@@ -0,0 +1,19 @@
:host{
width: 100%;
height: 100%;
display: flex;
justify-content: space-around;
align-items: center;
}

div.wrapper{
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;

h1{
font-weight: 300;
text-align: center;
}
}
23 changes: 22 additions & 1 deletion src/app/home/home.component.spec.ts
Expand Up @@ -28,6 +28,27 @@ describe('Component: Home', () => {
let fixture = TestBed.createComponent(HomeComponent);
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toBe('Loklak Search!');
expect(compiled.querySelector('div.wrapper h1').textContent).toBe('Loklak Search!');
}));

it('should have a correct headerImageUrl property', () => {
let fixture = TestBed.createComponent(HomeComponent);
let component = fixture.debugElement.componentInstance;
expect(component.headerImageUrl).toBe('assets/images/cow_200x233.png');
});

it('should render header cow image correctly', async(() => {
let fixture = TestBed.createComponent(HomeComponent);
fixture.detectChanges();
let component = fixture.debugElement.componentInstance;
let compiled = fixture.debugElement.nativeElement;

let image: HTMLImageElement = compiled.querySelector('div.wrapper img');

let imgSrc: string = image.src;
let relativePath: string = imgSrc.replace(window.location.origin + '/', ''); // Removing the host and port from the image source

expect(relativePath).toBe(component.headerImageUrl);
expect(image.alt).toBe('Loklak Cow'); // Correct alt text 'Loklak Cow' must be present.
}));
});
1 change: 1 addition & 0 deletions src/app/home/home.component.ts
Expand Up @@ -7,6 +7,7 @@ import { Component, OnInit } from '@angular/core';
})
export class HomeComponent implements OnInit {
private header: string = 'Loklak Search!';
private headerImageUrl: string = 'assets/images/cow_200x233.png';

constructor() { }

Expand Down
Binary file added src/assets/images/cow_200x233.png
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/images/cow_400x466.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion src/styles.scss
@@ -1 +1,11 @@
/* You can add global styles to this file, and also import other style files */
/* You can add global styles to this file, and also import other style files */

body{
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
background: #fafafa;
font-family: Roboto, Arial, Helvetica, sans-serif;
font-family: Iconsolata, monospace;
}

0 comments on commit 43f0a17

Please sign in to comment.