// @page Pattern Library/JavaScript // @name Overlay // // @description // `.us-overlay` slides in from either side of the viewport, or can be shown as a modal window. // // // @javascript // var overlay = new Overlay({ // bodyActiveClass: 'us-overlay--open', // activeClass: 'us-overlay-parent--active', // visibleClass: 'us-overlay-parent--visible', // overlay: $('.us-overlay-parent'), // openButton: '.js-open-overlay', // closeButton: '.js-close-overlay', // historyStatus: '#seedeal', // history: false, // preventDefault: true // }); // // @state .us-overlay--modal - Overlay appears as a modal window. // @state .us-overlay--right - Overlay appears on the right side of the viewport (not applicable when used in conjunction with .us-overlay--modal). // @state .us-overlay--above - Overlay appears over the top of another open overlay. // // @markup // // //
$overlay-modal-breakpoint: desktop !default; $overlay-modal-width: 60% !default; $overlay-max-modal-width: 700px !default; $overlay-z-index: 1003 !default; $overlay-transition-speed: .3s !default; $overlay-mobile-width: 100% !default; $overlay-tablet-width: 340px !default; $overlay-header-height: 55px !default; $overlay-close-size: 64px !default; .us-overlay--open { overflow: hidden; } @mixin overlay--open { .us-overlay-parent--active & { @content; } } @mixin overlay--above { &.us-overlay--above { @content; } } .us-overlay-parent { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: $overlay-z-index; visibility: hidden; } .us-overlay-parent--visible { overflow: scroll; visibility: visible; } .us-overlay { position: absolute; z-index: $overlay-z-index; width: $overlay-mobile-width; min-height: 100%; background: #fff; transform: translate3d(-100%, 0, 0); transition: transform $overlay-transition-speed ease-in, opacity $overlay-transition-speed linear, box-shadow $overlay-transition-speed linear; -webkit-overflow-scrolling: auto; @include overlay--open { opacity: 1; transform: translate3d(0, 0, 0); box-shadow: 1px 0 18px 0 rgba(0, 0, 0, .3); transition-timing-function: ease-out; } @include respond-to(small-tablet, true) { width: $overlay-tablet-width; } } .us-overlay--above { z-index: $overlay-z-index + 1; @include overlay--open { box-shadow: 1px 0 30px 5px rgba(0, 0, 0, .3); } } .us-overlay--modal { @include respond-to($overlay-modal-breakpoint, true) { position: relative; width: $overlay-modal-width; max-width: $overlay-max-modal-width; min-height: 0; margin: 5% auto; opacity: 0; transform: translate3d(0, -30px, 0); @include overlay--open { transform: translate3d(0, 0, 0); box-shadow: 0 1px 18px 0 rgba(0, 0, 0, .3); @include overlay--above { box-shadow: 0 1px 30px 5px rgba(0, 0, 0, .3); } } } } .us-overlay--right { right: 0; transform: translate3d(100%, 0, 0); @include overlay--open { transform: translate3d(0, 0, 0); box-shadow: -1px 0 18px 0 rgba(0, 0, 0, .3); @include overlay--above { box-shadow: -1px 0 30px 5px rgba(0, 0, 0, .3); } } } .us-overlay__container { position: relative; } .us-overlay__body { @extend %container !optional; padding: 1em; color: $c-typegrey; } .us-overlay__header { position: relative; width: 100%; min-height: $overlay-header-height; padding: 1em; color: #fff; background: $c-navy; } .us-overlay__title { width: calc(100% - #{$overlay-close-size}); } .us-overlay__close { position: absolute; top: .75em; right: 1em; }