Skip to content

Commit

Permalink
Merge pull request #17 from mihaiborbea/improve-responsive-design
Browse files Browse the repository at this point in the history
Improve responsive design
  • Loading branch information
mihaiborbea authored Sep 21, 2021
2 parents 517d6e2 + fd3b8d5 commit 98e2cab
Show file tree
Hide file tree
Showing 15 changed files with 261 additions and 106 deletions.
5 changes: 1 addition & 4 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
mat-sidenav-container,
mat-sidenav-content,
mat-sidenav {
height: 100%;
height: 100vh;
}
mat-sidenav {
width: 250px;
}
main {
padding: 20px;
}
96 changes: 63 additions & 33 deletions src/app/layout/header/header.component.html
Original file line number Diff line number Diff line change
@@ -1,38 +1,68 @@
<mat-toolbar color="primary">
<div fxHide.gt-xs *ngIf="isAuthenticated">
<button mat-icon-button (click)="onToggleSidenav()">
<mat-icon>menu</mat-icon>
</button>
</div>
<div class="navbar-brand">
<a routerLink="/">
<img
src="../../../assets/logo/brand-logo-mono-white.png"
class="brand-logo"
/>
</a>
</div>
<div fxFlex fxLayout fxLayoutAlign="start" fxHide.xs>
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<li routerLinkActive="active" *ngIf="isAuthenticated">
<a routerLink="/recipes">My Recipes</a>
</li>
<li routerLinkActive="active" *ngIf="isAuthenticated">
<a routerLink="/shopping-list">Shopping List</a>
</li>
</ul>
</div>
<div fxFlex fxLayout fxLayoutAlign="end" fxHide.xs *ngIf="isAuthenticated">
<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="$event.stopPropagation()">
<app-theme-switch></app-theme-switch>
<div
fxLayout="row"
fxLayoutAlign.xs="start center"
fxLayoutAlign="center center"
fxFlexFill
class="full-width"
>
<div
fxFlex="10"
fxLayoutAlign="start center"
fxHide.gt-xs
*ngIf="isAuthenticated"
>
<button mat-icon-button (click)="onToggleSidenav()">
<mat-icon>menu</mat-icon>
</button>
<button mat-menu-item (click)="onLogout()">
<span>Logout</span>
</div>
<div
fxFlex.lt-sm="90"
fxFlex.xs="10"
fxLayoutAlign="start center"
class="navbar-brand"
>
<a routerLink="/">
<img
src="../../../assets/logo/brand-logo-mono-white.png"
class="brand-logo"
/>
</a>
</div>
<div
fxFlex="80"
fxLayoutAlign.lt-xl="start center"
fxLayoutAlign.xl="center center"
fxHide.xs
>
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<li *ngIf="isAuthenticated">
<a routerLink="/recipes" routerLinkActive="active">My Recipes</a>
</li>
<li *ngIf="isAuthenticated">
<a routerLink="/shopping-list" routerLinkActive="active"
>Shopping List</a
>
</li>
</ul>
</div>
<div
fxFlex="10"
fxLayoutAlign="end center"
fxHide.xs
*ngIf="isAuthenticated"
>
<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon>more_vert</mat-icon>
</button>
</mat-menu>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="$event.stopPropagation()">
<app-theme-switch></app-theme-switch>
</button>
<button mat-menu-item (click)="onLogout()">
<span>Logout</span>
</button>
</mat-menu>
</div>
</div>
</mat-toolbar>
2 changes: 1 addition & 1 deletion src/app/layout/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ a:active {
color: white;
}
.navigation-items a:hover,
a:active {
.navigation-items a:active {
color: lightgray;
}
88 changes: 45 additions & 43 deletions src/app/recipes/recipe-detail/recipe-detail.component.html
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
<div fxLayout="row">
<div fxLayout="column" fxFlex="80" fxFlex.lt-md="100">
<h1>{{ recipe.name }}</h1>
<div class="container">
<div fxLayout="row">
<div fxLayout="column" fxFlexFill fxFlex.lt-md="100">
<h1>{{ recipe.name }}</h1>
</div>
</div>
</div>
<div fxLayout="row">
<div fxLayout="column" fxFlexFill class="img-canvas">
<img [src]="recipe.imagePath" alt="" [ngClass.gt-sm]="'img-fluid'" />
<div fxLayout="row">
<div fxLayout="column" fxFlexFill class="img-canvas">
<img [src]="recipe.imagePath" alt="" [ngClass.gt-sm]="'img-fluid'" />
</div>
</div>
</div>
<div fxLayout="row">
<div fxLayout="column">
<button
mat-raised-button
color="primary"
type="button"
[matMenuTriggerFor]="recipeMenu"
>
Manage Recipe <mat-icon>expand_more</mat-icon>
</button>
<mat-menu #recipeMenu="matMenu">
<button mat-menu-item (click)="onAddToShoppingList()">
<span>Add to Shopping List</span>
</button>
<button mat-menu-item (click)="onEditRecipe()">
<span>Edit Recipe</span>
<div fxLayout="row">
<div fxLayout="column">
<button
mat-raised-button
color="primary"
type="button"
[matMenuTriggerFor]="recipeMenu"
>
Manage Recipe <mat-icon>expand_more</mat-icon>
</button>
<button mat-menu-item (click)="onDeleteRecipe()">
<span>Delete Recipe</span>
</button>
</mat-menu>
<mat-menu #recipeMenu="matMenu">
<button mat-menu-item (click)="onAddToShoppingList()">
<span>Add to Shopping List</span>
</button>
<button mat-menu-item (click)="onEditRecipe()">
<span>Edit Recipe</span>
</button>
<button mat-menu-item (click)="onDeleteRecipe()">
<span>Delete Recipe</span>
</button>
</mat-menu>
</div>
</div>
</div>
<br />
<div fxLayout="row">
<div fxLayout="column" fxFlex="80" fxFlex.lt-md="100">
<p>{{ recipe.description }}</p>
<br />
<div fxLayout="row">
<div fxLayout="column" fxFlexFill fxFlex.lt-md="100">
<p>{{ recipe.description }}</p>
</div>
</div>
</div>
<br />
<div fxLayout="row">
<div fxLayout="column" fxFlex="80" fxFlex.lt-md="100">
<mat-list>
<mat-list-item *ngFor="let ingredient of recipe.ingredients">
{{ ingredient.name }} - {{ ingredient.amount }}
<mat-divider></mat-divider>
</mat-list-item>
</mat-list>
<br />
<div fxLayout="row">
<div fxLayout="column" fxFlexFill fxFlex.lt-md="100">
<mat-list>
<mat-list-item *ngFor="let ingredient of recipe.ingredients">
{{ ingredient.name }} - {{ ingredient.amount }}
<mat-divider></mat-divider>
</mat-list-item>
</mat-list>
</div>
</div>
</div>
6 changes: 5 additions & 1 deletion src/app/recipes/recipe-detail/recipe-detail.component.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.img-fluid {
max-width: 80%;
max-width: 100%;
}

.img-canvas {
margin-bottom: 15px;
}

.container {
padding-bottom: 20px;
}
4 changes: 2 additions & 2 deletions src/app/recipes/recipe-edit/recipe-edit.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div fxLayout="row">
<div fxLayout="column" fxFlex="80" fxFlex.lt-md="100">
<div fxLayout="row" class="container">
<div fxLayout="column" fxFlexFill fxFlex.lt-md="100">
<form [formGroup]="recipeForm" (ngSubmit)="onSubmit()">
<div fxLayout="row">
<button
Expand Down
6 changes: 5 additions & 1 deletion src/app/recipes/recipe-edit/recipe-edit.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ mat-divider {
}

.img-fluid {
max-width: 80%;
max-width: 100%;
}

.container {
padding-bottom: 20px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
<span>{{ recipe.name }}</span>
</mat-card-title>
</mat-card-header>
<mat-card-content fxLayout="row" fxLayoutAlign="start center">
<span>{{ recipe.description | truncate }}</span>
<mat-card-content fxLayout="row" fxLayoutAlign="start start">
<div class="description">
<span>{{ recipe.description }}</span>
</div>
<img mat-card-image [src]="recipe.imagePath" [alt]="recipe.name" />
</mat-card-content>
</mat-card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ mat-card {

mat-card-content {
height: 120px;
overflow: hidden;
}

.mat-card-image {
margin-left: auto;
margin-right: 0;
height: 90%;
max-width: 30%;
width: 30%;
}

.description {
height: calc(1.5rem * 5);
overflow: hidden;
width: 70%;
}

:host ::ng-deep .mat-card-header-text {
Expand Down
27 changes: 19 additions & 8 deletions src/app/recipes/recipes.component.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
<div fxLayout.gt-sm="row" fxLayout.lt-md="column" fxLayoutGap="30px">
<div fxLayout="column" fxFlexFill fxFlex.gt-sm="40" [fxHide.lt-md]="hideList">
<app-recipe-list></app-recipe-list>
</div>
<div
fxLayout.gt-sm="row"
fxLayoutAlign.gt-sm="center start"
fxLayoutAlign.lt-md="center center"
fxLayout.lt-md="column"
fxLayoutGap="30px"
class="container"
>
<div
fxLayout="column"
fxLayoutAlign="start start"
fxHide
[fxShow.lt-md]="hideList"
[fxHide.lt-md]="hideList"
[ngClass.lt-md]="'full-width'"
class="list-container"
>
<app-recipe-list></app-recipe-list>
</div>
<div fxLayout="column" fxFlexAlign="start" fxHide [fxShow.lt-md]="hideList">
<button mat-icon-button color="accent" routerLink="/recipes">
<mat-icon>arrow_back</mat-icon> Back
</button>
</div>
<div fxLayout="column" fxFlexFill fxFlex.gt-sm="60">
<div
fxLayout="column"
[ngClass.lt-md]="'full-width'"
class="detail-container"
>
<router-outlet></router-outlet>
</div>
</div>
17 changes: 17 additions & 0 deletions src/app/recipes/recipes.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.container {
margin: 0 25px 25px 25px;
}

.list-container {
width: 40%;
max-width: 640px;
}

.detail-container {
width: 60%;
max-width: 960px;
}

.full-width {
width: 100% !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ button {
mat-form-field:not(:last-child) {
margin-right: 10px;
}
@media (max-width: 959px) {
mat-form-field:not(:last-child) {
margin-right: 0px;
}
}
14 changes: 6 additions & 8 deletions src/app/shopping-list/shopping-list.component.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<div
fxLayout="row"
fxLayoutAlign.lt-lg="center center"
fxLayoutAlign.lg="start center"
>
<div class="container top" fxLayout="row" fxLayoutAlign="center center">
<div
class="container"
fxLayout="column"
fxFlex.lt-md="90"
fxFlex.md="80"
fxFlex.gt-md="60"
fxFlex.xl="50"
>
<app-shopping-edit></app-shopping-edit>
<br />
<mat-selection-list #list [multiple]="false">
<div class="edit-container">
<app-shopping-edit></app-shopping-edit>
</div>
<mat-selection-list #list [multiple]="false" class="scrollbar">
<div
*ngFor="
let ingredient of (shoppingList$ | async)?.ingredients;
Expand Down
Loading

0 comments on commit 98e2cab

Please sign in to comment.