Skip to content

Commit

Permalink
Pagination, responsive video, and lightbox
Browse files Browse the repository at this point in the history
  • Loading branch information
minimaluminium committed Aug 15, 2023
1 parent 1d4860c commit 06d8449
Show file tree
Hide file tree
Showing 18 changed files with 917 additions and 131 deletions.
2 changes: 1 addition & 1 deletion assets/built/casper.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/casper.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/screen.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/screen.css.map

Large diffs are not rendered by default.

579 changes: 541 additions & 38 deletions assets/css/screen.css

Large diffs are not rendered by default.

Binary file added assets/images/default-skin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/default-skin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/preloader.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 32 additions & 88 deletions assets/js/casper.js
Original file line number Diff line number Diff line change
@@ -1,91 +1,3 @@
/* Dropdown menu */
(function () {
const mediaQuery = window.matchMedia('(max-width: 767px)');

const head = document.querySelector('.gh-navigation');
const menu = head.querySelector('.gh-navigation-menu');
const nav = menu?.querySelector('.nav');
if (!nav) return;

const logo = document.querySelector('.gh-navigation-logo');
const navHTML = nav.innerHTML;

if (mediaQuery.matches) {
const items = nav.querySelectorAll('li');
items.forEach(function (item, index) {
item.style.transitionDelay = `${0.03 * (index + 1)}s`;
});
}

const makeDropdown = function () {
if (mediaQuery.matches) return;
const submenuItems = [];

while ((nav.offsetWidth + 64) > menu.offsetWidth) {
if (nav.lastElementChild) {
submenuItems.unshift(nav.lastElementChild);
nav.lastElementChild.remove();
} else {
break;
}
}

if (!submenuItems.length) {
head.classList.add('is-dropdown-loaded');
return;
}

const toggle = document.createElement('button');
toggle.setAttribute('class', 'gh-more-toggle gh-icon-button');
toggle.setAttribute('aria-label', 'More');
toggle.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor"><path d="M21.333 16c0-1.473 1.194-2.667 2.667-2.667v0c1.473 0 2.667 1.194 2.667 2.667v0c0 1.473-1.194 2.667-2.667 2.667v0c-1.473 0-2.667-1.194-2.667-2.667v0zM13.333 16c0-1.473 1.194-2.667 2.667-2.667v0c1.473 0 2.667 1.194 2.667 2.667v0c0 1.473-1.194 2.667-2.667 2.667v0c-1.473 0-2.667-1.194-2.667-2.667v0zM5.333 16c0-1.473 1.194-2.667 2.667-2.667v0c1.473 0 2.667 1.194 2.667 2.667v0c0 1.473-1.194 2.667-2.667 2.667v0c-1.473 0-2.667-1.194-2.667-2.667v0z"></path></svg>';

const wrapper = document.createElement('div');
wrapper.setAttribute('class', 'gh-dropdown');

if (submenuItems.length >= 10) {
head.classList.add('is-dropdown-mega');
wrapper.style.gridTemplateRows = `repeat(${Math.ceil(submenuItems.length / 2)}, 1fr)`;
} else {
head.classList.remove('is-dropdown-mega');
}

submenuItems.forEach(function (child) {
wrapper.appendChild(child);
});

toggle.appendChild(wrapper);
nav.appendChild(toggle);

head.classList.add('is-dropdown-loaded');

window.addEventListener('click', function (e) {
if (head.classList.contains('is-dropdown-open')) {
head.classList.remove('is-dropdown-open');
} else if (toggle.contains(e.target)) {
head.classList.add('is-dropdown-open');
}
});
}

imagesLoaded(logo, function () {
makeDropdown();
});

window.addEventListener('load', function () {
if (!logo) {
makeDropdown();
}
});

window.addEventListener('resize', function () {
setTimeout(() => {
nav.innerHTML = navHTML;
makeDropdown();
}, 1);
});
})();

/* Mobile menu burger toggle */
(function () {
const navigation = document.querySelector('.gh-navigation');
Expand All @@ -99,4 +11,36 @@
navigation.classList.remove('is-open');
}
});
})();

/* Add lightbox to gallery images */
(function () {
lightbox(
'.kg-image-card > .kg-image[width][height], .kg-gallery-image > img'
);
})();

