Skip to content

Commit

Permalink
feat(flex layout): added this module as a responsible layout instead …
Browse files Browse the repository at this point in the history
…of do it by myself
  • Loading branch information
Ismael Ramos committed Oct 19, 2017
1 parent ae53c78 commit e8786e9
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 72 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Live DEMO [here](http://angularexampleapp.com/)!
`npm start`

## Features
* Responsive layout
* Responsive layout (flex layout module)
* Internationalization
* Lazy loading modules
* Progress bar active, if a request is pending (events)
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@angular/common": "4.4.4",
"@angular/compiler": "4.4.4",
"@angular/core": "4.4.4",
"@angular/flex-layout": "^2.0.0-beta.9",
"@angular/forms": "4.4.4",
"@angular/http": "4.4.4",
"@angular/platform-browser": "4.4.4",
Expand Down
1 change: 1 addition & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {HttpClient, HttpClientModule} from '@angular/common/http';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {HttpLoaderFactory} from './app.translate.factory';
import {HeroTopComponent} from './heroes/hero-top/hero-top.component';
import {FlexLayoutModule} from '@angular/flex-layout';

@NgModule({
imports: [
Expand Down
14 changes: 10 additions & 4 deletions src/app/core/footer/footer.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<footer>
<span>{{ 'angularExampleApp' | translate }} 2017</span>
<div class="flex-spacer"></div>
<a href="https://angular.io/" target="_blank"><img src="assets/images/angular.svg"></a>
</footer>
<div fxFlex fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center center"
class.xs="footer-xs">
<div fxFlex="80">
<span>{{ 'angularExampleApp' | translate }} 2017</span>
</div>
<div fxFlex class="text-right" class.xs="footer-xs">
<a href="https://angular.io/" target="_blank"><img src="assets/images/angular.svg"></a>
</div>
</div>
</footer>
16 changes: 5 additions & 11 deletions src/app/core/footer/footer.component.scss
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
footer {
display: flex;
flex-wrap: wrap;
align-items: center;
padding: 8px 16px;
color: white;
height: 3.6em;
background: #3f51b5;
margin-top: 2em;
position: sticky;
top: 100%;

img {
height: 4em;
width: 25%;
}
}

@media (max-width: 360px) {
height: 50%;
text-align: center;
display: block;
padding-top: 1em;
}
.footer-xs {
text-align: center;
padding-top: 1em;
}
55 changes: 30 additions & 25 deletions src/app/core/nav/nav.component.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
<header>
<nav>
<a mat-raised-button *ngFor="let item of menuItems" routerLink="{{item.link}}">
{{item.name | uppercase}}
</a>
<div class="flex-spacer"></div>
<app-search-bar></app-search-bar>
<button mat-icon-button [matMenuTriggerFor]="matmenu">
<mat-icon>public</mat-icon>
</button>
<mat-menu #matmenu="matMenu">
<button mat-menu-item (click)="changeLanguage('en')">
<mat-icon>flag</mat-icon>
<span>
<div fxFlex fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center center">
<div fxFlex="50">
<a mat-raised-button *ngFor="let item of menuItems" routerLink="{{item.link}}">
{{item.name | uppercase}}
</a>
</div>
<div fxFlex class="text-right">
<app-search-bar></app-search-bar>
<button mat-icon-button [matMenuTriggerFor]="matmenu">
<mat-icon>public</mat-icon>
</button>
<mat-menu #matmenu="matMenu">
<button mat-menu-item (click)="changeLanguage('en')">
<mat-icon>flag</mat-icon>
<span>
English
</span>
</button>
<button mat-menu-item (click)="changeLanguage('es')">
<mat-icon>flag</mat-icon>
<span>
</button>
<button mat-menu-item (click)="changeLanguage('es')">
<mat-icon>flag</mat-icon>
<span>
Español
</span>
</button>
<button mat-menu-item (click)="changeLanguage('pt-br')">
<mat-icon>flag</mat-icon>
<span>
</button>
<button mat-menu-item (click)="changeLanguage('pt-br')">
<mat-icon>flag</mat-icon>
<span>
Português
</span>
</button>
</mat-menu>
<a class="image-icon" href="{{appConfig.repositoryURL}}" target="_blank">
<img src="assets/images/github-circle-white-transparent.svg">
</a>
</button>
</mat-menu>
<a class="image-icon" href="{{appConfig.repositoryURL}}" target="_blank">
<img src="assets/images/github-circle-white-transparent.svg">
</a>
</div>
</div>
</nav>
<section class="progress-bar">
<mat-progress-bar
Expand Down
6 changes: 5 additions & 1 deletion src/app/core/nav/nav.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
align-items: center;
padding: 8px 16px;
color: white;
height: 3em;
height: 4em;
background: #3f51b5;

.mat-raised-button {
Expand All @@ -33,6 +33,10 @@
width: 20px;
height: 20px;
}

img {
vertical-align: middle;
}
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/app/core/search-bar/search-bar.component.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
:host(app-search-bar) {
display: flex;
align-items: center;

/deep/ .mat-input-placeholder {
font-weight: 100;
color: white;
Expand Down
58 changes: 32 additions & 26 deletions src/app/heroes/hero-top/hero-top.component.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
<h1 class="section-title">{{'topHeroes' | translate}}</h1>
<mat-progress-spinner *ngIf="!heroes"
class="progress-spinner"
[color]="'primary'"
[mode]="'indeterminate'">
</mat-progress-spinner>
<div id="heroes-list" *ngIf="heroes">
<ng-container *ngFor="let hero of heroes">
<mat-card class="hero-card">
<mat-card-header>
<div mat-card-avatar class="hero-header-image"
[ngStyle]="{'background-image': 'url(assets/images/heroes/' + hero.id + '-thumbnail.jpg)'}"></div>
<mat-card-title>{{hero.name}}</mat-card-title>
<mat-card-subtitle>{{hero.alterEgo}}</mat-card-subtitle>
<div class="flex-spacer"></div>
<div class="hero-actions">
{{hero.likes}}
<mat-icon matTooltip="{{(canVote ? 'canVote' : 'cannotVote') | translate}}"
[matTooltipPosition]="'above'"
class="like-icon" (click)="like(hero)">favorite
</mat-icon>
</div>
</mat-card-header>
<img mat-card-image src="assets/images/heroes/{{hero.id}}.jpg">
</mat-card>
</ng-container>
<div fxLayout="row">
<div fxFlex="10" fxFlex.gt-sm="20"></div>
<div fxFlex="90" fxFlex.gt-sm="80">
<h1 class="section-title">{{'topHeroes' | translate}}</h1>
<mat-progress-spinner *ngIf="!heroes"
class="progress-spinner"
[color]="'primary'"
[mode]="'indeterminate'">
</mat-progress-spinner>
<div id="heroes-list" *ngIf="heroes">
<ng-container *ngFor="let hero of heroes">
<mat-card class="hero-card">
<mat-card-header>
<div mat-card-avatar class="hero-header-image"
[ngStyle]="{'background-image': 'url(assets/images/heroes/' + hero.id + '-thumbnail.jpg)'}"></div>
<mat-card-title>{{hero.name}}</mat-card-title>
<mat-card-subtitle>{{hero.alterEgo}}</mat-card-subtitle>
<div class="flex-spacer"></div>
<div class="hero-actions">
{{hero.likes}}
<mat-icon matTooltip="{{(canVote ? 'canVote' : 'cannotVote') | translate}}"
[matTooltipPosition]="'above'"
class="like-icon" (click)="like(hero)">favorite
</mat-icon>
</div>
</mat-card-header>
<img mat-card-image src="assets/images/heroes/{{hero.id}}.jpg">
</mat-card>
</ng-container>
</div>
</div>
<div fxFlex="10" fxFlex.gt-sm="20"></div>
</div>
1 change: 0 additions & 1 deletion src/app/heroes/hero-top/hero-top.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
}

.hero-card {
width: 45%;
margin: 2em auto;
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/shared/modules/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import {ModuleWithProviders, NgModule} from '@angular/core';
import {MaterialModule} from './material.module';
import {TranslateModule} from '@ngx-translate/core';
import {HeroService} from '../../heroes/shared/hero.service';
import {FlexLayoutModule} from '@angular/flex-layout';

@NgModule({
imports: [
MaterialModule,
FlexLayoutModule,
TranslateModule
],
exports: [
MaterialModule,
FlexLayoutModule,
TranslateModule
]
})
Expand Down
4 changes: 4 additions & 0 deletions src/assets/css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ snack-bar-container {
height: 55px !important;
width: 55px !important;
}

.text-right {
text-align: right;
}

0 comments on commit e8786e9

Please sign in to comment.