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

feat: add jquery #37

Merged
merged 1 commit into from
Dec 3, 2024
Merged
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
13 changes: 13 additions & 0 deletions steps/02.01-stability-solution/public/scripts/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$(document).ready(function () {
$(document).on('click', '#increase-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
$('#quantity').val(qty + 1);
});

$(document).on('click', '#decrease-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
if (qty > 1) {
$('#quantity').val(qty - 1);
}
});
});
6 changes: 6 additions & 0 deletions steps/02.01-stability-solution/public/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ body {
}

.conversion__price {
display: flex;
align-items: center;
justify-content: space-between;
}

.conversion__price-amount {
font-size: 1.5rem;
font-weight: 700;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="/styles/relatedProducts.css" />
<link rel="stylesheet" href="/styles/footer.css" />
<script src="/scripts/tracking.js"></script>
<script src="/scripts/product.js"></script>
<link rel="stylesheet" href="/styles/main.css" />
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
</ul>
</fieldset>
<div class="conversion__buy">
<span class="conversion__price">{{ sizes[0].price.amount }}€</span>
<div class="conversion__price">
<span class="conversion__price-amount">{{ sizes[0].price.amount }}€</span>
<div class="quantity">
<button id="decrease-qty" class="btn btn-small btn-quantity btn-light" type="button">-</button>
<input id="quantity" class="input-quantity form-control" type="number" value="1" min="1" max="10">
<button id="increase-qty" class="btn btn-small btn-quantity btn-light" type="button">+</button>
</div>
</div>
<button id="btn-add-to-cart" class="btn btn-primary btn-big conversion_add" disabled="disabled">
<strong>Ajouter au panier</strong>
</button>
Expand Down
13 changes: 13 additions & 0 deletions steps/02.01-stability/public/scripts/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$(document).ready(function () {
$(document).on('click', '#increase-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
$('#quantity').val(qty + 1);
});

$(document).on('click', '#decrease-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
if (qty > 1) {
$('#quantity').val(qty - 1);
}
});
});
27 changes: 27 additions & 0 deletions steps/02.01-stability/public/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@ body {
}

.conversion__price {
display: flex;
align-items: center;
justify-content: space-between;
}

.conversion__price-amount {
font-size: 1.5rem;
font-weight: 700;
}
Expand Down Expand Up @@ -441,6 +447,27 @@ body {
border-color: #000;
}

/* Quantity */
.quantity {
display: flex;
align-items: stretch;
gap: var(--spacing-2);
}

.btn-quantity {
color: var(--color-anthracite);
min-width: 2rem;
}

.btn-quantity:disabled {
color: var(--color-bg-secondary);
}

.input-quantity {
width: 4rem;
text-align: center;
}

/* Product title */
.product-title {
font-size: var(--font-size-xl);
Expand Down
1 change: 1 addition & 0 deletions steps/02.01-stability/server/views/pages/product.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="/styles/relatedProducts.css" />
<link rel="stylesheet" href="/styles/footer.css" />
<script src="/scripts/tracking.js"></script>
<script src="/scripts/product.js"></script>
<link rel="stylesheet" href="/styles/main.css" />
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
</ul>
</fieldset>
<div class="conversion__buy">
<span class="conversion__price">{{ sizes[0].price.amount }}€</span>
<div class="conversion__price">
<span class="conversion__price-amount">{{ sizes[0].price.amount }}€</span>
<div class="quantity">
<button id="decrease-qty" class="btn btn-small btn-quantity btn-light" type="button">-</button>
<input id="quantity" class="input-quantity form-control" type="number" value="1" min="1" max="10">
<button id="increase-qty" class="btn btn-small btn-quantity btn-light" type="button">+</button>
</div>
</div>
<button id="btn-add-to-cart" class="btn btn-primary btn-big conversion_add" disabled="disabled">
<strong>Ajouter au panier</strong>
</button>
Expand Down
13 changes: 13 additions & 0 deletions steps/02.02-fonts-solution/public/scripts/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$(document).ready(function () {
$(document).on('click', '#increase-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
$('#quantity').val(qty + 1);
});

$(document).on('click', '#decrease-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
if (qty > 1) {
$('#quantity').val(qty - 1);
}
});
});
6 changes: 6 additions & 0 deletions steps/02.02-fonts-solution/public/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ body {
}

.conversion__price {
display: flex;
align-items: center;
justify-content: space-between;
}

