diff --git a/assets/css/image/feed.css b/assets/css/image/feed.css new file mode 100644 index 0000000..b233c0e --- /dev/null +++ b/assets/css/image/feed.css @@ -0,0 +1,108 @@ +:root { + --grid-gap: 12px; +} + +.post-caption { + display: none; +} + +.post-link { + display: block; +} + +.post-link:hover { + opacity: 1; +} + +.post-lightbox { + position: absolute; + right: 15px; + bottom: 15px; + display: flex; + align-items: center; + justify-content: center; + width: 30px; + height: 30px; + line-height: 30px; + text-align: center; + background-color: var(--color-white); + border-radius: 50%; + box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); + opacity: 0; + transition: opacity 0.2s ease, transform 0.2s ease; + transform: scale(0.8); +} + +.post-link:hover+.post-lightbox, +.post-lightbox:hover { + opacity: 1; + transform: scale(1); +} + +.post-feed { + margin: 0 auto; + visibility: hidden; + opacity: 0; + transition: opacity 0.3s var(--animation-base); +} + +.post-feed.initialized { + visibility: visible; + opacity: 1; +} + +.post-feed .grid-item { + position: absolute; + width: 330px; +} + +.post-feed .post { + position: relative; + margin: var(--grid-gap); +} + +.post-feed .post-image { + width: 100%; +} + +@media (max-width: 640px) { + .post-feed { + --grid-gap: 4px; + + max-width: calc(100% - (calc(var(--gap) - var(--grid-gap))) * 2); + } + + .post-feed .grid-item { + width: 50%; + } +} + +@media (min-width: 641px) and (max-width: 1019px) { + .post-feed { + --grid-gap: 8px; + + max-width: calc(100% - (calc(var(--gap) - var(--grid-gap))) * 2); + } + + .post-feed .grid-item { + width: calc(100% / 3); + } +} + +@media (min-width: 1020px) { + .post-feed { + max-width: 990px; + } +} + +@media (min-width: 1350px) { + .post-feed { + max-width: 1320px; + } +} + +@media (min-width: 1680px) { + .post-feed { + max-width: 1650px; + } +} diff --git a/assets/css/image/main.css b/assets/css/image/main.css new file mode 100644 index 0000000..c28b3ec --- /dev/null +++ b/assets/css/image/main.css @@ -0,0 +1,19 @@ +@import "@tryghost/shared-theme-assets/assets/css/v1/screen.css"; + +@import "../common/article.css"; +@import "../common/author.css"; +@import "../common/gscan.css"; +@import "../common/head.css"; +@import "../common/pagehead.css"; +@import "../common/root.css"; +@import "../common/section.css"; +@import "../common/tag.css"; + +@import "../lib/prism.css"; +@import "../lib/commento.css"; +@import "../lib/tocbot.css"; + +@import "feed.css"; +@import "masonry.css"; +@import "pswp.css"; +@import "site.css"; diff --git a/assets/css/image/masonry.css b/assets/css/image/masonry.css new file mode 100644 index 0000000..9547165 --- /dev/null +++ b/assets/css/image/masonry.css @@ -0,0 +1,217 @@ +/* +Brother . +https: //github.com/TryGhost/Edge/blob/main/assets/css/general/masonry.css +*/ + +.flexmasonry { + display: flex; + flex-flow: column wrap; + align-content: space-between; +} + +.flexmasonry-item { + width: 100%; +} + +.flexmasonry-cols-2 .flexmasonry-item { + width: 50%; +} + +.flexmasonry-cols-3 .flexmasonry-item { + width: 33.333%; +} + +.flexmasonry-cols-4 .flexmasonry-item { + width: 25%; +} + +.flexmasonry-cols-5 .flexmasonry-item { + width: 20%; +} + +.flexmasonry-cols-6 .flexmasonry-item { + width: 16.666%; +} + +.flexmasonry-cols-7 .flexmasonry-item { + width: 14.285%; +} + +.flexmasonry-cols-8 .flexmasonry-item { + width: 12.5%; +} + +.flexmasonry-cols-2 .flexmasonry-item:nth-child(2n+1) { + order: 1; +} + +.flexmasonry-cols-2 .flexmasonry-item:nth-child(2n) { + order: 2; +} + +.flexmasonry-cols-3 .flexmasonry-item:nth-child(3n+1) { + order: 1; +} + +.flexmasonry-cols-3 .flexmasonry-item:nth-child(3n+2) { + order: 2; +} + +.flexmasonry-cols-3 .flexmasonry-item:nth-child(3n) { + order: 3; +} + +.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n+1) { + order: 1; +} + +.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n+2) { + order: 2; +} + +.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n+3) { + order: 3; +} + +.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n) { + order: 4; +} + +.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n+1) { + order: 1; +} + +.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n+2) { + order: 2; +} + +.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n+3) { + order: 3; +} + +.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n+4) { + order: 4; +} + +.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n) { + order: 5; +} + +.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n+1) { + order: 1; +} + +.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n+2) { + order: 2; +} + +.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n+3) { + order: 3; +} + +.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n+4) { + order: 4; +} + +.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n+5) { + order: 5; +} + +.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n) { + order: 6; +} + +.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n+1) { + order: 1; +} + +.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n+2) { + order: 2; +} + +.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n+3) { + order: 3; +} + +.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n+4) { + order: 4; +} + +.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n+5) { + order: 5; +} + +.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n+6) { + order: 6; +} + +.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n) { + order: 7; +} + +.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n+1) { + order: 1; +} + +.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n+2) { + order: 2; +} + +.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n+3) { + order: 3; +} + +.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n+4) { + order: 4; +} + +.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n+5) { + order: 5; +} + +.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n+6) { + order: 6; +} + +.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n+7) { + order: 7; +} + +.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n) { + order: 8; +} + +.flexmasonry-break { + flex-basis: 100%; + width: 0 !important; + margin: 0; + content: ""; +} + +.flexmasonry-break-1 { + order: 1; +} + +.flexmasonry-break-2 { + order: 2; +} + +.flexmasonry-break-3 { + order: 3; +} + +.flexmasonry-break-4 { + order: 4; +} + +.flexmasonry-break-5 { + order: 5; +} + +.flexmasonry-break-6 { + order: 6; +} + +.flexmasonry-break-7 { + order: 7; +} diff --git a/assets/css/image/pswp.css b/assets/css/image/pswp.css new file mode 100644 index 0000000..a2a692d --- /dev/null +++ b/assets/css/image/pswp.css @@ -0,0 +1,73 @@ +/* +I don't know either man +https: //github.com/TryGhost/Themes/blob/main/packages/_shared/assets/css/v1/vendor/pswp.css +*/ + +.pswp__bg { + background: rgba(255, 255, 255, 0.9); +} + +.pswp__caption__center { + color: var(--color-darker-gray); +} + +.pswp__button, +.pswp__button--arrow--left::before, +.pswp__button--arrow--right::before { + background: url("/assets/images/default-skin.png") 0 0 no-repeat; + background-size: 264px 88px; +} + +@media (-webkit-min-device-pixel-ratio: 1.1), +(-webkit-min-device-pixel-ratio: 1.09375), +(min-resolution: 105dpi), +(min-resolution: 1.1dppx) { + + .pswp--svg .pswp__button, + .pswp--svg .pswp__button--arrow--left::before, + .pswp--svg .pswp__button--arrow--right::before { + background-image: url("/assets/images/default-skin.svg"); + } + + .pswp--svg .pswp__button--arrow--left, + .pswp--svg .pswp__button--arrow--right { + background: none; + } +} + +.pswp__button--arrow--left, +.pswp__button--arrow--right { + background: none; +} + +.pswp__button--close { + background-position: 0 -44px; +} + +.pswp__button--share { + background-position: -44px -44px; +} + +.pswp--fs .pswp__button--fs { + background-position: -44px 0; +} + +.pswp__button--zoom { + background-position: -88px 0; +} + +.pswp--zoomed-in .pswp__button--zoom { + background-position: -132px 0; +} + +.pswp__button--arrow--left::before { + background-position: -138px -44px; +} + +.pswp__button--arrow--right::before { + background-position: -94px -44px; +} + +.pswp__preloader--active .pswp__preloader__icn { + background: url("/assets/images/preloader.gif") 0 0 no-repeat; +} diff --git a/assets/css/image/site.css b/assets/css/image/site.css new file mode 100644 index 0000000..f1f9a9c --- /dev/null +++ b/assets/css/image/site.css @@ -0,0 +1,18 @@ +.gh-site { + display: flex; + flex-direction: column; + min-height: 100vh; +} + +.gh-site-content { + flex-grow: 1; + padding: 48px 0 96px; +} + +.gh-main { + padding-top: 0; +} + +.gh-feed { + width: 100%; +} diff --git a/assets/images/default-skin.png b/assets/images/default-skin.png new file mode 100755 index 0000000..17424f1 Binary files /dev/null and b/assets/images/default-skin.png differ diff --git a/assets/images/default-skin.svg b/assets/images/default-skin.svg new file mode 100755 index 0000000..2c7f56e --- /dev/null +++ b/assets/images/default-skin.svg @@ -0,0 +1 @@ + diff --git a/assets/images/preloader.gif b/assets/images/preloader.gif new file mode 100755 index 0000000..b8faa69 Binary files /dev/null and b/assets/images/preloader.gif differ diff --git a/assets/js/common/tabs.js b/assets/js/common/tabs.js index 2e8ba38..b54ac12 100644 --- a/assets/js/common/tabs.js +++ b/assets/js/common/tabs.js @@ -1,5 +1,7 @@ function tabsInNewPage() { - var links = document.getElementsByTagName("article")[0].querySelectorAll('a'); + var links = document.getElementsByTagName("article"); + if (links.length === 0) return; + links = links[0].querySelectorAll('a'); var a = new RegExp('/' + window.location.host + '/'); links.forEach(link => !a.test(link.href) && link.setAttribute("target", "_blank")); } diff --git a/assets/js/image/main.js b/assets/js/image/main.js new file mode 100644 index 0000000..72e97b8 --- /dev/null +++ b/assets/js/image/main.js @@ -0,0 +1,134 @@ +function pswp(container, element, trigger, caption, isGallery) { + var parseThumbnailElements = function (el) { + var items = [], + gridEl, + linkEl, + item; + + $(el) + .find(element) + .each(function (i, v) { + gridEl = $(v); + linkEl = gridEl.find(trigger); + + item = { + src: isGallery + ? gridEl.find('img').attr('src') + : linkEl.attr('href'), + w: 0, + h: 0, + }; + + if (caption && gridEl.find(caption).length) { + item.title = gridEl.find(caption).html(); + } + + items.push(item); + }); + + return items; + }; + + var openPhotoSwipe = function (index, galleryElement) { + var pswpElement = document.querySelectorAll('.pswp')[0], + gallery, + options, + items; + + items = parseThumbnailElements(galleryElement); + + options = { + closeOnScroll: false, + history: false, + index: index, + shareEl: false, + showAnimationDuration: 0, + showHideOpacity: true, + }; + + gallery = new PhotoSwipe( + pswpElement, + PhotoSwipeUI_Default, + items, + options + ); + + gallery.listen('gettingData', function (index, item) { + if (item.w < 1 || item.h < 1) { + var img = new Image(); + img.onload = function () { + item.w = this.width; + item.h = this.height; + gallery.updateSize(true); + }; + img.src = item.src; + } + }); + gallery.init(); + }; + + var onThumbnailsClick = function (e) { + e.preventDefault(); + + var index = $(e.target) + .closest(container) + .find(element) + .index($(e.target).closest(element)); + var clickedGallery = $(e.target).closest(container); + + openPhotoSwipe(index, clickedGallery[0]); + + return false; + }; + + $(container).on('click', trigger, function (e) { + onThumbnailsClick(e); + }); +} + +function feed() { + 'use strict'; + + var grid = document.querySelector('.post-feed'); + if (!grid) return; + + var masonry; + + imagesLoaded(grid, function () { + masonry = new Masonry(grid, { + itemSelector: '.grid-item', + columnWidth: '.grid-sizer', + hiddenStyle: { transform: 'translateY(50px)', opacity: 0 }, + visibleStyle: { transform: 'translateY(0)', opacity: 1 }, + }); + + masonry.on('layoutComplete', function () { + grid.classList.add('initialized'); + }); + + masonry.layout(); + + function callback(items, loadNextPage) { + imagesLoaded(items, function (loaded) { + masonry.appended(items); + masonry.layout(); + loaded.elements.forEach(function (item) { + item.style.visibility = 'visible'; + }); + loadNextPage(); + }); + } + + pagination(true, callback, true); + }); + + pswp( + '.post-feed', + '.post', + '.post-lightbox', + '.post-caption', + false + ); +} + +feed(); diff --git a/author.hbs b/author.hbs index 55be21f..ad9a311 100644 --- a/author.hbs +++ b/author.hbs @@ -40,5 +40,9 @@ {{/author}} + {{#match @custom.mode "Text-based"}} {{> text/feed}} + {{else}} + {{> image/feed}} + {{/match}} diff --git a/default.hbs b/default.hbs index 3c10669..44ad9ba 100644 --- a/default.hbs +++ b/default.hbs @@ -7,7 +7,11 @@