/* Responsive video in post content */
(function () {
const sources = [
'.gh-content iframe[src*="youtube.com"]',
'.gh-content iframe[src*="youtube-nocookie.com"]',
'.gh-content iframe[src*="player.vimeo.com"]',
'.gh-content iframe[src*="kickstarter.com"][src*="video.html"]',
'.gh-content object',
'.gh-content embed',
];
reframe(document.querySelectorAll(sources.join(',')));
})();

/* Turn the main nav into dropdown menu when there are more than 5 menu items */
(function () {
dropdown();
})();

/* Infinite scroll pagination */
(function () {
if (document.body.classList.contains('paged')) {
pagination();
}
})();
86 changes: 86 additions & 0 deletions assets/js/dropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
function dropdown() {
const mediaQuery = window.matchMedia('(max-width: 767px)');

const head = document.querySelector('.gh-navigation');
const menu = head.querySelector('.gh-navigation-menu');
const nav = menu?.querySelector('.nav');
if (!nav) return;

const logo = document.querySelector('.gh-navigation-logo');
const navHTML = nav.innerHTML;

if (mediaQuery.matches) {
const items = nav.querySelectorAll('li');
items.forEach(function (item, index) {
item.style.transitionDelay = `${0.03 * (index + 1)}s`;
});
}

const makeDropdown = function () {
if (mediaQuery.matches) return;
const submenuItems = [];

while ((nav.offsetWidth + 64) > menu.offsetWidth) {
if (nav.lastElementChild) {
submenuItems.unshift(nav.lastElementChild);
nav.lastElementChild.remove();
} else {
break;
}
}

if (!submenuItems.length) {
head.classList.add('is-dropdown-loaded');
return;
}

const toggle = document.createElement('button');
toggle.setAttribute('class', 'gh-more-toggle gh-icon-button');
toggle.setAttribute('aria-label', 'More');
toggle.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor"><path d="M21.333 16c0-1.473 1.194-2.667 2.667-2.667v0c1.473 0 2.667 1.194 2.667 2.667v0c0 1.473-1.194 2.667-2.667 2.667v0c-1.473 0-2.667-1.194-2.667-2.667v0zM13.333 16c0-1.473 1.194-2.667 2.667-2.667v0c1.473 0 2.667 1.194 2.667 2.667v0c0 1.473-1.194 2.667-2.667 2.667v0c-1.473 0-2.667-1.194-2.667-2.667v0zM5.333 16c0-1.473 1.194-2.667 2.667-2.667v0c1.473 0 2.667 1.194 2.667 2.667v0c0 1.473-1.194 2.667-2.667 2.667v0c-1.473 0-2.667-1.194-2.667-2.667v0z"></path></svg>';

const wrapper = document.createElement('div');
wrapper.setAttribute('class', 'gh-dropdown');

if (submenuItems.length >= 10) {
head.classList.add('is-dropdown-mega');
wrapper.style.gridTemplateRows = `repeat(${Math.ceil(submenuItems.length / 2)}, 1fr)`;
} else {
head.classList.remove('is-dropdown-mega');
}

submenuItems.forEach(function (child) {
wrapper.appendChild(child);
});

toggle.appendChild(wrapper);
nav.appendChild(toggle);

head.classList.add('is-dropdown-loaded');

window.addEventListener('click', function (e) {
if (head.classList.contains('is-dropdown-open')) {
head.classList.remove('is-dropdown-open');
} else if (toggle.contains(e.target)) {
head.classList.add('is-dropdown-open');
}
});
}

imagesLoaded(logo, function () {
makeDropdown();
});

window.addEventListener('load', function () {
if (!logo) {
makeDropdown();
}
});

window.addEventListener('resize', function () {
setTimeout(() => {
nav.innerHTML = navHTML;
makeDropdown();
}, 1);
});
}
4 changes: 4 additions & 0 deletions assets/js/lib/photoswipe-ui-default.min.js

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

4 changes: 4 additions & 0 deletions assets/js/lib/photoswipe.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/js/lib/reframe.min.js

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

Loading

0 comments on commit 06d8449

Please sign in to comment.