perfect-gui 4.3.0 → 4.3.2

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.
@@ -97,19 +97,33 @@ function w(y) {
97
97
 
98
98
  .p-gui__image-container {
99
99
  width: 100%;
100
- display: grid;
101
- grid-template-columns: repeat(auto-fill, 32%);
102
- justify-content: space-between;
103
100
  padding: 0 2%;
101
+ display: flex;
102
+ justify-content: flex-start;
103
+ flex-wrap: wrap;
104
104
  }
105
105
 
106
106
  .p-gui__image {
107
- aspect-ratio: 1 / 1;
108
107
  background-size: cover;
109
108
  cursor: pointer;
110
109
  position: relative;
111
- margin-top: 1px;
112
- margin-bottom: 19px;
110
+ margin: 1px 2.5px 19px 2.5px;
111
+ border-radius: var(--main-border-radius);
112
+ flex: 0 0 calc(33.333% - 5px);
113
+ height: 90px;
114
+ background-position: center;
115
+ }
116
+
117
+ .p-gui__image--selected::after {
118
+ position: absolute;
119
+ top: 0;
120
+ left: 0;
121
+ width: 100%;
122
+ height: 100%;
123
+ content: '';
124
+ border: 1px solid #06FF89;
125
+ box-sizing: border-box;
126
+ border-radius: var(--main-border-radius);
113
127
  }
114
128
 
115
129
  .p-gui__image-text {
@@ -399,13 +413,13 @@ function w(y) {
399
413
  `
400
414
  );
401
415
  }
402
- class h {
416
+ class g {
403
417
  constructor(e = {}) {
404
418
  if (e.container ? (this.container = typeof e.container == "string" ? document.querySelector(e.container) : e.container, this.position_type = "absolute") : (this.container = document.body, this.position_type = "fixed"), this.propReferences = [], this.folders = [], e.isFolder) {
405
419
  this._folderConstructor(e.folderOptions);
406
420
  return;
407
421
  }
408
- this.name = e != null && typeof e.name == "string" ? e.name : "", this.backgroundColor = e.color || null, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(e.position), this instanceof h && (typeof h[h.instanceCounter] != "number" ? h[h.instanceCounter] = 0 : h[h.instanceCounter]++), this.instanceId = h[h.instanceCounter], this.wrapperWidth = e.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${w(this.position_type)}`), this._styleInstance(), this._addWrapper(), this.wrapper.setAttribute("data-corner-x", this.screenCorner.x), this.wrapper.setAttribute("data-corner-y", this.screenCorner.y), e.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, e.draggable == !0 && this._makeDraggable(), this.closed = !1, e.closed && this.toggleClose();
422
+ this.name = e != null && typeof e.name == "string" ? e.name : "", this.backgroundColor = e.color || null, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(e.position), this instanceof g && (typeof g[g.instanceCounter] != "number" ? g[g.instanceCounter] = 0 : g[g.instanceCounter]++), this.instanceId = g[g.instanceCounter], this.wrapperWidth = e.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${w(this.position_type)}`), this._styleInstance(), this._addWrapper(), this.wrapper.setAttribute("data-corner-x", this.screenCorner.x), this.wrapper.setAttribute("data-corner-y", this.screenCorner.y), e.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, e.draggable == !0 && this._makeDraggable(), this.closed = !1, e.closed && this.toggleClose();
409
423
  }
410
424
  _styleInstance() {
411
425
  let e = this._getScrollbarWidth(this.container);
@@ -495,59 +509,67 @@ class h {
495
509
  else
496
510
  throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
497
511
  let r = i.replace(/^.*[\\\/]/, ""), o;
498
- e.name == null ? o = r : o = typeof e.name == "string" && e.name || " ", this.imageContainer || (this.imageContainer = this._createElement({
512
+ e.name == null ? o = r : o = typeof e.name == "string" && e.name || " ";
513
+ const s = e.selected === !0, n = e.selectionBorder !== !1;
514
+ let a = "";
515
+ e.width && (typeof e.width == "number" && (e.width += "px"), a += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), a += `height: ${e.height}; `), this.imageContainer || (this.imageContainer = this._createElement({
499
516
  class: "p-gui__image-container"
500
517
  }));
501
- var n = this._createElement({
518
+ var l = this._createElement({
502
519
  class: "p-gui__image",
503
- inline: `background-image: url(${i})`,
520
+ inline: "background-image: url(" + i + "); " + a,
504
521
  parent: this.imageContainer
505
522
  });
506
- this._createElement({
507
- parent: n,
523
+ s && n && l.classList.add("p-gui__image--selected"), this._createElement({
524
+ parent: l,
508
525
  class: "p-gui__image-text",
509
526
  textContent: o
510
- }), typeof t == "function" && (n.onclick = () => t({ path: i, text: o }));
527
+ }), typeof t == "function" && (l.onclick = () => {
528
+ let u = this.imageContainer.querySelectorAll(".p-gui__image--selected");
529
+ for (let d = 0; d < u.length; d++)
530
+ u[d].classList.remove("p-gui__image--selected");
531
+ n && l.classList.add("p-gui__image--selected"), t({ path: i, text: o });
532
+ });
511
533
  }
512
534
  slider(e = {}, t) {
513
535
  if (typeof e != "object")
514
536
  throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);
515
- let i = typeof e.name == "string" && e.name || " ", r = !1, o = null, n = e.obj || e.object, s = e.prop || e.property, a = typeof e.value == "number" ? e.value : null, l = e.min ?? 0, f = e.max ?? 1, g = e.step || (f - l) / 100;
537
+ let i = typeof e.name == "string" && e.name || " ", r = !1, o = null, s = e.obj || e.object, n = e.prop || e.property, a = typeof e.value == "number" ? e.value : null, l = e.min ?? 0, u = e.max ?? 1, d = e.step || (u - l) / 100;
516
538
  if (a !== null)
517
- (s != null || n != null) && console.warn('[GUI] slider() "obj" and "property" parameters are ignored when a "value" parameter is used.');
518
- else if (s != null && n != null) {
519
- if (typeof s != "string")
520
- throw Error(`[GUI] slider() "prop" (or "property") parameter must be an string. Received: ${typeof s}.`);
521
- if (typeof n != "object")
522
- throw Error(`[GUI] slider() "obj" (or "object") parameter must be an object. Received: ${typeof n}.`);
523
- i == " " && (i = s), o = this.propReferences.push(n[s]) - 1, r = !0;
539
+ (n != null || s != null) && console.warn('[GUI] slider() "obj" and "property" parameters are ignored when a "value" parameter is used.');
540
+ else if (n != null && s != null) {
541
+ if (typeof n != "string")
542
+ throw Error(`[GUI] slider() "prop" (or "property") parameter must be an string. Received: ${typeof n}.`);
543
+ if (typeof s != "object")
544
+ throw Error(`[GUI] slider() "obj" (or "object") parameter must be an object. Received: ${typeof s}.`);
545
+ i == " " && (i = n), o = this.propReferences.push(s[n]) - 1, r = !0;
524
546
  } else
525
- (s != null && n == null || s == null && n == null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), a = (f - l) / 2;
547
+ (n != null && s == null || n == null && s == null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), a = (u - l) / 2;
526
548
  this.imageContainer = null;
527
- var d = this._createElement({
549
+ var h = this._createElement({
528
550
  class: "p-gui__slider",
529
551
  textContent: i
530
- }), u = this._createElement({
531
- parent: d,
552
+ }), f = this._createElement({
553
+ parent: h,
532
554
  el: "input",
533
555
  class: "p-gui__slider-ctrl",
534
556
  customAttributes: {
535
557
  type: "range",
536
558
  min: l,
537
- max: f,
538
- step: g,
539
- value: r ? n[s] : a
559
+ max: u,
560
+ step: d,
561
+ value: r ? s[n] : a
540
562
  }
541
563
  }), _ = this._createElement({
542
- parent: d,
564
+ parent: h,
543
565
  class: "p-gui__slider-value",
544
- textContent: String(r ? n[s] : a)
566
+ textContent: String(r ? s[n] : a)
545
567
  });
546
- u.addEventListener("input", () => {
547
- _.textContent = u.value, r && (n[s] = u.value), typeof t == "function" && t(parseFloat(u.value));
548
- }), r && Object.defineProperty(n, s, {
568
+ f.addEventListener("input", () => {
569
+ _.textContent = f.value, r && (s[n] = f.value), typeof t == "function" && t(parseFloat(f.value));
570
+ }), r && Object.defineProperty(s, n, {
549
571
  set: (b) => {
550
- this.propReferences[o] = b, u.value = b, _.textContent = String(b);
572
+ this.propReferences[o] = b, f.value = b, _.textContent = String(b);
551
573
  },
552
574
  get: () => this.propReferences[o]
553
575
  });
@@ -559,15 +581,15 @@ class h {
559
581
  this.imageContainer = null;
560
582
  let o = this._createElement({
561
583
  class: "p-gui__switch",
562
- onclick: (s) => {
563
- let a = s.target.childNodes[1], l = !0;
584
+ onclick: (n) => {
585
+ let a = n.target.childNodes[1], l = !0;
564
586
  a.classList.contains("p-gui__switch-checkbox--active") && (l = !1), a.classList.toggle("p-gui__switch-checkbox--active"), typeof t == "function" && t(l);
565
587
  },
566
588
  textContent: i
567
- }), n = r ? " p-gui__switch-checkbox--active" : "";
589
+ }), s = r ? " p-gui__switch-checkbox--active" : "";
568
590
  this._createElement({
569
591
  parent: o,
570
- class: "p-gui__switch-checkbox" + n
592
+ class: "p-gui__switch-checkbox" + s
571
593
  });
572
594
  }
573
595
  list(e = {}, t) {
@@ -578,22 +600,22 @@ class h {
578
600
  let o = this._createElement({
579
601
  class: "p-gui__list",
580
602
  textContent: i
581
- }), n = this._createElement({
603
+ }), s = this._createElement({
582
604
  parent: o,
583
605
  el: "select",
584
606
  class: "p-gui__list-dropdown",
585
- onchange: (s) => {
586
- t && t(s.target.value);
607
+ onchange: (n) => {
608
+ t && t(n.target.value);
587
609
  }
588
610
  });
589
- r.forEach((s) => {
611
+ r.forEach((n) => {
590
612
  this._createElement({
591
- parent: n,
613
+ parent: s,
592
614
  el: "option",
593
615
  customAttributes: {
594
- value: s
616
+ value: n
595
617
  },
596
- textContent: s
618
+ textContent: n
597
619
  });
598
620
  });
599
621
  }
@@ -606,7 +628,7 @@ class h {
606
628
  if (typeof e != "object")
607
629
  throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);
608
630
  let i = typeof e.name == "string" && e.name || " ";
609
- const r = e.x.min ?? 0, o = e.x.max ?? 1, n = e.y.min ?? 0, s = e.y.max ?? 1, a = e.x.obj || e.x.object, l = e.x.prop || e.x.property, f = this.propReferences.push(a[l]) - 1, g = e.y.obj || e.y.object, d = e.y.prop || e.y.property, u = this.propReferences.push(g[d]) - 1;
631
+ const r = e.x.min ?? 0, o = e.x.max ?? 1, s = e.y.min ?? 0, n = e.y.max ?? 1, a = e.x.obj || e.x.object, l = e.x.prop || e.x.property, u = this.propReferences.push(a[l]) - 1, d = e.y.obj || e.y.object, h = e.y.prop || e.y.property, f = this.propReferences.push(d[h]) - 1;
610
632
  t = typeof t == "function" ? t : null, this.imageContainer = null;
611
633
  const _ = this._createElement({
612
634
  class: "p-gui__vector2",
@@ -614,43 +636,43 @@ class h {
614
636
  }), b = this._createElement({
615
637
  parent: _,
616
638
  class: "p-gui__vector-value",
617
- textContent: a[l] + ", " + g[d]
618
- }), p = this._createElement({
639
+ textContent: a[l] + ", " + d[h]
640
+ }), c = this._createElement({
619
641
  parent: _,
620
642
  el: "div",
621
643
  class: "p-gui__vector2-area",
622
- onclick: (c) => {
623
- a[l] = parseFloat(this._mapLinear(c.offsetX, 0, p.clientWidth, r, o).toFixed(2)), g[d] = parseFloat(this._mapLinear(c.offsetY, 0, p.clientHeight, s, n).toFixed(2)), t && t(a[l], a[d]);
644
+ onclick: (p) => {
645
+ a[l] = parseFloat(this._mapLinear(p.offsetX, 0, c.clientWidth, r, o).toFixed(2)), d[h] = parseFloat(this._mapLinear(p.offsetY, 0, c.clientHeight, n, s).toFixed(2)), t && t(a[l], a[h]);
624
646
  }
625
647
  });
626
648
  let m = !1;
627
- p.addEventListener("pointerdown", (c) => {
649
+ c.addEventListener("pointerdown", (p) => {
628
650
  m = !0;
629
- }), p.addEventListener("pointerup", () => {
651
+ }), c.addEventListener("pointerup", () => {
630
652
  m = !1;
631
- }), p.addEventListener("pointermove", (c) => {
632
- m && (a[l] = parseFloat(this._mapLinear(c.offsetX, 0, p.clientWidth, r, o).toFixed(2)), g[d] = parseFloat(this._mapLinear(c.offsetY, 0, p.clientHeight, s, n).toFixed(2)), t && t(a[l], a[d]));
653
+ }), c.addEventListener("pointermove", (p) => {
654
+ m && (a[l] = parseFloat(this._mapLinear(p.offsetX, 0, c.clientWidth, r, o).toFixed(2)), d[h] = parseFloat(this._mapLinear(p.offsetY, 0, c.clientHeight, n, s).toFixed(2)), t && t(a[l], a[h]));
633
655
  }), this._createElement({
634
- parent: p,
656
+ parent: c,
635
657
  class: "p-gui__vector2-line p-gui__vector2-line-x"
636
658
  }), this._createElement({
637
- parent: p,
659
+ parent: c,
638
660
  class: "p-gui__vector2-line p-gui__vector2-line-y"
639
661
  });
640
662
  const x = this._createElement({
641
- parent: p,
663
+ parent: c,
642
664
  class: "p-gui__vector2-dot"
643
665
  });
644
- x.style.left = this._mapLinear(a[l], r, o, 0, p.clientWidth) + "px", x.style.top = this._mapLinear(g[d], n, s, p.clientHeight, 0) + "px", Object.defineProperty(a, l, {
645
- set: (c) => {
646
- this.propReferences[f] = c, x.style.left = this._mapLinear(c, r, o, 0, p.clientWidth) + "px", b.textContent = String(c) + ", " + g[d];
647
- },
648
- get: () => this.propReferences[f]
649
- }), Object.defineProperty(g, d, {
650
- set: (c) => {
651
- this.propReferences[u] = c, x.style.top = this._mapLinear(c, n, s, p.clientHeight, 0) + "px", b.textContent = a[l] + ", " + String(c);
666
+ x.style.left = this._mapLinear(a[l], r, o, 0, c.clientWidth) + "px", x.style.top = this._mapLinear(d[h], s, n, c.clientHeight, 0) + "px", Object.defineProperty(a, l, {
667
+ set: (p) => {
668
+ this.propReferences[u] = p, x.style.left = this._mapLinear(p, r, o, 0, c.clientWidth) + "px", b.textContent = String(p) + ", " + d[h];
652
669
  },
653
670
  get: () => this.propReferences[u]
671
+ }), Object.defineProperty(d, h, {
672
+ set: (p) => {
673
+ this.propReferences[f] = p, x.style.top = this._mapLinear(p, s, n, c.clientHeight, 0) + "px", b.textContent = a[l] + ", " + String(p);
674
+ },
675
+ get: () => this.propReferences[f]
654
676
  });
655
677
  }
656
678
  color(e = {}, t) {
@@ -662,27 +684,27 @@ class h {
662
684
  el: "div",
663
685
  class: "p-gui__color",
664
686
  textContent: i
665
- }), n = this._createElement({
687
+ }), s = this._createElement({
666
688
  parent: o,
667
689
  el: "input",
668
690
  class: "p-gui__color-picker",
669
691
  type: "color",
670
692
  value: r
671
693
  });
672
- typeof t == "function" && n.addEventListener("input", () => {
673
- t(n.value);
694
+ typeof t == "function" && s.addEventListener("input", () => {
695
+ t(s.value);
674
696
  });
675
697
  }
676
698
  folder(e = {}) {
677
699
  let t = typeof e.closed == "boolean" ? e.closed : !1, i = e.name || "", r = e.color || null, o = e.maxHeight || null;
678
700
  this.imageContainer = null;
679
- let n = "p-gui__folder";
680
- this.folders.length == 0 && (n += " p-gui__folder--first"), t && (n += " p-gui__folder--closed");
681
- let s = r ? `background-color: ${r};` : "";
682
- s += o ? `max-height: ${o}px;` : "";
701
+ let s = "p-gui__folder";
702
+ this.folders.length == 0 && (s += " p-gui__folder--first"), t && (s += " p-gui__folder--closed");
703
+ let n = r ? `background-color: ${r};` : "";
704
+ n += o ? `max-height: ${o}px;` : "";
683
705
  let a = this._createElement({
684
- class: n,
685
- inline: s
706
+ class: s,
707
+ inline: n
686
708
  });
687
709
  this._createElement({
688
710
  innerHTML: `<span class="p-gui__folder-arrow"></span>${i}`,
@@ -692,7 +714,7 @@ class h {
692
714
  },
693
715
  parent: a
694
716
  });
695
- let l = new h({ isFolder: !0, folderOptions: {
717
+ let l = new g({ isFolder: !0, folderOptions: {
696
718
  wrapper: a
697
719
  } });
698
720
  return this.folders.push(l), l;
@@ -721,5 +743,5 @@ class h {
721
743
  }
722
744
  }
723
745
  export {
724
- h as default
746
+ g as default
725
747
  };
@@ -0,0 +1,416 @@
1
+ (function(_,c){typeof exports=="object"&&typeof module<"u"?module.exports=c():typeof define=="function"&&define.amd?define(c):(_=typeof globalThis<"u"?globalThis:_||self,_["Perfect GUI"]=c())})(this,function(){"use strict";function _(w){return`
2
+ .p-gui {
3
+ --main-border-radius: 5px;
4
+ --color-bg: #121212;
5
+ --color-border: #484848;
6
+ --color-border-2: rgba(255,255,255,.1);
7
+ --color-accent: #1681ca;
8
+ --color-accent-hover: #218fda;
9
+
10
+ position: ${w};
11
+ top: 0;
12
+ left: 0;
13
+ transform: translate3d(0,0,0);
14
+ padding-top: 21px;
15
+ background: var(--color-bg);
16
+ display: flex;
17
+ justify-content: center;
18
+ flex-wrap: wrap;
19
+ font-family: Verdana, Arial, sans-serif;
20
+ width: 290px;
21
+ overflow: auto;
22
+ box-shadow: 0 0 2px black;
23
+ box-sizing: border-box;
24
+ z-index: 99999;
25
+ user-select: none;
26
+ border-bottom-right-radius: 3px;
27
+ border-bottom-left-radius: 3px;
28
+ cursor: auto;
29
+ border-radius: var(--main-border-radius);
30
+ border: 1px solid var(--color-border);
31
+ }
32
+
33
+ .p-gui * {
34
+ font-size: 11px;
35
+ }
36
+
37
+ .p-gui::-webkit-scrollbar,
38
+ .p-gui *::-webkit-scrollbar {
39
+ width: 10px;
40
+ }
41
+
42
+ .p-gui::-webkit-scrollbar-track,
43
+ .p-gui *::-webkit-scrollbar-track {
44
+ background: #2f2f2f;
45
+ border-radius: 3px;
46
+ }
47
+
48
+ .p-gui::-webkit-scrollbar-thumb,
49
+ .p-gui *::-webkit-scrollbar-thumb {
50
+ background: #757576;
51
+ border-radius: 10px;
52
+ box-sizing: border-box;
53
+ border: 1px solid #2f2f2f;
54
+ }
55
+
56
+ .p-gui--collapsed {
57
+ height: 0;
58
+ padding: 21px 10px 0 10px;
59
+ overflow: hidden;
60
+ }
61
+
62
+ .p-gui__header {
63
+ position: absolute;
64
+ top: 0;
65
+ left: 0;
66
+ width: 100%;
67
+ height: 20px;
68
+ background-color: rgba(0, 0, 0, .8);
69
+ cursor: grab;
70
+ color: grey;
71
+ font-size: 10px;
72
+ line-height: 20px;
73
+ padding-left: 12px;
74
+ box-sizing: border-box;
75
+ touch-action: none;
76
+ }
77
+
78
+ .p-gui__header-close {
79
+ width: 20px;
80
+ height: 20px;
81
+ position: absolute;
82
+ top: 0;
83
+ right: 5px;
84
+ cursor: pointer;
85
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABFJREFUCNdjIAb8//8BjIkAAOrOBd3TR0jRAAAAAElFTkSuQmCC);
86
+ background-size: 50% 50%;
87
+ background-position: center;
88
+ background-repeat: no-repeat;
89
+ }
90
+
91
+ .p-gui--collapsed .p-gui__header-close {
92
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABVJREFUCNdjYEhgIIj///8AwsSoBQD43QydY5mb0QAAAABJRU5ErkJggg==);
93
+ }
94
+
95
+ .p-gui__image-container {
96
+ width: 100%;
97
+ padding: 0 2%;
98
+ display: flex;
99
+ justify-content: flex-start;
100
+ flex-wrap: wrap;
101
+ }
102
+
103
+ .p-gui__image {
104
+ background-size: cover;
105
+ cursor: pointer;
106
+ position: relative;
107
+ margin: 1px 2.5px 19px 2.5px;
108
+ border-radius: var(--main-border-radius);
109
+ flex: 0 0 calc(33.333% - 5px);
110
+ height: 90px;
111
+ background-position: center;
112
+ }
113
+
114
+ .p-gui__image--selected::after {
115
+ position: absolute;
116
+ top: 0;
117
+ left: 0;
118
+ width: 100%;
119
+ height: 100%;
120
+ content: '';
121
+ border: 1px solid #06FF89;
122
+ box-sizing: border-box;
123
+ border-radius: var(--main-border-radius);
124
+ }
125
+
126
+ .p-gui__image-text {
127
+ position: absolute;
128
+ bottom: -15px;
129
+ color: #eee;
130
+ text-shadow: 0 -1px 0 #111;
131
+ white-space: nowrap;
132
+ width: 100%;
133
+ overflow: hidden;
134
+ text-overflow: ellipsis;
135
+ }
136
+
137
+ .p-gui__button,
138
+ .p-gui__switch,
139
+ .p-gui__list,
140
+ .p-gui__vector2,
141
+ .p-gui__color {
142
+ width: 100%;
143
+ padding: 7px 13px;
144
+ color: white;
145
+ cursor: pointer;
146
+ position: relative;
147
+ box-sizing: border-box;
148
+ margin-bottom: 3px;
149
+ margin: 3px;
150
+
151
+ border: 1px solid var(--color-border-2);
152
+ border-radius: var(--main-border-radius);
153
+ }
154
+
155
+ .p-gui__vector2 {
156
+ padding: 7px;
157
+ }
158
+
159
+ .p-gui__button,
160
+ .p-gui__switch {
161
+ margin-right: 4px;
162
+ margin-left: 4px;
163
+ }
164
+
165
+ .p-gui__button {
166
+ background: var(--color-accent);
167
+ text-align: center;
168
+ color: white;
169
+ border: none;
170
+ }
171
+
172
+ .p-gui__button:hover {
173
+ background: var(--color-accent-hover);
174
+ }
175
+
176
+ .p-gui__switch {
177
+ background: rgba(255, 255, 255, .05);
178
+ }
179
+
180
+ .p-gui__switch:hover {
181
+ background: rgba(255, 255, 255, .1);
182
+ }
183
+
184
+ .p-gui__folder .p-gui__button,
185
+ .p-gui__folder .p-gui__switch {
186
+ margin-right: 0;
187
+ margin-left: 0;
188
+ }
189
+
190
+ .p-gui__vector2 {
191
+ background: transparent;
192
+ aspect-ratio: 1;
193
+ padding-bottom: 0;
194
+ }
195
+
196
+ .p-gui__vector2-area {
197
+ position: relative;
198
+ background: rgba(0, 0, 0, .3);
199
+ margin-top: 8px;
200
+ width: 100%;
201
+ height: calc(100% - 28px);
202
+ touch-action: none;
203
+ }
204
+
205
+ .p-gui__vector2-line {
206
+ position: absolute;
207
+ background: white;
208
+ opacity: .3;
209
+ pointer-events: none;
210
+ }
211
+
212
+ .p-gui__vector2-line-x {
213
+ width: 100%;
214
+ height: 1px;
215
+ left: 0;
216
+ top: 50%;
217
+ transform: translateY(-50%);
218
+ }
219
+
220
+ .p-gui__vector2-line-y {
221
+ width: 1px;
222
+ height: 100%;
223
+ top: 0;
224
+ left: 50%;
225
+ transform: translateX(-50%);
226
+ }
227
+
228
+ .p-gui__vector2-dot {
229
+ position: absolute;
230
+ top: 0;
231
+ left: 0;
232
+ width: 8px;
233
+ height: 8px;
234
+ border-radius: 50%;
235
+ background: #d5d5d5;
236
+ border: 2px solid #ff9999;
237
+ transform: translate(-50%, -50%);
238
+ pointer-events: none;
239
+ }
240
+
241
+ .p-gui__switch-checkbox {
242
+ width: 5px;
243
+ height: 5px;
244
+ background-color: rgba(0, 0, 0, .5);
245
+ border: 1px solid grey;
246
+ position: absolute;
247
+ top: 0;
248
+ right: 10px;
249
+ bottom: 0;
250
+ margin: auto;
251
+ border-radius: 50%;
252
+ pointer-events: none;
253
+ }
254
+
255
+ .p-gui__switch-checkbox--active {
256
+ background-color: #00ff89;
257
+ box-shadow: 0 0 7px #00ff89;
258
+ }
259
+
260
+ .p-gui__list,
261
+ .p-gui__color {
262
+ cursor: default;
263
+ }
264
+
265
+ .p-gui__list-dropdown,
266
+ .p-gui__color-picker {
267
+ position: absolute;
268
+ right: 5px;
269
+ top: 0;
270
+ bottom: 0;
271
+ margin: auto;
272
+ height: 21px;
273
+ cursor: pointer;
274
+ border-radius: 3px;
275
+ border: 1px solid var(--color-border-2);
276
+ }
277
+
278
+ .p-gui__list-dropdown {
279
+ background: rgba(255, 255, 255,.05);
280
+ color: white;
281
+ padding: 0 12px;
282
+ top: 0px;
283
+ }
284
+
285
+ .p-gui__list-dropdown:hover {
286
+ background: rgba(255, 255, 255, .1);
287
+ }
288
+
289
+ .p-gui__color-picker {
290
+ -webkit-appearance: none;
291
+ padding: 0;
292
+ background-color: transparent;
293
+ border: 1px solid #222222;
294
+ overflow: hidden;
295
+ }
296
+
297
+ .p-gui__color-picker::-webkit-color-swatch-wrapper {
298
+ padding: 0;
299
+ }
300
+ .p-gui__color-picker::-webkit-color-swatch {
301
+ border: none;
302
+ }
303
+
304
+ .p-gui__slider {
305
+ width: 100%;
306
+ margin-bottom: 8px;
307
+ padding: 7px;
308
+ color: white;
309
+ position: relative;
310
+ min-height: 14px;
311
+ }
312
+
313
+ .p-gui__slider-ctrl {
314
+ -webkit-appearance: none;
315
+ padding: 0;
316
+ font: inherit;
317
+ outline: none;
318
+ opacity: .8;
319
+ background: var(--color-accent);
320
+ box-sizing: border-box;
321
+ cursor: pointer;
322
+ position: absolute;
323
+ bottom: -4px; /* 5px height -1px de dépassement du curseur */
324
+ right: 0;
325
+ height: 5px;
326
+ width: 100%;
327
+ margin: 0;
328
+ }
329
+
330
+ /* la zone de déplacement */
331
+ .p-gui__slider-ctrl::-webkit-slider-runnable-track {
332
+ height: 13px;
333
+ border: none;
334
+ border-radius: 0;
335
+ background-color: transparent; /* supprimé définie sur l'input */
336
+ }
337
+
338
+ /* Curseur */
339
+ .p-gui__slider-ctrl::-webkit-slider-thumb {
340
+ -webkit-appearance: none; /* également nécessaire sur le curseur */
341
+ width: 15px;
342
+ height: 7px;
343
+ border: none; /* pris en compte sur Webkit et Edge */
344
+ background: white; /* pris en compte sur Webkit only */
345
+ position: relative;
346
+ top: 3px;
347
+ border-radius: 1px;
348
+ }
349
+
350
+ .p-gui__slider-value,
351
+ .p-gui__vector-value {
352
+ display: inline-block;
353
+ position: absolute;
354
+ right: 7px;
355
+ }
356
+
357
+ .p-gui__folder {
358
+ width: 100%;
359
+ position: relative;
360
+ background: #434343;
361
+ overflow: auto;
362
+ margin-bottom: 3px;
363
+ display: flex;
364
+ flex-wrap: wrap;
365
+ border-left: 3px solid grey;
366
+ border-bottom: 1px solid grey;
367
+ padding: 0 3px;
368
+ }
369
+
370
+ .p-gui__folder:last-of-type {
371
+ margin-bottom: 0;
372
+ border-bottom: none;
373
+ }
374
+
375
+ .p-gui__folder--first {
376
+ margin-top: 0;
377
+ }
378
+
379
+ .p-gui__folder--closed {
380
+ height: 32px;
381
+ overflow: hidden;
382
+ }
383
+
384
+ .p-gui__folder-header {
385
+ padding: 10px 5px;
386
+ background-color: rgba(0, 0, 0, .5);
387
+ color: white;
388
+ cursor: pointer;
389
+ width: 100%;
390
+ margin: 0 -2px 2px -3px;
391
+ }
392
+
393
+ .p-gui__folder-header:hover {
394
+ background-color: rgba(0, 0, 0, .75);
395
+ }
396
+
397
+ .p-gui__folder-arrow {
398
+ width: 8px;
399
+ height: 8px;
400
+ display: inline-block;
401
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAHlBMVEUAAAD///////////////////////////////////8kfJuVAAAACXRSTlMA9Z1fCdMo1yxEJnA0AAAAK0lEQVQI12PABlRgjKkJUMZMYRhjpgqMAZSEMICSaIzpDWiKhdENhEhgAgATSg5jyWnYewAAAABJRU5ErkJggg==);
402
+ background-size: contain;
403
+ margin-right: 5px;
404
+ transform: rotate(90deg)
405
+ }
406
+
407
+ .p-gui__folder--closed .p-gui__folder-arrow {
408
+ transform: rotate(0deg);
409
+ }
410
+ `}class c{constructor(e={}){if(e.container?(this.container=typeof e.container=="string"?document.querySelector(e.container):e.container,this.position_type="absolute"):(this.container=document.body,this.position_type="fixed"),this.propReferences=[],this.folders=[],e.isFolder){this._folderConstructor(e.folderOptions);return}this.name=e!=null&&typeof e.name=="string"?e.name:"",this.backgroundColor=e.color||null,this.container==document.body?this.maxHeight=window.innerHeight:this.maxHeight=Math.min(this.container.clientHeight,window.innerHeight),e.maxHeight&&(this.initMaxHeight=e.maxHeight,this.maxHeight=Math.min(this.initMaxHeight,this.maxHeight)),this.screenCorner=this._parseScreenCorner(e.position),this instanceof c&&(typeof c[c.instanceCounter]!="number"?c[c.instanceCounter]=0:c[c.instanceCounter]++),this.instanceId=c[c.instanceCounter],this.wrapperWidth=e.width||290,this.stylesheet=document.createElement("style"),this.stylesheet.setAttribute("type","text/css"),this.stylesheet.setAttribute("id","lm-gui-stylesheet"),document.head.append(this.stylesheet),this.instanceId==0&&this._addStyles(`${_(this.position_type)}`),this._styleInstance(),this._addWrapper(),this.wrapper.setAttribute("data-corner-x",this.screenCorner.x),this.wrapper.setAttribute("data-corner-y",this.screenCorner.y),e.autoRepositioning!=!1&&window.addEventListener("resize",this._handleResize.bind(this)),this._handleResize(),this.hasBeenDragged=!1,e.draggable==!0&&this._makeDraggable(),this.closed=!1,e.closed&&this.toggleClose()}_styleInstance(){let e=this._getScrollbarWidth(this.container);if(this.screenCorner.x=="left"?this.xOffset=0:this.xOffset=this.container.clientWidth-this.wrapperWidth-e,this.instanceId>0){let t=this.container.querySelectorAll(".p-gui");for(let i=0;i<t.length;i++)this.screenCorner.y==t[i].dataset.cornerY&&(this.screenCorner.x=="left"&&t[i].dataset.cornerX=="left"?this.xOffset+=t[i].offsetWidth:this.screenCorner.x=="right"&&t[i].dataset.cornerX=="right"&&(this.xOffset-=t[i].offsetWidth))}this.yOffset=0,this.position={prevX:this.xOffset,prevY:this.yOffset,x:this.xOffset,y:this.yOffset},this._addStyles(`#p-gui-${this.instanceId} {
411
+ width: ${this.wrapperWidth}px;
412
+ max-height: ${this.maxHeight}px;
413
+ transform: translate3d(${this.xOffset}px,${this.yOffset}px,0);
414
+ ${this.screenCorner.y=="top"?"":"top: auto; bottom: 0;"}
415
+ ${this.backgroundColor?"background: "+this.backgroundColor+";":""}
416
+ }`)}_folderConstructor(e){this.wrapper=e.wrapper}_parseScreenCorner(e){let t={x:"right",y:"top"};return e==null||(typeof e!="string"&&console.error("[perfect-gui] Position must be a string."),e.includes("left")&&(t.x="left"),e.includes("bottom")&&(t.y="bottom")),t}_getScrollbarWidth(e){return e===document.body?window.innerWidth-document.documentElement.clientWidth:e.offsetWidth-e.clientWidth}_handleResize(){if(this.container==document.body?this.maxHeight=window.innerHeight:this.maxHeight=Math.min(this.container.clientHeight,window.innerHeight),this.initMaxHeight&&(this.maxHeight=Math.min(this.initMaxHeight,this.maxHeight)),this.wrapper.style.maxHeight=this.maxHeight+"px",this.hasBeenDragged)return;let e=this._getScrollbarWidth(this.container);if(this.xOffset=this.screenCorner.x=="left"?0:this.container.clientWidth-this.wrapperWidth-e,this.instanceId>0){let t=this.container.querySelectorAll(`.p-gui:not(#${this.wrapper.id}):not([data-dragged])`);for(let i=0;i<t.length&&!(parseInt(t[i].id.replace("p-gui-",""))>this.instanceId);i++)this.screenCorner.y==t[i].dataset.cornerY&&(this.screenCorner.x=="left"&&t[i].dataset.cornerX=="left"?this.xOffset+=t[i].offsetWidth:this.screenCorner.x=="right"&&t[i].dataset.cornerX=="right"&&(this.xOffset-=t[i].offsetWidth))}this.position={prevX:this.xOffset,prevY:this.yOffset,x:this.xOffset,y:this.yOffset},this.wrapper.style.transform=`translate3d(${this.position.x}px, ${this.position.y}px, 0)`}_createElement(e){e.el=e.el||"div";var t=document.createElement(e.el);if(e.id&&(t.id=e.id),e.class&&(t.className=e.class),e.inline&&(t.style=e.inline),e.href&&(t.href=e.href),e.onclick&&(t.onclick=e.onclick),e.onchange&&(t.onchange=e.onchange),e.textContent&&(t.textContent=e.textContent),e.innerHTML&&(t.innerHTML=e.innerHTML),e.type&&(t.type=e.type),e.value&&(t.value=e.value),e.customAttributes)for(var i in e.customAttributes)t.setAttribute(i,e.customAttributes[i]);return e.parent=e.parent?e.parent:this.wrapper,e.parent.append(t),t}_addStyles(e){this.stylesheet.innerHTML+=e}_addWrapper(){this.wrapper=this._createElement({parent:this.container,id:"p-gui-"+this.instanceId,class:"p-gui"}),this.header=this._createElement({parent:this.wrapper,class:"p-gui__header",textContent:this.name,inline:`${this.backgroundColor?"border-color: "+this.backgroundColor+";":""}`}),this._createElement({parent:this.header,class:"p-gui__header-close",onclick:this.toggleClose.bind(this)})}button(e,t){let i="";typeof e!="string"?typeof e=="object"&&(e!=null&&e.hasOwnProperty("name"))?i=e.name==""?" ":e.name:i=" ":i=e==""?" ":e,this.imageContainer=null,typeof t!="function"&&(t=()=>{});const r=this._createElement({class:"p-gui__button",textContent:i,onclick:t});typeof e.color=="string"&&(r.style.setProperty("--color-accent",e.color),r.style.setProperty("--color-accent-hover",e.hoverColor||e.color))}image(e={},t){if(typeof e!="object")throw Error(`[GUI] image() first parameter must be an object. Received: ${typeof e}.`);let i;if(typeof e.path=="string")i=e.path;else throw typeof e.path==null?Error("[GUI] image() path must be provided."):Error("[GUI] image() path must be a string.");let r=i.replace(/^.*[\\\/]/,""),o;e.name==null?o=r:o=typeof e.name=="string"&&e.name||" ";const s=e.selected===!0,n=e.selectionBorder!==!1;let a="";e.width&&(typeof e.width=="number"&&(e.width+="px"),a+=`flex: 0 0 calc(${e.width} - 5px); `),e.height&&(typeof e.height=="number"&&(e.height+="px"),a+=`height: ${e.height}; `),this.imageContainer||(this.imageContainer=this._createElement({class:"p-gui__image-container"}));var l=this._createElement({class:"p-gui__image",inline:"background-image: url("+i+"); "+a,parent:this.imageContainer});s&&n&&l.classList.add("p-gui__image--selected"),this._createElement({parent:l,class:"p-gui__image-text",textContent:o}),typeof t=="function"&&(l.onclick=()=>{let u=this.imageContainer.querySelectorAll(".p-gui__image--selected");for(let h=0;h<u.length;h++)u[h].classList.remove("p-gui__image--selected");n&&l.classList.add("p-gui__image--selected"),t({path:i,text:o})})}slider(e={},t){if(typeof e!="object")throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);let i=typeof e.name=="string"&&e.name||" ",r=!1,o=null,s=e.obj||e.object,n=e.prop||e.property,a=typeof e.value=="number"?e.value:null,l=e.min??0,u=e.max??1,h=e.step||(u-l)/100;if(a!==null)(n!=null||s!=null)&&console.warn('[GUI] slider() "obj" and "property" parameters are ignored when a "value" parameter is used.');else if(n!=null&&s!=null){if(typeof n!="string")throw Error(`[GUI] slider() "prop" (or "property") parameter must be an string. Received: ${typeof n}.`);if(typeof s!="object")throw Error(`[GUI] slider() "obj" (or "object") parameter must be an object. Received: ${typeof s}.`);i==" "&&(i=n),o=this.propReferences.push(s[n])-1,r=!0}else(n!=null&&s==null||n==null&&s==null)&&console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'),a=(u-l)/2;this.imageContainer=null;var g=this._createElement({class:"p-gui__slider",textContent:i}),f=this._createElement({parent:g,el:"input",class:"p-gui__slider-ctrl",customAttributes:{type:"range",min:l,max:u,step:h,value:r?s[n]:a}}),x=this._createElement({parent:g,class:"p-gui__slider-value",textContent:String(r?s[n]:a)});f.addEventListener("input",()=>{x.textContent=f.value,r&&(s[n]=f.value),typeof t=="function"&&t(parseFloat(f.value))}),r&&Object.defineProperty(s,n,{set:b=>{this.propReferences[o]=b,f.value=b,x.textContent=String(b)},get:()=>this.propReferences[o]})}toggle(e={},t){if(typeof e!="object")throw Error(`[GUI] toggle() first parameter must be an object. Received: ${typeof e}.`);let i=typeof e.name=="string"&&e.name||" ",r=e.value===!0;this.imageContainer=null;let o=this._createElement({class:"p-gui__switch",onclick:n=>{let a=n.target.childNodes[1],l=!0;a.classList.contains("p-gui__switch-checkbox--active")&&(l=!1),a.classList.toggle("p-gui__switch-checkbox--active"),typeof t=="function"&&t(l)},textContent:i}),s=r?" p-gui__switch-checkbox--active":"";this._createElement({parent:o,class:"p-gui__switch-checkbox"+s})}list(e={},t){if(typeof e!="object")throw Error(`[GUI] list() first parameter must be an object. Received: ${typeof e}.`);let i=typeof e.name=="string"?e.name:" ",r=Array.isArray(e.values)?e.values:null;t=typeof t=="function"?t:null,this.imageContainer=null;let o=this._createElement({class:"p-gui__list",textContent:i}),s=this._createElement({parent:o,el:"select",class:"p-gui__list-dropdown",onchange:n=>{t&&t(n.target.value)}});r.forEach(n=>{this._createElement({parent:s,el:"option",customAttributes:{value:n},textContent:n})})}options(e,t){if(typeof e!="object")throw Error(`[GUI] options() first parameter must be an object. Received: ${typeof e}.`);this.list(e,t)}vector2(e={},t){if(typeof e!="object")throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);let i=typeof e.name=="string"&&e.name||" ";const r=e.x.min??0,o=e.x.max??1,s=e.y.min??0,n=e.y.max??1,a=e.x.obj||e.x.object,l=e.x.prop||e.x.property,u=this.propReferences.push(a[l])-1,h=e.y.obj||e.y.object,g=e.y.prop||e.y.property,f=this.propReferences.push(h[g])-1;t=typeof t=="function"?t:null,this.imageContainer=null;const x=this._createElement({class:"p-gui__vector2",textContent:i}),b=this._createElement({parent:x,class:"p-gui__vector-value",textContent:a[l]+", "+h[g]}),p=this._createElement({parent:x,el:"div",class:"p-gui__vector2-area",onclick:d=>{a[l]=parseFloat(this._mapLinear(d.offsetX,0,p.clientWidth,r,o).toFixed(2)),h[g]=parseFloat(this._mapLinear(d.offsetY,0,p.clientHeight,n,s).toFixed(2)),t&&t(a[l],a[g])}});let y=!1;p.addEventListener("pointerdown",d=>{y=!0}),p.addEventListener("pointerup",()=>{y=!1}),p.addEventListener("pointermove",d=>{y&&(a[l]=parseFloat(this._mapLinear(d.offsetX,0,p.clientWidth,r,o).toFixed(2)),h[g]=parseFloat(this._mapLinear(d.offsetY,0,p.clientHeight,n,s).toFixed(2)),t&&t(a[l],a[g]))}),this._createElement({parent:p,class:"p-gui__vector2-line p-gui__vector2-line-x"}),this._createElement({parent:p,class:"p-gui__vector2-line p-gui__vector2-line-y"});const m=this._createElement({parent:p,class:"p-gui__vector2-dot"});m.style.left=this._mapLinear(a[l],r,o,0,p.clientWidth)+"px",m.style.top=this._mapLinear(h[g],s,n,p.clientHeight,0)+"px",Object.defineProperty(a,l,{set:d=>{this.propReferences[u]=d,m.style.left=this._mapLinear(d,r,o,0,p.clientWidth)+"px",b.textContent=String(d)+", "+h[g]},get:()=>this.propReferences[u]}),Object.defineProperty(h,g,{set:d=>{this.propReferences[f]=d,m.style.top=this._mapLinear(d,s,n,p.clientHeight,0)+"px",b.textContent=a[l]+", "+String(d)},get:()=>this.propReferences[f]})}color(e={},t){if(typeof e!="object")throw Error(`[GUI] color() first parameter must be an object. Received: ${typeof e}.`);let i=typeof e.name=="string"&&e.name||" ",r;typeof e.value=="string"&&(e.value.length!=7||e.value[0]!="#"?console.error(`[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${e.value}".`):r=e.value),r||(r="#000000");const o=this._createElement({el:"div",class:"p-gui__color",textContent:i}),s=this._createElement({parent:o,el:"input",class:"p-gui__color-picker",type:"color",value:r});typeof t=="function"&&s.addEventListener("input",()=>{t(s.value)})}folder(e={}){let t=typeof e.closed=="boolean"?e.closed:!1,i=e.name||"",r=e.color||null,o=e.maxHeight||null;this.imageContainer=null;let s="p-gui__folder";this.folders.length==0&&(s+=" p-gui__folder--first"),t&&(s+=" p-gui__folder--closed");let n=r?`background-color: ${r};`:"";n+=o?`max-height: ${o}px;`:"";let a=this._createElement({class:s,inline:n});this._createElement({innerHTML:`<span class="p-gui__folder-arrow"></span>${i}`,class:"p-gui__folder-header",onclick:function(){this.parentNode.classList.toggle("p-gui__folder--closed")},parent:a});let l=new c({isFolder:!0,folderOptions:{wrapper:a}});return this.folders.push(l),l}_makeDraggable(){var e=this;this.header.addEventListener("pointerdown",t),this.header.addEventListener("pointerup",r);function t(o){o.preventDefault(),e.position.initX=e.position.x,e.position.initY=e.position.y,e.position.prevX=o.clientX,e.position.prevY=o.clientY,document.addEventListener("pointermove",i)}function i(o){o.preventDefault(),e.hasBeenDragged||(e.hasBeenDragged=!0,e.wrapper.setAttribute("data-dragged","true")),e.position.x=e.position.initX+o.clientX-e.position.prevX,e.position.y=e.position.initY+o.clientY-e.position.prevY,e.wrapper.style.transform="translate3d("+e.position.x+"px,"+e.position.y+"px,0)"}function r(o){document.removeEventListener("pointermove",i)}}toggleClose(){this.closed=!this.closed,this.wrapper.classList.toggle("p-gui--collapsed")}kill(){this.wrapper.remove()}_mapLinear(e,t,i,r,o){return r+(e-t)*(o-r)/(i-t)}}return c});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perfect-gui",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "Nice and simple GUI for JavaScript",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -289,19 +289,35 @@ export default class GUI {
289
289
 
290
290
  const selected = params.selected === true;
291
291
  const selectionBorder = params.selectionBorder !== false;
292
+
293
+ // width & height options
294
+ let inline_styles = '';
295
+ if (params.width) {
296
+ if (typeof params.width == 'number') {
297
+ params.width += 'px';
298
+ }
299
+ inline_styles += `flex: 0 0 calc(${params.width} - 5px); `;
300
+ }
301
+
302
+ if (params.height) {
303
+ if (typeof params.height == 'number') {
304
+ params.height += 'px';
305
+ }
306
+ inline_styles += `height: ${params.height}; `;
307
+ }
292
308
 
293
309
  if (!this.imageContainer) {
294
310
  this.imageContainer = this._createElement({
295
311
  class: 'p-gui__image-container'
296
312
  });
297
313
  }
298
-
314
+
299
315
  // Image
300
316
  var image = this._createElement({
301
317
  class: 'p-gui__image',
302
- inline: `background-image: url(${path})`,
318
+ inline: 'background-image: url(' + path + '); ' + inline_styles,
303
319
  parent: this.imageContainer
304
- })
320
+ });
305
321
 
