Skip to content

Commit

Permalink
Search view in home page #13
Browse files Browse the repository at this point in the history
  • Loading branch information
donia98 committed Oct 3, 2018
1 parent 9bed6cd commit 7fad92d
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 2 deletions.
73 changes: 73 additions & 0 deletions public/css/home.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

.container {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
}

.card {
margin: 7px;
border-radius: 10px;
border: 2px solid #DCDCDC;
position: relative;
}



.card:hover .overlay {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0,0,0,0.5);
z-index:100;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
border-radius: 10px;
}

.overlay .hidden {
display: none;
}

.card:hover .hidden {
display: flex;
margin: 10px;
width: 150px;
height: 30px;
color: #FFFFFF;
border: 0;
text-align: center;
justify-content: center;

}

.image {
border-radius: 10px 10px 0 0;
border: 1px solid #DCDCDC;
width: 300px;
}

.card:hover #book-btn {
background-color: #00C2FF;
}

.card:hover #view-btn {
background-color: #787878;
}
.info {
display: flex;
justify-content: space-between;
}
.search-view h2 {
padding: 20px;
padding-left: 35px;
font-family: 'Lato', sans-serif;
font-size: 30px;
}
Binary file added public/room.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 103 additions & 0 deletions src/controllers/home.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,109 @@
const data = [
{
id: 1,
room_num: 2,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'single',
},
{
id: 1,
room_num: 2,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'single',
},
{
id: 1,
room_num: 2,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'single',
},
{
id: 1,
room_num: 2,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'single',
},
{
id: 1,
room_num: 2,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'single',
},
{
id: 1,
room_num: 2,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'single',
},
{
id: 1,
room_num: 2,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'single',
},
{
id: 2,
room_num: 3,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'single',
},
{
id: 3,
room_num: 4,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'double',
},
{
id: 4,
room_num: 5,
description: 'nice room',
price: 500,
imgs: 'room.jpg',
services: 'some servieces',
type: 'triple',
},
];

exports.get = (req, res) => {
// filter the data based on the room type
const filteredData = {
single: data.filter(room => room.type === 'single'),
double: data.filter(room => room.type === 'double'),
triple: data.filter(room => room.type === 'triple'),
};

res.render('home', {
style: 'style',
style_special: 'home',
title: 'Home',
script: 'home',
data: filteredData,
});
};
69 changes: 67 additions & 2 deletions src/views/home.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
<section>

<section class="home-body">
{{#if data.single}}
<div class="search-view">
<h2>Single :</h2>
<div class="container">
{{#each data.single}}
<div class="card">
<div class="img">
<div class="overlay">
<button class="hidden" id="book-btn" type="button" name="button">Book</button>
<button class="hidden" id="view-btn" type="button" name="button">View more</button>
</div>
<img class="image" src="{{imgs}}" alt="room img">
</div>
<div class="info">
<span>Price : {{price}}$</span>
<span>Room No. : {{room_num}}</span>
</div>
</div>
{{/each}}
</div>
</div>
{{/if}}
{{#if data.double}}
<div class="search-view">
<h2>Double :</h2>
<div class="container">
{{#each data.double}}
<div class="card">
<div class="img">
<div class="overlay">
<button class="hidden" id="book-btn" type="button" name="button">Book</button>
<button class="hidden" id="view-btn" type="button" name="button">View more</button>
</div>
<img class="image" src="{{imgs}}" alt="room img">
</div>
<div class="info">
<span>Price : {{price}}$</span>
<span>Room No. : {{room_num}}</span>
</div>
</div>
{{/each}}
</div>
</div>
{{/if}}
{{#if data.triple}}
<div class="search-view">
<h2>Trible :</h2>
<div class="container">
{{#each data.triple}}
<div class="card">
<div class="img">
<div class="overlay">
<button class="hidden" id="book-btn" type="button" name="button">Book</button>
<button class="hidden" id="view-btn" type="button" name="button">View more</button>
</div>
<img class="image" src="{{imgs}}" alt="room img">
</div>
<div class="info">
<span>Price : {{price}}$</span>
<span>Room No. : {{room_num}}</span>
</div>
</div>
{{/each}}
</div>
</div>
{{/if}}
</section>
3 changes: 3 additions & 0 deletions src/views/partials/head.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
{{#if style}}
<link rel="stylesheet" href="css/{{style}}.css">
{{/if}}
{{#if style_special}}
<link rel="stylesheet" href="css/{{style_special}}.css">
{{/if}}
<title>{{title}}</title>

0 comments on commit 7fad92d

Please sign in to comment.