.conversion__price-amount {
font-size: 1.5rem;
font-weight: 700;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<link rel="stylesheet" href="/styles/relatedProducts.css" />
<link rel="stylesheet" href="/styles/footer.css" />
<script src="/scripts/tracking.js"></script>
<script src="/scripts/product.js"></script>
<link rel="stylesheet" href="/styles/main.css" />
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
</ul>
</fieldset>
<div class="conversion__buy">
<span class="conversion__price">{{ sizes[0].price.amount }}€</span>
<div class="conversion__price">
<span class="conversion__price-amount">{{ sizes[0].price.amount }}€</span>
<div class="quantity">
<button id="decrease-qty" class="btn btn-small btn-quantity btn-light" type="button">-</button>
<input id="quantity" class="input-quantity form-control" type="number" value="1" min="1" max="10">
<button id="increase-qty" class="btn btn-small btn-quantity btn-light" type="button">+</button>
</div>
</div>
<button id="btn-add-to-cart" class="btn btn-primary btn-big conversion_add" disabled="disabled">
<strong>Ajouter au panier</strong>
</button>
Expand Down
13 changes: 13 additions & 0 deletions steps/02.02-fonts/public/scripts/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$(document).ready(function () {
$(document).on('click', '#increase-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
$('#quantity').val(qty + 1);
});

$(document).on('click', '#decrease-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
if (qty > 1) {
$('#quantity').val(qty - 1);
}
});
});
6 changes: 6 additions & 0 deletions steps/02.02-fonts/public/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ body {
}

.conversion__price {
display: flex;
align-items: center;
justify-content: space-between;
}

.conversion__price-amount {
font-size: 1.5rem;
font-weight: 700;
}
Expand Down
1 change: 1 addition & 0 deletions steps/02.02-fonts/server/views/pages/product.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="/styles/relatedProducts.css" />
<link rel="stylesheet" href="/styles/footer.css" />
<script src="/scripts/tracking.js"></script>
<script src="/scripts/product.js"></script>
<link rel="stylesheet" href="/styles/main.css" />
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
</ul>
</fieldset>
<div class="conversion__buy">
<span class="conversion__price">{{ sizes[0].price.amount }}€</span>
<div class="conversion__price">
<span class="conversion__price-amount">{{ sizes[0].price.amount }}€</span>
<div class="quantity">
<button id="decrease-qty" class="btn btn-small btn-quantity btn-light" type="button">-</button>
<input id="quantity" class="input-quantity form-control" type="number" value="1" min="1" max="10">
<button id="increase-qty" class="btn btn-small btn-quantity btn-light" type="button">+</button>
</div>
</div>
<button id="btn-add-to-cart" class="btn btn-primary btn-big conversion_add" disabled="disabled">
<strong>Ajouter au panier</strong>
</button>
Expand Down
13 changes: 13 additions & 0 deletions steps/03.01-speed-size/public/scripts/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$(document).ready(function () {
$(document).on('click', '#increase-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
$('#quantity').val(qty + 1);
});

$(document).on('click', '#decrease-qty', function () {
let qty = parseInt($('#quantity').val(), 10) || 0;
if (qty > 1) {
$('#quantity').val(qty - 1);
}
});
});
6 changes: 6 additions & 0 deletions steps/03.01-speed-size/public/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ body {
}

.conversion__price {
display: flex;
align-items: center;
justify-content: space-between;
}

.conversion__price-amount {
font-size: 1.5rem;
font-weight: 700;
}
Expand Down
1 change: 1 addition & 0 deletions steps/03.01-speed-size/server/views/pages/product.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<link rel="stylesheet" href="/styles/relatedProducts.css" />
<link rel="stylesheet" href="/styles/footer.css" />
<script src="/scripts/tracking.js"></script>
<script src="/scripts/product.js"></script>
<link rel="stylesheet" href="/styles/main.css" />
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
</ul>
</fieldset>
<div class="conversion__buy">
<span class="conversion__price">{{ sizes[0].price.amount }}€</span>
<div class="conversion__price">
<span class="conversion__price-amount">{{ sizes[0].price.amount }}€</span>
<div class="quantity">
<button id="decrease-qty" class="btn btn-small btn-quantity btn-light" type="button">-</button>
<input id="quantity" class="input-quantity form-control" type="number" value="1" min="1" max="10">
<button id="increase-qty" class="btn btn-small btn-quantity btn-light" type="button">+</button>
</div>
</div>
<button id="btn-add-to-cart" class="btn btn-primary btn-big conversion_add" disabled="disabled">
<strong>Ajouter au panier</strong>
</button>
Expand Down