306
322
  if (selected && selectionBorder) {
307
323
  image.classList.add('p-gui__image--selected');
@@ -312,7 +328,9 @@ export default class GUI {
312
328
  parent: image,
313
329
  class: 'p-gui__image-text',
314
330
  textContent: name
315
- })
331
+ });
332
+
333
+
316
334
 
317
335
  if (typeof callback == 'function') {
318
336
  image.onclick = () => {
package/src/styles.js CHANGED
@@ -100,20 +100,21 @@ export default function( position_type ) {
100
100
 
101
101
  .p-gui__image-container {
102
102
  width: 100%;
103
- display: grid;
104
- grid-template-columns: repeat(auto-fill, 32%);
105
- justify-content: space-between;
106
103
  padding: 0 2%;
104
+ display: flex;
105
+ justify-content: flex-start;
106
+ flex-wrap: wrap;
107
107
  }
108
108
 
109
109
  .p-gui__image {
110
- aspect-ratio: 1 / 1;
111
110
  background-size: cover;
112
111
  cursor: pointer;
113
112
  position: relative;
114
- margin-top: 1px;
115
- margin-bottom: 19px;
113
+ margin: 1px 2.5px 19px 2.5px;
116
114
  border-radius: var(--main-border-radius);
115
+ flex: 0 0 calc(33.333% - 5px);
116
+ height: 90px;
117
+ background-position: center;
117
118
  }
118
119
 
119
120
  .p-gui__image--selected::after {