<div class="image-gallery ">
    <!-- image-gallery__block-sizer empty element, used by masonry image layout -->
    <div class="image-gallery__block-sizer"></div>
    <div class="image-gallery__block">
        <a class="image-gallery__popup-launcher mfp-image" href="https://magicyeti.us/800/600">
            <figure>
                <img src="https://magicyeti.us/800/600" alt="" class="" />
                <figcaption>
                    <p class="">

                    </p>
                    <cite>Alfred E. Newman</cite>
                </figcaption>
            </figure>
        </a>
    </div>
    <div class="image-gallery__block">
        <a class="image-gallery__popup-launcher mfp-image" href="https://magicyeti.us/800/450">
            <figure>
                <img src="https://magicyeti.us/800/450" alt="" class="" />
                <figcaption>
                    <p class="">

                    </p>
                    <cite>Alfred E. Newman</cite>
                </figcaption>
            </figure>
        </a>
    </div>
    <div class="image-gallery__block">
        <a class="image-gallery__popup-launcher mfp-image" href="https://magicyeti.us/800/800">
            <figure>
                <img src="https://magicyeti.us/800/800" alt="" class="" />
                <figcaption>
                    <p class="">

                    </p>
                    <cite>Alfred E. Newman</cite>
                </figcaption>
            </figure>
        </a>
    </div>
    <div class="image-gallery__block">
        <a class="image-gallery__popup-launcher mfp-image" href="https://magicyeti.us/800/1067">
            <figure>
                <img src="https://magicyeti.us/800/1067" alt="" class="" />
                <figcaption>
                    <p class="">

                    </p>
                    <cite>Alfred E. Newman</cite>
                </figcaption>
            </figure>
        </a>
    </div>
    <div class="image-gallery__block">
        <a class="image-gallery__popup-launcher mfp-image" href="https://magicyeti.us/800/533">
            <figure>
                <img src="https://magicyeti.us/800/533" alt="" class="" />
                <figcaption>
                    <p class="">

                    </p>
                    <cite>Alfred E. Newman</cite>
                </figcaption>
            </figure>
        </a>
    </div>
    <div class="image-gallery__block">
        <a class="image-gallery__popup-launcher mfp-image" href="https://magicyeti.us/800/800">
            <figure>
                <img src="https://magicyeti.us/800/800" alt="" class="" />
                <figcaption>
                    <p class="">

                    </p>
                    <cite>Alfred E. Newman</cite>
                </figcaption>
            </figure>
        </a>
    </div>
</div>
<div class="image-gallery {{ layout_component }}">
    <!-- image-gallery__block-sizer empty element, used by masonry image layout -->
    <div class="image-gallery__block-sizer"></div>
    {% for item in image_gallery.items %}
        {% set bigImageSrc = yetimg({ratio: item.image.ratio, w: 800}) %}
        <div class="image-gallery__block">
            <a class="image-gallery__popup-launcher mfp-image" href="{{ bigImageSrc }}">
                {% include '@figure' with { figure: item.figure, image: item.image, hg: item.hg, p: item.p, cite: item.cite } %}
            </a>
        </div>
    {% endfor %}
