Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPTJAN2024-DIEGO GUAMAN #2995

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,43 @@ app.set('views', path.join(__dirname, 'views'));
app.use(express.static(path.join(__dirname, 'public')));

// Register the location for handlebars partials here:

hbs.registerPartials(path.join(__dirname, '/views/partials'));
// ...

// Add the route handlers here:

app.get('/', (req, res) => {
res.render('index');
});
app.get('/beers', (req, res) => {
punkAPI
.getBeers()
.then(beersFromApi => {
console.log('Beers from the database: ', beersFromApi)
res.render('beers', {beers: beersFromApi});
})
.catch(error => console.log(error));

});
app.get('/beers/beer', (req, res) => {
punkAPI
.getBeer(1)
.then(responseFromAPI => {
const beerId = responseFromAPI;
res.render('random-beer', {beerId: beerId});
})
.catch(error => console.log(error));

});
app.get('/random-beer', (req, res) => {
punkAPI
.getRandom()
.then(responseFromAPI => {
const randomBeer = responseFromAPI[0];
res.render('random-beer', {beer: randomBeer});
})
.catch(error => console.log(error));

});

app.listen(3000, () => console.log('🏃‍ on port 3000'));
131 changes: 131 additions & 0 deletions public/stylesheets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,134 @@ dark-blue: #0a2c42;
grey: #bfbfbf;
font-family: Arial, Helvetica, sans-serif;
*/
/* -------------PARTIAL CARD-------------*/
.card{
width: 32%;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 10px;
}
.card img{
height: 180px;
object-fit: cover;
margin-bottom: 10px;
}
.card .title-card{
font-size: 0.9em;

}
.card .tag-line{
font-size: 0.7em;
color: #bfbfbf;

}
.card .text-description-card{
font-size: 0.7em;
margin-top: 10px;
}

/* -------------FIN PARTIAL CARD-------------*/

/* -------------BEERS PAGE-------------*/
.beers-section{
width: 85%;
margin: 0 auto;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: space-between;
margin-top: 85px;
margin-bottom: 80px;
}
/* -------------FIN BEERS PAGE-------------*/

/* -------------LAYOUT -------------*/
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background-color: #f7f9f9;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
}
a{
text-decoration: none;
color: #f7f9f9;
text-align: center;
margin-right: 20px;
font-weight: 600;
transition: all .3s ease;
}
a:hover{
color: #bfbfbf;
}
.nav-bar{
position: fixed;
top: 0;
left: 0;
width: 100%;
padding: 20px 50px;
background-color: #2081c3;
}

.footer{
width: 100%;
color: #f7f9f9;
background-color: #0a2c42;
padding: 20px 20px;
position: fixed;
bottom: 0;
left: 0;
}
/* -------------FIN LAYOUT -------------*/

/* -------------INDEX-HOME-------------*/
.main-section{
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.section-content{
height: 600px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 50px;
}
.main-section .section-content img{
width: 350px;
margin-bottom: 30px;
}
.main-section .section-content a{
background-color: #2081c3;
padding: 10px 20px;
margin-top: 20px;
border-radius: 5px;
border: 1px solid #2081c3;
transition: all .4s ease;
}
.main-section .section-content a:hover{
color: #2081c3;
background-color: #f7f9f9;

}

/* -------------FIN INDEX-HOME-------------*/

/* -------------RANDOM BEERS PAGE-------------*/
.container-beer{
width: 85%;
margin: 0 auto;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: space-between;
margin-top: 85px;
margin-bottom: 80px;
}
/* -------------FIN RANDOM BEERS PAGE-------------*/
5 changes: 5 additions & 0 deletions views/beers.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="beers-section">
{{#each beers}}
{{> beerpartial this}}
{{/each}}
</div>
10 changes: 7 additions & 3 deletions views/index.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div>

</div>
<section class="main-section">
<div class="section-content">
<img src="/images/beer.png" alt="beer-img">
<a href="/beers">Check the Beers!</a>
<a href="/random-beer">Check a Random Beer!</a>
</div>
</section>
20 changes: 20 additions & 0 deletions views/layout.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="/stylesheets/styles.css">
</head>
<body>
<nav class="nav-bar">
<a href="/">Home</a>
<a href="/beers">Beers</a>
<a href="/random-beer">Ranbom Beer</a>
</nav>
{{{body}}}
<footer class="footer">
Debeloped by Ironhack ;)
</footer>
</body>
</html>
17 changes: 17 additions & 0 deletions views/partials/beerpartial.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="card">
<img src="{{this.image_url}}" alt="">
<div class="card-body">
<h4 class="title-card">
<a href="/beers/beer">

</a>
{{this.name}}
</h4>
<h5 class="tag-line">
{{this.tagline}}
</h5>
<p class="text-description-card">
{{this.description}}
</p>
</div>
</div>
25 changes: 25 additions & 0 deletions views/random-beer.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div class="container-beer">
<a href="">{{beerId}}</a>
<div class="image-left">
<img src="{{beer.image_url}}" alt="">
</div>
<div class="text-content-right">
<h4 class="title-card">
<a href="/beers/beer">

</a>
{{beer.name}}
</h4>
<h5 class="tag-line">
{{beer.tagline}}
</h5>
<p class="text-description-card">
{{beer.description}}
</p>
</div>
</div>