@iris.interactive/handcook 4.0.6 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,88 @@
1
+ import ElementEnum from "../../enumerators/element.enum";
2
+ import './overlay.component.scss';
3
+
4
+ export class HcOverlay {
5
+
6
+ showEvent;
7
+ hideEvent;
8
+
9
+ constructor(elements = ElementEnum.overlay) {
10
+ const HcOverlay = this;
11
+ document.querySelectorAll(elements).forEach(element => {
12
+ HcOverlay.createEvent(element);
13
+
14
+ //Init class
15
+ element.classList.add('hc-overlay-init');
16
+
17
+ //Open triggers
18
+ document.querySelectorAll('[data-hc-overlay-trigger]').forEach(open => {
19
+ open.addEventListener('click', (e) => {
20
+ let target = e.currentTarget.getAttribute('data-hc-overlay-trigger') ? e.currentTarget.getAttribute('data-hc-overlay-trigger'):e.currentTarget.getAttribute('href') ? e.currentTarget.getAttribute('href').substring(1):null;
21
+ HcOverlay.show(document.getElementById(target));
22
+ });
23
+ });
24
+
25
+ //Close triggers
26
+ document.querySelectorAll('[data-hc-overlay-close]').forEach(close => {
27
+ close.addEventListener('click', (e) => {
28
+ e.preventDefault();
29
+ let closeTarget = e.currentTarget.getAttribute('data-hc-overlay-close');
30
+ if (closeTarget) {
31
+ HcOverlay.close(document.getElementById(closeTarget));
32
+ }
33
+ });
34
+ });
35
+
36
+ //Close all overlays on background click
37
+ document.querySelectorAll('[data-hc-overlay-background]').forEach(background => {
38
+ background.addEventListener('click', (e) => {
39
+ console.log('click');
40
+ e.preventDefault();
41
+ document.querySelectorAll(ElementEnum.overlay).forEach(overlay => {
42
+ HcOverlay.close(overlay);
43
+ })
44
+ });
45
+ });
46
+
47
+ //Close all overlays on escape key
48
+ document.onkeyup = function(event) {
49
+ if (event.key === 'Escape') {
50
+ document.querySelectorAll(ElementEnum.overlay).forEach(overlay => {
51
+ HcOverlay.close(overlay);
52
+ })
53
+ }
54
+ }
55
+ });
56
+ }
57
+
58
+ show(element) {
59
+ element.classList.add('hc-overlay-show');
60
+ document.body.classList.add('hc-overlay-lock');
61
+ document.dispatchEvent(this.showEvent);
62
+ }
63
+
64
+ close(element) {
65
+ element.classList.remove('hc-overlay-show');
66
+ document.body.classList.remove('hc-overlay-lock');
67
+ document.dispatchEvent(this.hideEvent);
68
+ }
69
+
70
+ createEvent(element) {
71
+ this.showEvent = new CustomEvent("show.hc.overlay", {
72
+ detail: {
73
+ element
74
+ }
75
+ });
76
+
77
+ this.hideEvent = new CustomEvent("hide.hc.overlay", {
78
+ detail: {
79
+ element
80
+ }
81
+ });
82
+ }
83
+ }
84
+
85
+ const hc_overlay = function (elements) {
86
+ return new HcOverlay(elements);
87
+ }
88
+ export default hc_overlay;
@@ -0,0 +1,77 @@
1
+ /* Overlay
2
+ /* ============================================= */
3
+ .hc-overlay {
4
+ display: none;
5
+ position: fixed;
6
+ z-index: var(--hc-overlay--z-index, 9000);
7
+ color: var(--hc-overlay--color, #000);
8
+ background-color: var(--hc-overlay--background-color, #fff);
9
+ padding: var(--hc-overlay--padding, 20px);
10
+ top: 0;
11
+ height: 100%;
12
+ width: 100%;
13
+ max-width: var(--hc-overlay--width, 675px);
14
+ overflow: auto;
15
+ transition-property: var(--hc-overlay--transition-property, transform);
16
+ transition-duration: var(--hc-overlay--transition-duration, 0.4s);
17
+ transition-timing-function: var(--hc-overlay--transition-timing-function, ease);
18
+
19
+ &--right {
20
+ right: 0;
21
+ transform: translateX(100%);
22
+ }
23
+
24
+ &--left,
25
+ &--full {
26
+ left: 0;
27
+ transform: translateX(-100%);
28
+ }
29
+
30
+ &--full {
31
+ max-width: none;
32
+ }
33
+
34
+ &.hc-overlay-init {
35
+ display: block;
36
+
37
+ & + .hc-overlay__background {
38
+ display: block;
39
+ }
40
+ }
41
+
42
+ &.hc-overlay-show {
43
+ transform: translateX(0);
44
+
45
+ & + .hc-overlay__background {
46
+ opacity: 1;
47
+ pointer-events: auto;
48
+ }
49
+ }
50
+
51
+ &__background {
52
+ display: none;
53
+ position: fixed;
54
+ z-index: calc(var(--hc-overlay--z-index, 9000) - 1);
55
+ background-color: var(--hc-overlay-background--background-color, rgba(0, 0, 0, 0.6));
56
+ top: 0;
57
+ left: 0;
58
+ right: 0;
59
+ bottom: 0;
60
+ opacity: 0;
61
+ pointer-events: none;
62
+ transition-property: var(--hc-overlay-background--transition-property, opacity);
63
+ transition-duration: var(--hc-overlay-background--transition-duration, 0.4s);
64
+ transition-timing-function: var(--hc-overlay-background--transition-timing-function, ease);
65
+ }
66
+
67
+ &__close {
68
+ position: absolute;
69
+ right: var(--hc-overlay-close--right, 30px);
70
+ top: var(--hc-overlay-close--top, 30px);
71
+ cursor: pointer;
72
+ }
73
+ }
74
+
75
+ .hc-overlay-lock {
76
+ overflow: hidden;
77
+ }
@@ -1 +1 @@
1
- (()=>{"use strict";var a={812:(a,t,o)=>{function e(a,t,o){return t in a?Object.defineProperty(a,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[t]=o,a}var l=function a(){!function(a,t){if(!(a instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a)};e(l,"tooltip","[data-hc-tooltip], [data-hc-popover]"),e(l,"popover","[data-hc-popover]"),e(l,"scrollSmooth","[data-hc-smooth-scroll]"),e(l,"modal","[data-hc-modal]"),e(l,"modalClose","[data-hc-modal-close]"),e(l,"lightboxAttr","data-hc-lightbox"),e(l,"lightbox","[".concat(l.lightboxAttr,"]")),e(l,"dropdown","[data-hc-dropdown]"),e(l,"collapse","[data-hc-collapse]"),e(l,"collapseItem","[data-hc-collapse-item]"),e(l,"popin","[data-hc-popin]"),e(l,"tab","[data-hc-tab]"),e(l,"toggle","[data-hc-toggle]"),e(l,"slider","[data-hc-slider]"),e(l,"scrollspy","[data-hc-scrollspy]"),e(l,"scrollspyNav","[data-hc-scrollspy-nav]"),e(l,"scrollspyNavItem","[data-hc-scrollspy-nav-item]"),e(l,"scrollRevealParent","[data-hc-scroll-reveal-parent]"),e(l,"scrollRevealChildren","[data-hc-scroll-reveal-parent] > *:not([data-hc-noscroll-reveal]):not([data-hc-scroll-reveal-parent])"),e(l,"scrollReveal","[data-hc-scroll-reveal]")},539:(a,t,o)=>{function e(a,t,o){return t in a?Object.defineProperty(a,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[t]=o,a}var l=function a(){!function(a,t){if(!(a instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a)};e(l,"attrHref","data-hc-smooth-scroll-href"),e(l,"attrShift","data-hc-smooth-scroll-shift")}},t={};function o(e){var l=t[e];if(void 0!==l)return l.exports;var r=t[e]={exports:{}};return a[e](r,r.exports,o),r.exports}o.d=(a,t)=>{for(var e in t)o.o(t,e)&&!o.o(a,e)&&Object.defineProperty(a,e,{enumerable:!0,get:t[e]})},o.o=(a,t)=>Object.prototype.hasOwnProperty.call(a,t),o(812),o(539)})();
1
+ (()=>{"use strict";var a={812:(a,t,o)=>{function e(a,t,o){return t in a?Object.defineProperty(a,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[t]=o,a}var l=function a(){!function(a,t){if(!(a instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a)};e(l,"tooltip","[data-hc-tooltip], [data-hc-popover]"),e(l,"popover","[data-hc-popover]"),e(l,"scrollSmooth","[data-hc-smooth-scroll]"),e(l,"modal","[data-hc-modal]"),e(l,"modalClose","[data-hc-modal-close]"),e(l,"lightboxAttr","data-hc-lightbox"),e(l,"lightbox","[".concat(l.lightboxAttr,"]")),e(l,"dropdown","[data-hc-dropdown]"),e(l,"collapse","[data-hc-collapse]"),e(l,"collapseItem","[data-hc-collapse-item]"),e(l,"popin","[data-hc-popin]"),e(l,"tab","[data-hc-tab]"),e(l,"toggle","[data-hc-toggle]"),e(l,"slider","[data-hc-slider]"),e(l,"scrollspy","[data-hc-scrollspy]"),e(l,"scrollspyNav","[data-hc-scrollspy-nav]"),e(l,"scrollspyNavItem","[data-hc-scrollspy-nav-item]"),e(l,"scrollRevealParent","[data-hc-scroll-reveal-parent]"),e(l,"scrollRevealChildren","[data-hc-scroll-reveal-parent] > *:not([data-hc-noscroll-reveal]):not([data-hc-scroll-reveal-parent])"),e(l,"scrollReveal","[data-hc-scroll-reveal]"),e(l,"overlay","[data-hc-overlay]")},539:(a,t,o)=>{function e(a,t,o){return t in a?Object.defineProperty(a,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[t]=o,a}var l=function a(){!function(a,t){if(!(a instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a)};e(l,"attrHref","data-hc-smooth-scroll-href"),e(l,"attrShift","data-hc-smooth-scroll-shift")}},t={};function o(e){var l=t[e];if(void 0!==l)return l.exports;var r=t[e]={exports:{}};return a[e](r,r.exports,o),r.exports}o.d=(a,t)=>{for(var e in t)o.o(t,e)&&!o.o(a,e)&&Object.defineProperty(a,e,{enumerable:!0,get:t[e]})},o.o=(a,t)=>Object.prototype.hasOwnProperty.call(a,t),o(812),o(539)})();