</div>
{
  "image_gallery": {
    "items": [
      {
        "figure": {
          "media": "@image"
        },
        "image": {
          "ratio": "4:3",
          "w": "200"
        },
        "cite": {
          "citation": "Alfred E. Newman"
        },
        "p": "This is a default caption. It can include styles but currently cannot support link text.",
        "hg": {
          "super": "Optional Superhead",
          "headline": "Headline",
          "sub": "Optional Subhead",
          "tag": "h2"
        }
      },
      {
        "figure": {
          "media": "@image"
        },
        "image": {
          "ratio": "16:9",
          "w": "200"
        },
        "cite": {
          "citation": "Alfred E. Newman"
        },
        "p": "This is a default caption. It can include styles but currently cannot support link text.",
        "hg": {
          "super": "Optional Superhead",
          "headline": "Headline",
          "sub": "Optional Subhead",
          "tag": "h2"
        }
      },
      {
        "figure": {
          "media": "@image"
        },
        "image": {
          "ratio": "1:1",
          "w": "200"
        },
        "cite": {
          "citation": "Alfred E. Newman"
        },
        "p": "This is a default caption. It can include styles but currently cannot support link text.",
        "hg": {
          "super": "Optional Superhead",
          "headline": "Headline",
          "sub": "Optional Subhead",
          "tag": "h2"
        }
      },
      {
        "figure": {
          "media": "@image"
        },
        "image": {
          "ratio": "3:4",
          "w": "200"
        },
        "cite": {
          "citation": "Alfred E. Newman"
        },
        "p": "This is a default caption. It can include styles but currently cannot support link text.",
        "hg": {
          "super": "Optional Superhead",
          "headline": "Headline",
          "sub": "Optional Subhead",
          "tag": "h2"
        }
      },
      {
        "figure": {
          "media": "@image"
        },
        "image": {
          "ratio": "3:2",
          "w": "200"
        },
        "cite": {
          "citation": "Alfred E. Newman"
        },
        "p": "This is a default caption. It can include styles but currently cannot support link text.",
        "hg": {
          "super": "Optional Superhead",
          "headline": "Headline",
          "sub": "Optional Subhead",
          "tag": "h2"
        }
      },
      {
        "figure": {
          "media": "@image"
        },
        "image": {
          "ratio": "1:1",
          "w": "200"
        },
        "cite": {
          "citation": "Alfred E. Newman"
        },
        "p": "This is a default caption. It can include styles but currently cannot support link text.",
        "hg": {
          "super": "Optional Superhead",
          "headline": "Headline",
          "sub": "Optional Subhead",
          "tag": "h2"
        }
      }
    ]
  }
}
  • Content:
    .image-gallery {
      // -1 gridblock in all directions to make up for gutter
      // around each of the image grid items
      margin: #{$grid-gap / -2};
    }
    
    .modal {
      .modal__wrapper {
        max-width: 80vw;
        max-height: 80vh;
    
        img {
          max-width: 80vw;
          max-height: 80vw;
        }
      }
    }
    
    .image-gallery__block {
      a {
        display: block;
        overflow: hidden;
    
        &:hover,
        &:focus {
          figure {
            img {
              transform: scale(1.1);
            }
    
            &::before,
            &::after {
              opacity: 1;
            }
          }
        }
      }
    
      figure {
        position: relative;
        overflow: hidden;
    
        img {
          transition: transform .6s ease-in-out;
        }
    
        &::after {
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translateX(-50%) translateY(-50%);
          transition: opacity .3s ease-in-out;
          color: color(davidson-white);
          font-family: 'iconfont';
          font-size: 2.2em;
          line-height: 1.2;
          content: $icon-popup;
          opacity: 0;
          z-index: 10;
        }
    
        &::before {
          $overlay-color: rgba(color(davidson-red), .7);
          position: absolute;
          top: 0;
          right: 0;
          bottom: 0;
          left: 0;
          transition: opacity .3s ease-in-out;
          background-color: $overlay-color;
          box-shadow: inset 0 0 0 .5rem color(davidson-red);
          content: '';
          opacity: 0;
          z-index: 10;
        }
      }
    
      figcaption {
        display: none;
      }
    }
    
    .image-gallery__slide__title {
      @include rr-font-compute(l, tight);
      font-weight: 500;
    }
    
    .image-gallery__block-sizer,
    .image-gallery__block {
      width: calc(33.3% - #{$grid-gap});
      padding: #{$grid-gap / 2};
      box-sizing: content-box;
    
      figure {
        padding-bottom: 0;
        border-bottom: 0;
      }
    }
    
    .image-gallery__block--width2 {
      width: calc(66.6% - #{$grid-gap});
    }
    
    // magnific popup 
    .mfp-bg {
      background-color: color(medium-teal);
    }
    
    button.mfp-close {
      right: 0;
      width: 1.4em !important; // sass-lint:disable-line no-important
      padding: 0;
      line-height: 1;
      text-align: center;
      &:before {
        display: none;
      }
    }
    
    button.mfp-arrow {
      &:before,
      &:after {
        transform: none;
        background: transparent;
      }
      &:hover,
      &:active {
        &:before,
        &:after {
          left: 0;
        }
      }
    }
    
    .mfp-image-holder {
      .mfp-bottom-bar {
        position: relative;
        top: auto;
        margin-top: 0;
      }
    
      .mfp-figure {
        padding: 3rem;
        background-color: color(davidson-white);
      }
    
      .mfp-figure::after {
        display: none;
      }
    
      .mfp-title {
        padding-right: 0;
      }
    
      .mfp-counter {
        top: auto;
        bottom: 100%;
      }
    
      .mfp-img {
        padding: 0 0 1rem;
      }
    
      figure img {
        max-width: 70vw;
        height: auto;
      }
    
      @include rr-break-directive(l) {
        .mfp-landscape figure {
          figcaption {
            margin: 2rem;
          }
        }
    
        .mfp-portrait figure {
          display: flex;
          align-items: flex-start;
          justify-content: center;
          max-width: 70vw;
    
          img {
            flex: 1 1 50%;
            max-width: 30vw;
            margin-right: 2rem;
          }
    
          figcaption {
            flex: 1 1 50%;
            margin-right: 2rem;
          }
    
          .mfp-bottom-bar {
            margin-top: 56px;
          }
        }
      }
    }
    
  • URL: /components/raw/image-gallery/image-gallery.scss
  • Filesystem Path: patterns/organisms/interactive/image-gallery/image-gallery.scss
  • Size: 3.2 KB
  • Content:
    /* This demonstrates initializing the ambient video; the final 
       script should not be included in an integrated project. */
    
    document.addEventListener('DOMContentLoaded', () => {
      image_gallery();
    });
  • URL: /components/raw/image-gallery/image-gallery-init.js
  • Filesystem Path: patterns/organisms/interactive/image-gallery/image-gallery-init.js
  • Size: 203 Bytes
  • Content:
    /*
     * Image gallery has dependencies on jquery, slick, accessible-modal-window, and
     * magnificpopup.
     */
    
    const fitCaption = ($c) => {
      $ = jQuery;
      const $image = $c.find('img');
      const $caption = $c.find('figcaption');
      const w = $image.width();
      if (w == 0) {
        return;
      }
      const h = $image.height();
      const r = w/h;
      const captionWidth = (w < 300) ? "70vw" : w;
    
    
      $caption.css({maxWidth: captionWidth});
    
      if (r <= 1) {
          $c.addClass('mfp-portrait')
          $c.removeClass('mfp-landscape')
      } else {
          $c.addClass('mfp-landscape')
          $c.removeClass('mfp-portrait')
      }
    }
    
    const image_gallery = () => {
      $ = jQuery;
      const $gallery = $('.image-gallery')
      if ($gallery.length < 1) return;
    
      // Fire up the masonry layout
      const $grid = $gallery.masonry({
          columnWidth: '.image-gallery__block-sizer',
          itemSelector: '.image-gallery__block',
      });
    
      // Reflow content in the layout as each image is loaded
      $grid.imagesLoaded().progress( () => { $grid.masonry('layout') });
    
          
      const $modals = $gallery.magnificPopup({
          delegate: 'a.image-gallery__popup-launcher',
          mainClass: 'mfp-fade',
          tLoading: 'Loading image #%curr%...',
          gallery: { enabled: true }, 
          navigateByImgClick: true,
          preload: [0, 1],
          image: {
              tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
              verticalFit: false,
              titleSrc: (item) => {
                  return $(item.el).find('figcaption').html();
              }     
          }
      });
    
      $modals.on('mfpResize mfpImageLoadComplete mfpChange mfpOpen', (e) => {
        if ($.magnificPopup.instance) {
          fitCaption($.magnificPopup.instance.content);
        }
      });               
    }
    
  • URL: /components/raw/image-gallery/image-gallery.js
  • Filesystem Path: patterns/organisms/interactive/image-gallery/image-gallery.js
  • Size: 1.7 KB

There are no notes for this item.