@iris.interactive/handcook 2.5.0 → 2.6.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.
package/mix-manifest.json CHANGED
@@ -1,5 +1,8 @@
1
1
  {
2
+ "/public/scripts/index.js": "/public/scripts/index.js",
3
+ "/public/styles/style.css": "/public/styles/style.css",
2
4
  "/public/index.html": "/public/index.html",
5
+ "/public/scripts/handcook.js": "/public/scripts/handcook.js",
3
6
  "/public/styles/scss/_utils.scss": "/public/styles/scss/_utils.scss",
4
7
  "/public/styles/scss/_variables.scss": "/public/styles/scss/_variables.scss",
5
8
  "/public/styles/scss/handcook.scss": "/public/styles/scss/handcook.scss",
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "@iris.interactive/handcook",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
4
4
  "description": "The web cooking by IRIS Interactive",
5
5
  "main": "./public/scripts/index.js",
6
6
  "scripts": {
7
7
  "build": "mix",
8
8
  "build:production": "mix --production",
9
9
  "start": "mix watch",
10
- "hot": "mix watch --hot",
11
- "prepare": "mix -- --env prepare"
10
+ "hot": "mix watch --hot"
12
11
  },
13
12
  "keywords": [
14
13
  "IRIS Interactive",
@@ -26,6 +25,7 @@
26
25
  "browser-sync-webpack-plugin": "^2.3.0",
27
26
  "iconfont-plugin-webpack": "^1.1.4",
28
27
  "laravel-mix": "^6.0.19",
28
+ "laravel-mix-glob": "^1.1.10",
29
29
  "mix-env-file": "^0.1.1",
30
30
  "postcss": "^8.3.0",
31
31
  "resolve-url-loader": "^4.0.0",
package/public/index.html CHANGED
@@ -42,41 +42,41 @@
42
42
  color: blue;
43
43
  }
44
44
 
45
- .swiper {
45
+ .hc-slider {
46
46
  position: relative;
47
47
  margin: 40px 0;
48
48
  }
49
49
 
50
- #slider-full .swiper-slide {
50
+ #slider-full .hc-slider-slide {
51
51
  width: 100%;
52
52
  }
53
53
 
54
- #slider-full .swiper-slide img {
54
+ #slider-full .hc-slider-slide img {
55
55
  width: 100%;
56
56
  }
57
57
 
