Skip to content

Commit 12c3d60

Browse files
committed
implementaòàao jQuery da pèagina produto
1 parent f4661fb commit 12c3d60

4 files changed

Lines changed: 102 additions & 7 deletions

File tree

‎.vscode/settings.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"liveServer.settings.port": 5501
3+
}

‎css/style.css‎

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ h1,h2,h3,h4,h5,h6, blockquote, figcaption {
2929
line-height: 1.17em;
3030
padding: 8px 0;
3131
}
32+
.mobile_only{
33+
display: none;
34+
}
3235
.clear{
3336
clear: both;
3437
}
@@ -399,10 +402,10 @@ main.product article.container{
399402
margin-top: 130px;
400403
}
401404
main.product figure, .add-to-cart{
402-
width: 49%;
405+
width: 48.75%;
403406
}
404407
main.product figure{
405-
margin-right: 2%;
408+
margin-right: 2.5%;
406409
}
407410

408411
main.product figure img{
@@ -411,7 +414,7 @@ main.product figure img{
411414
main.product figure img:hover{
412415
filter: saturate(200%) contrast(110%);;
413416
}
414-
.add-to-cart h2, .add-to-cart h3{
417+
.add-to-cart h2, .add-to-cart h3, h2.mobile_only{
415418
font-size: 26px;
416419
line-height: 57.6px;
417420
letter-spacing: -.9px;
@@ -452,6 +455,17 @@ main.product figure h3{
452455
height: 30px;
453456
border: 1px solid var(--green);
454457
}
458+
.left-column .counter p:first-child, .left-column .counter p:last-child{
459+
color: var(--green);
460+
cursor: pointer;
461+
}
462+
p.alert-negative, p.alert-out{
463+
display:none;
464+
font-size: 12px;
465+
color: #d00;
466+
line-height: 14px;
467+
margin-top: 5px;
468+
}
455469
.right-column{
456470
width: 350px;
457471
float: left;
@@ -461,9 +475,12 @@ main.product figure h3{
461475
display: flex;
462476
align-items: center;
463477
flex-wrap: wrap;
464-
border: 1px solid var(--green);
465478
border-radius: 4px;
466479
padding: 20px 10px 20px 20px ;
480+
border: 1px solid rgb(161, 161, 161, 0);
481+
}
482+
.right-column div.active{
483+
border: 1px solid rgb(161, 161, 161);
467484
}
468485
.right-column div p, .right-column div p a{
469486
font: 400 14px/15.6px "Helvetica", Arial, sans-serif;
@@ -520,6 +537,9 @@ main.product figure h3{
520537

521538

522539
@media screen and (max-width: 376px){
540+
.mobile_only {
541+
display: block;
542+
}
523543
/* HEADER SECTION */
524544
.container{
525545
margin: 0 15px;
@@ -738,4 +758,33 @@ main.product figure h3{
738758
flex-wrap: wrap;
739759
justify-content: center;
740760
}
761+
762+
763+
/* PÁGINA PRODUTO*/
764+
.add-to-cart h2{
765+
display: none;
766+
}
767+
main.product article.container{
768+
flex-flow: column;
769+
}
770+
main.product figure, .add-to-cart{
771+
width: 100%;
772+
}
773+
main.product figcaption, main.product figure h3{
774+
display: none;
775+
}
776+
.left-column {
777+
width: 100%;
778+
display: flex;
779+
}
780+
.left-column h3{
781+
width: 50%;
782+
}
783+
.add-to-cart button{
784+
width: 100%;
785+
margin-top: 67px;
786+
margin-left: unset;
787+
font-size: 20px;
788+
line-height: 23px;
789+
}
741790
}

‎js/script.js‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,42 @@ $(function(){
66
$(".m-hide").removeClass("m-hide");
77
$(".see_more").addClass("active");
88
});
9-
});
9+
10+
//Counter
11+
let quantity = $(".counter p:nth-of-type(2)");
12+
13+
$(".counter p:first-child").on("click", function(){
14+
if(quantity.text() > 0){
15+
let contagem = parseInt(quantity.text());
16+
quantity.text(contagem - 1);
17+
$("p.alert-out").css("display","none")
18+
$(".left-column .counter").css("border", "1px solid var(--green)");
19+
$(".counter p:nth-of-type(2)").css("color", "var(--black)");
20+
} else if (quantity.text() == 0){
21+
$("p.alert-negative").css("display","block");
22+
$(".left-column .counter").css("border", "1px solid #d00");
23+
$(".counter p:nth-of-type(2)").css("color", "#d00");
24+
};
25+
});
26+
$(".counter p:last-child").on("click", function(){
27+
if(quantity.text() < 10){
28+
let contagem = parseInt(quantity.text());
29+
quantity.text(contagem + 1);
30+
$("p.alert-negative").css("display","none");
31+
$(".left-column .counter").css("border", "1px solid var(--green)");
32+
$(".counter p:nth-of-type(2)").css("color", "var(--black)");
33+
} else if (quantity.text() == 10){
34+
$("p.alert-out").css("display","block")
35+
$(".left-column .counter").css("border", "1px solid #d00");
36+
$(".counter p:nth-of-type(2)").css("color", "#d00");
37+
};
38+
});
39+
//END COUNTER
40+
41+
//outline select purchese area
42+
43+
$(".right-column div").on("click", function(){
44+
$(".right-column div").removeClass("active");
45+
$(this).addClass("active");
46+
});
47+
});

‎product_1.html‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ <h1><a href="/"><img src="img/logo.png" alt="Brand Logo"></a></h1>
3737

3838
<main class="product">
3939
<article class="container">
40+
<h2 class="mobile_only">Spiced Mint Candleaf®</h2>
4041
<figure>
4142
<img src="img/candle_product.png" alt="Spiced Mint Candleaf® foto expositiva">
4243
<figcaption>All hand-made with natural soy wax, Candleaf is made for your pleasure moments</figcaption>
@@ -50,17 +51,19 @@ <h3>$ 9.99</h3>
5051
<h4>Quantity</h4>
5152
<div class="counter">
5253
<p>-</p>
53-
<p>0</p>
54+
<p>1</p>
5455
<p>+</p>
5556
</div>
5657
</div>
58+
<p class="alert-negative">Attention:<br>Quantity can't be negative!'</p>
59+
<p class="alert-out">No more items can be added.</p>
5760
</div>
5861
<div class="right-column">
5962
<div>
6063
<input type="radio" name="radio" id="one" >
6164
<label for="one">One time purchase</label>
6265
</div>
63-
<div>
66+
<div class="active">
6467
<input type="radio" name="radio" id="always" checked>
6568
<label for="always">Subscribe and delivery every</label>
6669
<select>
@@ -82,6 +85,8 @@ <h4>Quantity</h4>
8285
<span>Weight:</span> 400g </p>
8386
</div>
8487
</article>
88+
<p class="mobile_only">All hand-made with natural soy wax, Candleaf is made for your pleasure moments</p>
89+
<h3 class="mobile_only">🚚 FREE SHIPPING</h3>
8590
</article>
8691

8792
</main>

0 commit comments

Comments
 (0)