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

_fancybox.js created #67

Merged
merged 1 commit into from
Mar 17, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions assets/src/js/_fancybox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Fancybox } from '@fancyapps/ui';

class FancyBoxJs {
constructor() {
this.fancyBoxInit();
}

// eslint-disable-next-line class-methods-use-this
fancyBoxInit() {
Fancybox.bind('[data-fancybox]', {
dragToClose: false,
closeButton: 'top',

Image: {
zoom: false,
},
});
}
}

export default FancyBoxJs;
1 change: 1 addition & 0 deletions assets/src/js/_swiperJs.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class SwiperJS {
Swiper.use([Navigation]);
// eslint-disable-next-line no-new
const swiper = new Swiper('.product-img-swiper', {
loop: false,
slidesPerView: 3,
spaceBetween: 24,
navigation: {
Expand Down
5 changes: 5 additions & 0 deletions assets/src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PopperJs from './_popper';
import BootstrapPlugins from './_bootstrapPlugins';
import SwiperJS from './_swiperJs';
import Filters from './_filters';
import FancyBoxJs from './_fancybox';

const App = {

Expand All @@ -22,10 +23,14 @@ const App = {
function initFilters() {
return new Filters();
}
function initFancyBox() {
return new FancyBoxJs();
}
initPopperJs();
initBootstrapPlugins();
initSwiperJS();
initFilters();
initFancyBox();
}

};
Expand Down
15 changes: 10 additions & 5 deletions assets/src/scss/components/_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@
overflow-x: hidden;
padding-bottom: 24px;
.swiper-slide {
img {
@include boxShadow($regular-box);
width: 166px;
height: 166px;
object-fit: cover;
a {
img {
width: 166px;
height: 166px;
object-fit: cover;
}
img:hover {
@include animation;
@include boxShadow($regular-box);
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions assets/src/scss/components/fancybox.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.fancybox__thumbs .carousel__slide .fancybox__thumb::after {
border-color: $primary-color;
border-radius: 0;
}
13 changes: 9 additions & 4 deletions assets/src/scss/layout/_product.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@
}
}
&-img {
@include boxShadow($regular-box);
margin-bottom: 24px;
max-width: 546px;
max-height: 546px;
img {
object-fit: cover;
width: 100%;
a {
img {
object-fit: cover;
width: 100%;
}
}
}
&-img:hover {
@include animation;
@include boxShadow($regular-box);
}
}
4 changes: 3 additions & 1 deletion assets/src/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// vendors
@import "node_modules/bootstrap/scss/bootstrap";
@import "node_modules/@fancyapps/ui/src/Fancybox/Fancybox";
@import "node_modules/swiper/swiper";
@import "node_modules/swiper/modules/pagination/pagination";

Expand Down Expand Up @@ -58,7 +59,8 @@
"components/breadcrumbs",
"components/certificates",
"components/nav-pills",
"components/pagination";
"components/pagination",
"components/fancybox";

// pages
@import "pages/front-page",
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"webpack-stream": "7.0.0"
},
"dependencies": {
"@fancyapps/ui": "^4.0.26",
"@popperjs/core": "^2.11.2",
"bootstrap": "5.1.3",
"swiper": "^8.0.7"
Expand Down
8 changes: 6 additions & 2 deletions templates/pages/product/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
<div class="col-xl-7 col-md-7 col-lg-7">
<div class="product-images">
<div class="product-img d-flex justify-content-center">
<img src="<?php echo get_the_post_thumbnail_url() ?>" alt="<?php echo $image_title?>">
<a data-fancybox="gallery" href="<?php echo get_the_post_thumbnail_url() ?>">
<img src="<?php echo get_the_post_thumbnail_url() ?>" alt="<?php echo $image_title?>">
</a>
</div>
<div class="product-slider">
<div class="product-img-swiper">
<div class="swiper-wrapper">
<?php foreach ($slider_imgs as $img) { ?>
<?php if ($img['crb_image'] !== ''): ?>
<div class="swiper-slide">
<img src="<?php echo wp_get_attachment_url($img['crb_image']) ?>" alt="<?php echo get_the_title($img['crb_image']) ?>">
<a data-fancybox="gallery" href="<?php echo wp_get_attachment_url($img['crb_image']) ?>">
<img src="<?php echo wp_get_attachment_url($img['crb_image']) ?>" alt="<?php echo get_the_title($img['crb_image']) ?>">
</a>
</div>
<?php endif; ?>
<?php } ?>
Expand Down