58
- .swiper-slide {
58
+ .hc-slider-slide {
59
59
  width: 500px;
60
60
  margin-right: 40px;
61
61
  }
62
62
 
63
- .swiper-slide:last-child {
63
+ .hc-slider-slide:last-child {
64
64
  margin-right: 0;
65
65
  }
66
66
 
67
- .swiper-button-prev,
68
- .swiper-button-next {
67
+ .hc-slider-button-prev,
68
+ .hc-slider-button-next {
69
69
  position: absolute;
70
70
  top: 50%;
71
71
  transform: translateY(-50%);
72
72
  z-index: 1;
73
73
  }
74
74
 
75
- .swiper-button-prev {
75
+ .hc-slider-button-prev {
76
76
  left: 0;
77
77
  }
78
78
 
79
- .swiper-button-prev:before {
79
+ .hc-slider-button-prev:before {
80
80
  content: "<";
81
81
  display: flex;
82
82
  align-items: center;
@@ -87,11 +87,11 @@
87
87
  background-color: #fff;
88
88
  }
89
89
 
90
- .swiper-button-next {
90
+ .hc-slider-button-next {
91
91
  right: 0;
92
92
  }
93
93
 
94
- .swiper-button-next:before {
94
+ .hc-slider-button-next:before {
95
95
  content: ">";
96
96
  display: flex;
97
97
  align-items: center;
@@ -102,14 +102,14 @@
102
102
  background-color: #fff;
103
103
  }
104
104
 
105
- .swiper-pagination {
105
+ .hc-slider-pagination {
106
106
  display: inline-flex;
107
107
  gap: 10px;
108
108
  margin: 30px 50% 0;
109
109
  transform: translate(-50%);
110
110
  }
111
111
 
112
- .swiper-pagination-bullet {
112
+ .hc-slider-pagination-bullet {
113
113
  width: 10px;
114
114
  height: 10px;
115
115
  background-color: rgba(255, 0, 0, 0.35);
@@ -117,7 +117,7 @@
117
117
  border-radius: 50%;
118
118
  }
119
119
 
120
- .swiper-pagination-bullet.swiper-pagination-bullet-active {
120
+ .hc-slider-pagination-bullet.hc-slider-pagination-bullet-active {
121
121
  background-color: red;
122
122
  }
123
123
  </style>
@@ -14,21 +14,26 @@
14
14
  */
15
15
 
16
16
  import ElementEnum from "../../enumerators/element.enum";
17
- import "./collapse.component.css";
17
+ import "./collapse.component.scss";
18
18
  import Collapse from "bootstrap/js/src/collapse";
19
19
 
20
- class HcCollapse {
20
+ export class HcCollapse {
21
+
22
+ showEvent;
23
+ shownEvent;
24
+ hideEvent;
25
+ hiddenEvent;
21
26
 
22
27
  constructor(elements = ElementEnum.collapse, type = "collapse") {
28
+ this.createEvent();
23
29
  const collapseElementList = [].slice.call(document.querySelectorAll(elements));
24
30
  const collapseList = collapseElementList.map(function (collapseElement) {
25
31
  const parent = collapseElement.getAttribute('data-hc-collapse-parent');
26
- let option = {};
32
+ let option = {
33
+ toggle: false
34
+ };
27
35
  if (parent !== null) {
28
- option = {
29
- parent: parent,
30
- toggle: false
31
- }
36
+ option.parent = parent;
32
37
  }
33
38
  return new Collapse(collapseElement, option);
34
39
  });
@@ -40,10 +45,32 @@ class HcCollapse {
40
45
  });
41
46
  });
42
47
  });
48
+ document.querySelectorAll('[data-hc-collapse]').forEach(trigger => {
49
+ trigger.addEventListener('hide.bs.collapse', (e) => {
50
+ trigger.dispatchEvent(this.hideEvent);
51
+ });
52
+ trigger.addEventListener('hidden.bs.collapse', (e) => {
53
+ trigger.dispatchEvent(this.hiddenEvent);
54
+ });
55
+ trigger.addEventListener('show.bs.collapse', (e) => {
56
+ trigger.dispatchEvent(this.showEvent);
57
+ });
58
+ trigger.addEventListener('shown.bs.collapse', (e) => {
59
+ trigger.dispatchEvent(this.shownEvent);
60
+ });
61
+ });
62
+ }
63
+
64
+ createEvent() {
65
+ this.showEvent = new Event("show.hc.collapse");
66
+ this.shownEvent = new Event("shown.hc.collapse");
67
+ this.hideEvent = new Event("hide.hc.collapse");
68
+ this.hiddenEvent = new Event("hidden.hc.collapse");
43
69
  }
44
70
 
45
71
  }
46
72
 
47
- export const hc_collapse = function (trigger) {
73
+ const hc_collapse = function (trigger) {
48
74
  return new HcCollapse(trigger);
49
- }
75
+ };
76
+ export default hc_collapse;
@@ -17,29 +17,56 @@
17
17
  import ElementEnum from "../../enumerators/element.enum";
18
18
  import tippy from "tippy.js";
19
19
  import "tippy.js/dist/tippy.css";
20
- import "tippy.js/themes/light.css";
20
+ import "./dropdown.component.scss";
21
21
 
22
- class HcDropdown {
22
+ export class HcDropdown {
23
23
 
24
- instance;
24
+ showEvent;
25
+ shownEvent;
26
+ hideEvent;
27
+ hiddenEvent;
28
+
29
+ instances = [];
25
30
 
26
31
  constructor(elements = ElementEnum.dropdown) {
32
+ this.createEvent();
27
33
  document.querySelectorAll(elements).forEach(element => {
28
34
 
29
35
  const template = document.querySelector(element.dataset.hcDropdownMenu);
30
- this.instance = tippy(element, {
36
+ const tippyObject = tippy(element, {
31
37
  trigger: 'click',
32
38
  allowHTML: true,
33
39
  content: template.innerHTML,
34
40
  arrow: false,
35
41
  placement: "bottom",
36
- theme: "light",
37
- interactive: true
42
+ theme: "dropdown",
43
+ interactive: true,
44
+ onShow: (instance) => {
45
+ instance.reference.dispatchEvent(this.showEvent)
46
+ },
47
+ onShown: (instance) => {
48
+ instance.reference.dispatchEvent(this.shownEvent)
49
+ },
50
+ onHide: (instance) => {
51
+ instance.reference.dispatchEvent(this.hideEvent)
52
+ },
53
+ onHidden: (instance) => {
54
+ instance.reference.dispatchEvent(this.hiddenEvent)
55
+ },
38
56
  });
57
+ this.instances.push(tippyObject);
39
58
  });
40
59
  }
60
+
61
+ createEvent() {
62
+ this.showEvent = new Event('show.hc.dropdown');
63
+ this.shownEvent = new Event('shown.hc.dropdown');
64
+ this.hideEvent = new Event('hide.hc.dropdown');
65
+ this.hiddenEvent = new Event('hidden.hc.dropdown');
66
+ }
41
67
  }
42
68
 
43
- export const hc_dropdown = function (trigger) {
69
+ const hc_dropdown = function (trigger) {
44
70
  return new HcDropdown(trigger);
45
- }
71
+ }
72
+ export default hc_dropdown;
@@ -0,0 +1,48 @@
1
+ /*!
2
+ * IRIS Interactive
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is no subject to a specific license
7
+ * but it belongs to the company IRIS Interactive.
8
+ * You can contact IRIS Interactive at the following
9
+ * address: contact@iris-interactive.fr
10
+ *
11
+ * @author Lucas ROCHE
12
+ * @date 24/02/2022 14:19
13
+ * @copyright Copyright (c) 2002-2022 IRIS Interactive, Inc. (http://www.iris-interactive.fr)
14
+ */
15
+
16
+ .tippy-box[data-theme~=dropdown] {
17
+ color: #26323d;
18
+ box-shadow: 0 0 20px 4px rgba(154, 161, 177, .15), 0 4px 80px -8px rgba(36, 40, 47, .25), 0 4px 4px -2px rgba(91, 94, 105, .15);
19
+ background-color: #fff
20
+ }
21
+
22
+ .tippy-box[data-theme~=dropdown] .tippy-content {
23
+ padding: 0;
24
+ }
25
+
26
+ .tippy-box[data-theme~=dropdown][data-placement^=top] > .tippy-arrow:before {
27
+ border-top-color: #fff
28
+ }
29
+
30
+ .tippy-box[data-theme~=dropdown][data-placement^=bottom] > .tippy-arrow:before {
31
+ border-bottom-color: #fff
32
+ }
33
+
34
+ .tippy-box[data-theme~=dropdown][data-placement^=left] > .tippy-arrow:before {
35
+ border-left-color: #fff
36
+ }
37
+
38
+ .tippy-box[data-theme~=dropdown][data-placement^=right] > .tippy-arrow:before {
39
+ border-right-color: #fff
40
+ }
41
+
42
+ .tippy-box[data-theme~=dropdown] > .tippy-backdrop {
43
+ background-color: #fff
44
+ }
45
+
46
+ .tippy-box[data-theme~=dropdown] > .tippy-svg-arrow {
47
+ fill: #fff
48
+ }
@@ -16,11 +16,13 @@
16
16
 
17
17
  import LazyLoad from "vanilla-lazyload";
18
18
 
19
- export const hc_lazyload = function() {
19
+ const hc_lazyload = function() {
20
20
  return new LazyLoad({
21
21
  elements_selector: '[data-hc-src], [data-hc-bg], [data-hc-bg-hidpi]',
22
22
  data_src: 'hc-src',
23
23
  data_bg: 'hc-bg',
24
24
  data_bg_hidpi: 'hc-bg-hidpi'
25
25
  });
26
- }
26
+ }
27
+
28
+ export default hc_lazyload;
@@ -17,16 +17,20 @@ import {Fancybox} from "@fancyapps/ui";
17
17
  import '@fancyapps/ui/dist/fancybox.css';
18
18
  import ElementEnum from "../../enumerators/element.enum";
19
19
 
20
- class HcLightbox {
20
+ export class HcLightbox {
21
21
 
22
- instance = [];
22
+ instance;
23
23
 
24
24
  constructor(elements = ElementEnum.lightbox) {
25
- Fancybox.bind(elements);
25
+ Fancybox.bind(elements,{
26
+ groupAll: true
27
+ });
26
28
  this.instance = Fancybox.getInstance();
27
29
  }
28
30
  }
29
31
 
30
- export const hc_lightbox = function (trigger, options) {
31
- return new HcLightbox(trigger, options);
32
- }
32
+ const hc_lightbox = function (trigger) {
33
+ return new HcLightbox(trigger);
34
+ }
35
+
36
+ export default hc_lightbox;
@@ -16,9 +16,9 @@
16
16
  import ElementEnum from "../../enumerators/element.enum";
17
17
  import {Fancybox} from "@fancyapps/ui";
18
18
  import '@fancyapps/ui/dist/fancybox.css';
19
- import './modal.component.css';
19
+ import './modal.component.scss';
20
20
 
21
- class HcModal {
21
+ export class HcModal {
22
22
 
23
23
  instance = [];
24
24
  defaultOptions = {
@@ -40,6 +40,7 @@ class HcModal {
40
40
  }
41
41
  }
42
42
 
43
- export const hc_modal = function (trigger, options) {
43
+ const hc_modal = function (trigger, options) {
44
44
  return new HcModal(trigger, options);
45
- }
45
+ }
46
+ export default hc_modal;
@@ -17,9 +17,10 @@ import ElementEnum from "../../enumerators/element.enum";
17
17
  import Swiper from "swiper/bundle";
18
18
  import "swiper/css";
19
19
 
20
- class HcSlider {
20
+ export class HcSlider {
21
21
 
22
22
  slider;
23
+ instances = [];
23
24
 
24
25
  // Options
25
26
  options = {};
@@ -30,7 +31,8 @@ class HcSlider {
30
31
  this.slider = element;
31
32
  this.setOptions();
32
33
  this.buildDom();
33
- new Swiper(element, this.options);
34
+ const instance = new Swiper(element, this.options);
35
+ this.instances.push(instance);
34
36
  this.initOptions();
35
37
  });
36
38
  }
@@ -66,7 +68,7 @@ class HcSlider {
66
68
  // on crée la div wrapper et on insére les slider item dedans
67
69
  this.slider.classList.add('swiper');
68
70
  const wrapperElement = document.createElement("div");
69
- wrapperElement.classList.add( "swiper-wrapper" );
71
+ wrapperElement.classList.add("swiper-wrapper");
70
72
  this.slider.appendChild(wrapperElement);
71
73
  this.slider.querySelectorAll('.swiper-wrapper').forEach(wrapper => {
72
74
  items.forEach(item => {
@@ -78,28 +80,34 @@ class HcSlider {
78
80
  if (this.slider.hasAttribute('data-hc-slider-pagination')) {
79
81
 
80
82
  const paginationElement = document.createElement("div");
81
- paginationElement.classList.add("swiper-pagination");
83
+ paginationElement.classList.add("hc-slider-pagination");
82
84
  this.slider.appendChild(paginationElement);
83
85
 
84
86
  this.options['pagination'] = {
85
- el: '.swiper-pagination',
87
+ el: '.hc-slider-pagination',
86
88
  type: 'bullets',
87
- clickable: true
89
+ clickable: true,
90
+ bulletClass: 'hc-slider-pagination-bullet',
91
+ clickableClass: 'hc-slider-pagination-clickable',
92
+ currentClass: 'hc-slider-pagination-current',
93
+ bulletActiveClass: 'hc-slider-pagination-bullet-active'
88
94
  };
89
95
  }
90
96
  if (this.slider.hasAttribute('data-hc-slider-arrows')) {
91
97
 
92
98
  const buttonPrev = document.createElement("div");
93
- buttonPrev.classList.add("swiper-button-prev");
99
+ buttonPrev.classList.add("hc-slider-button-prev");
94
100
  this.slider.appendChild(buttonPrev);
95
101
 
96
102
  const buttonNext = document.createElement("div");
97
- buttonNext.classList.add("swiper-button-next");
103
+ buttonNext.classList.add("hc-slider-button-next");
98
104
  this.slider.appendChild(buttonNext);
99
105
 
100
106
  this.options['navigation'] = {
101
- nextEl: '.swiper-button-next',
102
- prevEl: '.swiper-button-prev',
107
+ nextEl: '.hc-slider-button-next',
108
+ prevEl: '.hc-slider-button-prev',
109
+ disabledClass: 'hc-slider-button-disabled',
110
+ hiddenClass: 'hc-slider-button-hidden',
103
111
  };
104
112
  }
105
113
  }
@@ -113,11 +121,36 @@ class HcSlider {
113
121
  forceToAxis: true,
114
122
  },
115
123
  grabCursor: true,
116
- loop: false
124
+ loop: false,
125
+ on: {
126
+ init: (swiper) => {
127
+
128
+ // layout
129
+ swiper.$el.find('.swiper-wrapper').addClass('hc-slider-wrapper');
130
+
131
+ // slide item
132
+ swiper.$el.find('.swiper-slide').addClass('hc-slider-slide');
133
+ swiper.$el.find('.swiper-slide-active').addClass('hc-slider-slide-active');
134
+ swiper.$el.find('.swiper-slide-next').addClass('hc-slider-slide-next');
135
+ swiper.$el.find('.swiper-slide-prev').addClass('hc-slider-slide-prev');
136
+ },
137
+ slideChangeTransitionEnd: (swiper) => {
138
+
139
+ // slide item
140
+ swiper.$el.find('.swiper-slide')
141
+ .removeClass('hc-slider-slide-active')
142
+ .removeClass('hc-slider-slide-next')
143
+ .removeClass('hc-slider-slide-prev');
144
+ swiper.$el.find('.swiper-slide-active').addClass('hc-slider-slide-active');
145
+ swiper.$el.find('.swiper-slide-next').addClass('hc-slider-slide-next');
146
+ swiper.$el.find('.swiper-slide-prev').addClass('hc-slider-slide-prev');
147
+ }
148
+ }
117
149
  };
118
150
  }
119
151
  }
120
152
 
121
- export const hc_slider = function (trigger) {
153
+ const hc_slider = function (trigger) {
122
154
  return new HcSlider(trigger);
123
- }
155
+ }
156
+ export default hc_slider;
@@ -15,7 +15,7 @@
15
15
 
16
16
  import ElementEnum from "../../enumerators/element.enum";
17
17
 
18
- class HcSmoothScroll {
18
+ export class HcSmoothScroll {
19
19
 
20
20
  constructor(triggerAttribute = ElementEnum.scrollSmooth, durationAnimation = 1000) {
21
21
 
@@ -59,6 +59,7 @@ class HcSmoothScroll {
59
59
  }
60
60
  }
61
61
 
62
- export const hc_smooth_scroll = function(trigger, options) {
62
+ const hc_smooth_scroll = function(trigger, options) {
63
63
  new HcSmoothScroll(trigger, options);
64
- }
64
+ }
65
+ export default hc_smooth_scroll;
@@ -14,10 +14,15 @@
14
14
  */
15
15
 
16
16
  import ElementEnum from "../../enumerators/element.enum";
17
- import "./tab.component.css";
17
+ import "./tab.component.scss";
18
18
  import Tab from "bootstrap/js/src/tab";
19
19
 
20
- class HcTab {
20
+ export class HcTab {
21
+
22
+ showEvent;
23
+ shownEvent;
24
+ hideEvent;
25
+ hiddenEvent;
21
26
 
22
27
  constructor(elements = ElementEnum.tab) {
23
28
  this.buildDOM();
@@ -29,7 +34,21 @@ class HcTab {
29
34
  event.preventDefault()
30
35
  tabTrigger.show()
31
36
  })
32
- })
37
+ });
38
+ document.querySelectorAll(elements).forEach(trigger => {
39
+ trigger.addEventListener('hide.bs.tab', (e) => {
40
+ trigger.dispatchEvent(this.hideEvent);
41
+ });
42
+ trigger.addEventListener('show.bs.tab', (e) => {
43
+ trigger.dispatchEvent(this.showEvent);
44
+ });
45
+ trigger.addEventListener('shown.bs.tab', (e) => {
46
+ trigger.dispatchEvent(this.shownEvent);
47
+ });
48
+ trigger.addEventListener('hidden.bs.tab', (e) => {
49
+ trigger.dispatchEvent(this.hiddenEvent);
50
+ });
51
+ });
33
52
  }
34
53
 
35
54
  buildDOM() {
@@ -37,10 +56,18 @@ class HcTab {
37
56
  if (!wrapper.classList.contains("nav")) {
38
57
  wrapper.classList.add("nav")
39
58
  }
40
- })
59
+ });
60
+ }
61
+
62
+ createEvent() {
63
+ this.showEvent = new Event("show.hc.collapse");
64
+ this.shownEvent = new Event("shown.hc.collapse");
65
+ this.hideEvent = new Event("hide.hc.collapse");
66
+ this.hiddenEvent = new Event("hidden.hc.collapse");
41
67
  }
42
68
  }
43
69
 
44
- export const hc_tab = function (trigger) {
70
+ const hc_tab = function (trigger) {
45
71
  return new HcTab(trigger);
46
- }
72
+ }
73
+ export default hc_tab;
@@ -16,7 +16,7 @@
16
16
 
17
17
  import ElementEnum from "../../enumerators/element.enum";
18
18
 
19
- class HcToggle {
19
+ export class HcToggle {
20
20
 
21
21
  constructor(elements = ElementEnum.toggle) {
22
22
  document.querySelectorAll(elements).forEach(element => {
@@ -45,6 +45,7 @@ class HcToggle {
45
45
  }
46
46
  }
47
47
 
48
- export const hc_toggle = function (trigger) {
48
+ const hc_toggle = function (trigger) {
49
49
  return new HcToggle(trigger);
50
- }
50
+ }
51
+ export default hc_toggle;
@@ -19,16 +19,23 @@ import "tippy.js/dist/tippy.css"
19
19
  import ElementEnum from "../../enumerators/element.enum";
20
20
  import TooltipEnum from "../../enumerators/tooltip.enum";
21
21
 
22
- class HcTooltip {
22
+ export class HcTooltip {
23
+
24
+ showEvent;
25
+ shownEvent;
26
+ hideEvent;
27
+ hiddenEvent;
23
28
 
24
29
  instances = [];
25
30
  defaultOptions = {
26
31
  placement: '',
27
32
  content: '',
28
- trigger: ''
33
+ trigger: '',
34
+ allowHTML: true
29
35
  };
30
36
 
31
37
  constructor(elements = ElementEnum.tooltip, overrideOptions = {}) {
38
+ this.createEvent();
32
39
  document.querySelectorAll(elements).forEach(element => {
33
40
  let options = {};
34
41
  Object.assign(options, this.defaultOptions, overrideOptions);
@@ -40,11 +47,30 @@ class HcTooltip {
40
47
  e.preventDefault();
41
48
  });
42
49
  }
50
+ options.onShow = (instance) => {
51
+ instance.reference.dispatchEvent(this.showEvent);
52
+ }
53
+ options.onShown = (instance) => {
54
+ instance.reference.dispatchEvent(this.shownEvent);
55
+ }
56
+ options.onHide = (instance) => {
57
+ instance.reference.dispatchEvent(this.hideEvent);
58
+ }
59
+ options.onHidden = (instance) => {
60
+ instance.reference.dispatchEvent(this.hiddenEvent);
61
+ }
43
62
  const instance = tippy(element, options);
44
63
  this.instances.push(instance);
45
64
  });
46
65
  }
47
66
 
67
+ createEvent() {
68
+ this.showEvent = new Event('show.hc.tooltip');
69
+ this.shownEvent = new Event('shown.hc.tooltip');
70
+ this.hideEvent = new Event('hide.hc.tooltip');
71
+ this.hiddenEvent = new Event('hidden.hc.tooltip');
72
+ }
73
+
48
74
  show() {
49
75
  this.instances.forEach(instance => {
50
76
  instance.show();
@@ -70,6 +96,7 @@ class HcTooltip {
70
96
  }
71
97
  }
72
98
 
73
- export const hc_tooltip = function (trigger, options) {
99
+ const hc_tooltip = function (trigger, options) {
74
100
  return new HcTooltip(trigger, options);
75
- };
101
+ }
102
+ export default hc_tooltip;