perfect-gui 4.3.1 → 4.3.3

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,20 +97,21 @@ 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;
113
111
  border-radius: var(--main-border-radius);
112
+ flex: 0 0 calc(33.333% - 5px);
113
+ height: 90px;
114
+ background-position: center;
114
115
  }
115
116
 
116
117
  .p-gui__image--selected::after {
@@ -412,13 +413,13 @@ function w(y) {
412
413
  `
413
414
  );
414
415
  }
415
- class h {
416
+ class u {
416
417
  constructor(e = {}) {
417
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) {
418
419
  this._folderConstructor(e.folderOptions);
419
420
  return;
420
421
  }
421
- 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 u && (typeof u[u.instanceCounter] != "number" ? u[u.instanceCounter] = 0 : u[u.instanceCounter]++), this.instanceId = u[u.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
423
  }
423
424
  _styleInstance() {
424
425
  let e = this._getScrollbarWidth(this.container);
@@ -509,63 +510,64 @@ class h {
509
510
  throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
510
511
  let r = i.replace(/^.*[\\\/]/, ""), o;
511
512
  e.name == null ? o = r : o = typeof e.name == "string" && e.name || " ";
512
- const s = e.selected === !0, n = e.selectionBorder !== !1;
513
- this.imageContainer || (this.imageContainer = this._createElement({
513
+ const s = e.selected === !0, a = e.selectionBorder !== !1;
514
+ let n = "";
515
+ e.width && (typeof e.width == "number" && (e.width += "px"), n += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), n += `height: ${e.height}; `), this.imageContainer || (this.imageContainer = this._createElement({
514
516
  class: "p-gui__image-container"
515
517
  }));
516
- var a = this._createElement({
518
+ var l = this._createElement({
517
519
  class: "p-gui__image",
518
- inline: `background-image: url(${i})`,
520
+ inline: "background-image: url(" + i + "); " + n,
519
521
  parent: this.imageContainer
520
522
  });
521
- s && n && a.classList.add("p-gui__image--selected"), this._createElement({
522
- parent: a,
523
+ s && a && l.classList.add("p-gui__image--selected"), this._createElement({
524
+ parent: l,
523
525
  class: "p-gui__image-text",
524
526
  textContent: o
525
- }), typeof t == "function" && (a.onclick = () => {
526
- let l = this.imageContainer.querySelectorAll(".p-gui__image--selected");
527
- for (let g = 0; g < l.length; g++)
528
- l[g].classList.remove("p-gui__image--selected");
529
- n && a.classList.add("p-gui__image--selected"), t({ path: i, text: o });
527
+ }), typeof t == "function" && (l.onclick = () => {
528
+ let g = this.imageContainer.querySelectorAll(".p-gui__image--selected");
529
+ for (let d = 0; d < g.length; d++)
530
+ g[d].classList.remove("p-gui__image--selected");
531
+ a && l.classList.add("p-gui__image--selected"), t({ path: i, text: o });
530
532
  });
531
533
  }
532
534
  slider(e = {}, t) {
533
535
  if (typeof e != "object")
534
536
  throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);
535
- 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, g = e.max ?? 1, u = e.step || (g - l) / 100;
536
- if (a !== null)
537
- (n != null || s != null) && console.warn('[GUI] slider() "obj" and "property" parameters are ignored when a "value" parameter is used.');
538
- else if (n != null && s != null) {
539
- if (typeof n != "string")
540
- throw Error(`[GUI] slider() "prop" (or "property") parameter must be an string. Received: ${typeof n}.`);
537
+ let i = typeof e.name == "string" && e.name || " ", r = !1, o = null, s = e.obj || e.object, a = e.prop || e.property, n = typeof e.value == "number" ? e.value : null, l = e.min ?? 0, g = e.max ?? 1, d = e.step || (g - l) / 100;
538
+ if (n !== null)
539
+ (a != null || s != null) && console.warn('[GUI] slider() "obj" and "property" parameters are ignored when a "value" parameter is used.');
540
+ else if (a != null && s != null) {
541
+ if (typeof a != "string")
542
+ throw Error(`[GUI] slider() "prop" (or "property") parameter must be an string. Received: ${typeof a}.`);
541
543
  if (typeof s != "object")
542
544
  throw Error(`[GUI] slider() "obj" (or "object") parameter must be an object. Received: ${typeof s}.`);
543
- i == " " && (i = n), o = this.propReferences.push(s[n]) - 1, r = !0;
545
+ i == " " && (i = a), o = this.propReferences.push(s[a]) - 1, r = !0;
544
546
  } else
545
- (n != null && s == null || n == null && s == null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), a = (g - l) / 2;
547
+ (a != null && s == null || a == null && s == null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), n = (g - l) / 2;
546
548
  this.imageContainer = null;
547
- var d = this._createElement({
549
+ var h = this._createElement({
548
550
  class: "p-gui__slider",
549
551
  textContent: i
550
552
  }), f = this._createElement({
551
- parent: d,
553
+ parent: h,
552
554
  el: "input",
553
555
  class: "p-gui__slider-ctrl",
554
556
  customAttributes: {
555
557
  type: "range",
556
558
  min: l,
557
559
  max: g,
558
- step: u,
559
- value: r ? s[n] : a
560
+ step: d,
561
+ value: r ? s[a] : n
560
562
  }
561
563
  }), _ = this._createElement({
562
- parent: d,
564
+ parent: h,
563
565
  class: "p-gui__slider-value",
564
- textContent: String(r ? s[n] : a)
566
+ textContent: String(r ? s[a] : n)
565
567
  });
566
568
  f.addEventListener("input", () => {
567
- _.textContent = f.value, r && (s[n] = f.value), typeof t == "function" && t(parseFloat(f.value));
568
- }), r && Object.defineProperty(s, n, {
569
+ _.textContent = f.value, r && (s[a] = f.value), typeof t == "function" && t(parseFloat(f.value));
570
+ }), r && Object.defineProperty(s, a, {
569
571
  set: (b) => {
570
572
  this.propReferences[o] = b, f.value = b, _.textContent = String(b);
571
573
  },
@@ -579,9 +581,9 @@ class h {
579
581
  this.imageContainer = null;
580
582
  let o = this._createElement({
581
583
  class: "p-gui__switch",
582
- onclick: (n) => {
583
- let a = n.target.childNodes[1], l = !0;
584
- a.classList.contains("p-gui__switch-checkbox--active") && (l = !1), a.classList.toggle("p-gui__switch-checkbox--active"), typeof t == "function" && t(l);
584
+ onclick: (a) => {
585
+ let n = a.target.childNodes[1], l = !0;
586
+ n.classList.contains("p-gui__switch-checkbox--active") && (l = !1), n.classList.toggle("p-gui__switch-checkbox--active"), typeof t == "function" && t(l);
585
587
  },
586
588
  textContent: i
587
589
  }), s = r ? " p-gui__switch-checkbox--active" : "";
@@ -593,28 +595,36 @@ class h {
593
595
  list(e = {}, t) {
594
596
  if (typeof e != "object")
595
597
  throw Error(`[GUI] list() first parameter must be an object. Received: ${typeof e}.`);
596
- let i = typeof e.name == "string" ? e.name : " ", r = Array.isArray(e.values) ? e.values : null;
597
- t = typeof t == "function" ? t : null, this.imageContainer = null;
598
- let o = this._createElement({
598
+ let i = typeof e.name == "string" ? e.name : " ", r = Array.isArray(e.values) ? e.values : null, o = (() => {
599
+ if (!r)
600
+ return null;
601
+ if (typeof e.value == "string")
602
+ return r.indexOf(e.value);
603
+ if (typeof e.value == "number")
604
+ return e.value;
605
+ })();
606
+ console.log("->", o), t = typeof t == "function" ? t : null, this.imageContainer = null;
607
+ let s = this._createElement({
599
608
  class: "p-gui__list",
600
609
  textContent: i
601
- }), s = this._createElement({
602
- parent: o,
610
+ }), a = this._createElement({
611
+ parent: s,
603
612
  el: "select",
604
613
  class: "p-gui__list-dropdown",
605
614
  onchange: (n) => {
606
615
  t && t(n.target.value);
607
616
  }
608
617
  });
609
- r.forEach((n) => {
610
- this._createElement({
611
- parent: s,
618
+ r && r.forEach((n, l) => {
619
+ let g = this._createElement({
620
+ parent: a,
612
621
  el: "option",
613
622
  customAttributes: {
614
623
  value: n
615
624
  },
616
625
  textContent: n
617
626
  });
627
+ o == l && g.setAttribute("selected", "");
618
628
  });
619
629
  }
620
630
  options(e, t) {
@@ -626,7 +636,7 @@ class h {
626
636
  if (typeof e != "object")
627
637
  throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);
628
638
  let i = typeof e.name == "string" && e.name || " ";
629
- 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, g = this.propReferences.push(a[l]) - 1, u = e.y.obj || e.y.object, d = e.y.prop || e.y.property, f = this.propReferences.push(u[d]) - 1;
639
+ const r = e.x.min ?? 0, o = e.x.max ?? 1, s = e.y.min ?? 0, a = e.y.max ?? 1, n = e.x.obj || e.x.object, l = e.x.prop || e.x.property, g = this.propReferences.push(n[l]) - 1, d = e.y.obj || e.y.object, h = e.y.prop || e.y.property, f = this.propReferences.push(d[h]) - 1;
630
640
  t = typeof t == "function" ? t : null, this.imageContainer = null;
631
641
  const _ = this._createElement({
632
642
  class: "p-gui__vector2",
@@ -634,13 +644,13 @@ class h {
634
644
  }), b = this._createElement({
635
645
  parent: _,
636
646
  class: "p-gui__vector-value",
637
- textContent: a[l] + ", " + u[d]
647
+ textContent: n[l] + ", " + d[h]
638
648
  }), c = this._createElement({
639
649
  parent: _,
640
650
  el: "div",
641
651
  class: "p-gui__vector2-area",
642
652
  onclick: (p) => {
643
- a[l] = parseFloat(this._mapLinear(p.offsetX, 0, c.clientWidth, r, o).toFixed(2)), u[d] = parseFloat(this._mapLinear(p.offsetY, 0, c.clientHeight, n, s).toFixed(2)), t && t(a[l], a[d]);
653
+ n[l] = parseFloat(this._mapLinear(p.offsetX, 0, c.clientWidth, r, o).toFixed(2)), d[h] = parseFloat(this._mapLinear(p.offsetY, 0, c.clientHeight, a, s).toFixed(2)), t && t(n[l], n[h]);
644
654
  }
645
655
  });
646
656
  let m = !1;
@@ -649,7 +659,7 @@ class h {
649
659
  }), c.addEventListener("pointerup", () => {
650
660
  m = !1;
651
661
  }), c.addEventListener("pointermove", (p) => {
652
- m && (a[l] = parseFloat(this._mapLinear(p.offsetX, 0, c.clientWidth, r, o).toFixed(2)), u[d] = parseFloat(this._mapLinear(p.offsetY, 0, c.clientHeight, n, s).toFixed(2)), t && t(a[l], a[d]));
662
+ m && (n[l] = parseFloat(this._mapLinear(p.offsetX, 0, c.clientWidth, r, o).toFixed(2)), d[h] = parseFloat(this._mapLinear(p.offsetY, 0, c.clientHeight, a, s).toFixed(2)), t && t(n[l], n[h]));
653
663
  }), this._createElement({
654
664
  parent: c,
655
665
  class: "p-gui__vector2-line p-gui__vector2-line-x"
@@ -661,14 +671,14 @@ class h {
661
671
  parent: c,
662
672
  class: "p-gui__vector2-dot"
663
673
  });
664
- x.style.left = this._mapLinear(a[l], r, o, 0, c.clientWidth) + "px", x.style.top = this._mapLinear(u[d], s, n, c.clientHeight, 0) + "px", Object.defineProperty(a, l, {
674
+ x.style.left = this._mapLinear(n[l], r, o, 0, c.clientWidth) + "px", x.style.top = this._mapLinear(d[h], s, a, c.clientHeight, 0) + "px", Object.defineProperty(n, l, {
665
675
  set: (p) => {
666
- this.propReferences[g] = p, x.style.left = this._mapLinear(p, r, o, 0, c.clientWidth) + "px", b.textContent = String(p) + ", " + u[d];
676
+ this.propReferences[g] = p, x.style.left = this._mapLinear(p, r, o, 0, c.clientWidth) + "px", b.textContent = String(p) + ", " + d[h];
667
677
  },
668
678
  get: () => this.propReferences[g]
669
- }), Object.defineProperty(u, d, {
679
+ }), Object.defineProperty(d, h, {
670
680
  set: (p) => {
671
- this.propReferences[f] = p, x.style.top = this._mapLinear(p, s, n, c.clientHeight, 0) + "px", b.textContent = a[l] + ", " + String(p);
681
+ this.propReferences[f] = p, x.style.top = this._mapLinear(p, s, a, c.clientHeight, 0) + "px", b.textContent = n[l] + ", " + String(p);
672
682
  },
673
683
  get: () => this.propReferences[f]
674
684
  });
@@ -698,11 +708,11 @@ class h {
698
708
  this.imageContainer = null;
699
709
  let s = "p-gui__folder";
700
710
  this.folders.length == 0 && (s += " p-gui__folder--first"), t && (s += " p-gui__folder--closed");
701
- let n = r ? `background-color: ${r};` : "";
702
- n += o ? `max-height: ${o}px;` : "";
703
- let a = this._createElement({
711
+ let a = r ? `background-color: ${r};` : "";
712
+ a += o ? `max-height: ${o}px;` : "";
713
+ let n = this._createElement({
704
714
  class: s,
705
- inline: n
715
+ inline: a
706
716
  });
707
717
  this._createElement({
708
718
  innerHTML: `<span class="p-gui__folder-arrow"></span>${i}`,
@@ -710,10 +720,10 @@ class h {
710
720
  onclick: function() {
711
721
  this.parentNode.classList.toggle("p-gui__folder--closed");
712
722
  },
713
- parent: a
723
+ parent: n
714
724
  });
715
- let l = new h({ isFolder: !0, folderOptions: {
716
- wrapper: a
725
+ let l = new u({ isFolder: !0, folderOptions: {
726
+ wrapper: n
717
727
  } });
718
728
  return this.folders.push(l), l;
719
729
  }
@@ -741,5 +751,5 @@ class h {
741
751
  }
742
752
  }
743
753
  export {
744
- h as default
754
+ u as default
745
755
  };
@@ -94,20 +94,21 @@
94
94
 
95
95
  .p-gui__image-container {
96
96
  width: 100%;
97
- display: grid;
98
- grid-template-columns: repeat(auto-fill, 32%);
99
- justify-content: space-between;
100
97
  padding: 0 2%;
98
+ display: flex;
99
+ justify-content: flex-start;
100
+ flex-wrap: wrap;
101
101
  }
102
102
 
103
103
  .p-gui__image {
104
- aspect-ratio: 1 / 1;
105
104
  background-size: cover;
106
105
  cursor: pointer;
107
106
  position: relative;
108
- margin-top: 1px;
109
- margin-bottom: 19px;
107
+ margin: 1px 2.5px 19px 2.5px;
110
108
  border-radius: var(--main-border-radius);
109
+ flex: 0 0 calc(33.333% - 5px);
110
+ height: 90px;
111
+ background-position: center;
111
112
  }
112
113
 
113
114
  .p-gui__image--selected::after {
@@ -412,4 +413,4 @@
412
413
  transform: translate3d(${this.xOffset}px,${this.yOffset}px,0);
413
414
  ${this.screenCorner.y=="top"?"":"top: auto; bottom: 0;"}
414
415
  ${this.backgroundColor?"background: "+this.backgroundColor+";":""}
415
- }`)}_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;this.imageContainer||(this.imageContainer=this._createElement({class:"p-gui__image-container"}));var a=this._createElement({class:"p-gui__image",inline:`background-image: url(${i})`,parent:this.imageContainer});s&&n&&a.classList.add("p-gui__image--selected"),this._createElement({parent:a,class:"p-gui__image-text",textContent:o}),typeof t=="function"&&(a.onclick=()=>{let l=this.imageContainer.querySelectorAll(".p-gui__image--selected");for(let g=0;g<l.length;g++)l[g].classList.remove("p-gui__image--selected");n&&a.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,g=e.max??1,u=e.step||(g-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=(g-l)/2;this.imageContainer=null;var h=this._createElement({class:"p-gui__slider",textContent:i}),f=this._createElement({parent:h,el:"input",class:"p-gui__slider-ctrl",customAttributes:{type:"range",min:l,max:g,step:u,value:r?s[n]:a}}),x=this._createElement({parent:h,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,g=this.propReferences.push(a[l])-1,u=e.y.obj||e.y.object,h=e.y.prop||e.y.property,f=this.propReferences.push(u[h])-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]+", "+u[h]}),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)),u[h]=parseFloat(this._mapLinear(d.offsetY,0,p.clientHeight,n,s).toFixed(2)),t&&t(a[l],a[h])}});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)),u[h]=parseFloat(this._mapLinear(d.offsetY,0,p.clientHeight,n,s).toFixed(2)),t&&t(a[l],a[h]))}),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(u[h],s,n,p.clientHeight,0)+"px",Object.defineProperty(a,l,{set:d=>{this.propReferences[g]=d,m.style.left=this._mapLinear(d,r,o,0,p.clientWidth)+"px",b.textContent=String(d)+", "+u[h]},get:()=>this.propReferences[g]}),Object.defineProperty(u,h,{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});
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,a=e.selectionBorder!==!1;let n="";e.width&&(typeof e.width=="number"&&(e.width+="px"),n+=`flex: 0 0 calc(${e.width} - 5px); `),e.height&&(typeof e.height=="number"&&(e.height+="px"),n+=`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+"); "+n,parent:this.imageContainer});s&&a&&l.classList.add("p-gui__image--selected"),this._createElement({parent:l,class:"p-gui__image-text",textContent:o}),typeof t=="function"&&(l.onclick=()=>{let g=this.imageContainer.querySelectorAll(".p-gui__image--selected");for(let h=0;h<g.length;h++)g[h].classList.remove("p-gui__image--selected");a&&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,a=e.prop||e.property,n=typeof e.value=="number"?e.value:null,l=e.min??0,g=e.max??1,h=e.step||(g-l)/100;if(n!==null)(a!=null||s!=null)&&console.warn('[GUI] slider() "obj" and "property" parameters are ignored when a "value" parameter is used.');else if(a!=null&&s!=null){if(typeof a!="string")throw Error(`[GUI] slider() "prop" (or "property") parameter must be an string. Received: ${typeof a}.`);if(typeof s!="object")throw Error(`[GUI] slider() "obj" (or "object") parameter must be an object. Received: ${typeof s}.`);i==" "&&(i=a),o=this.propReferences.push(s[a])-1,r=!0}else(a!=null&&s==null||a==null&&s==null)&&console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'),n=(g-l)/2;this.imageContainer=null;var u=this._createElement({class:"p-gui__slider",textContent:i}),f=this._createElement({parent:u,el:"input",class:"p-gui__slider-ctrl",customAttributes:{type:"range",min:l,max:g,step:h,value:r?s[a]:n}}),x=this._createElement({parent:u,class:"p-gui__slider-value",textContent:String(r?s[a]:n)});f.addEventListener("input",()=>{x.textContent=f.value,r&&(s[a]=f.value),typeof t=="function"&&t(parseFloat(f.value))}),r&&Object.defineProperty(s,a,{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:a=>{let n=a.target.childNodes[1],l=!0;n.classList.contains("p-gui__switch-checkbox--active")&&(l=!1),n.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,o=(()=>{if(!r)return null;if(typeof e.value=="string")return r.indexOf(e.value);if(typeof e.value=="number")return e.value})();console.log("->",o),t=typeof t=="function"?t:null,this.imageContainer=null;let s=this._createElement({class:"p-gui__list",textContent:i}),a=this._createElement({parent:s,el:"select",class:"p-gui__list-dropdown",onchange:n=>{t&&t(n.target.value)}});r&&r.forEach((n,l)=>{let g=this._createElement({parent:a,el:"option",customAttributes:{value:n},textContent:n});o==l&&g.setAttribute("selected","")})}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,a=e.y.max??1,n=e.x.obj||e.x.object,l=e.x.prop||e.x.property,g=this.propReferences.push(n[l])-1,h=e.y.obj||e.y.object,u=e.y.prop||e.y.property,f=this.propReferences.push(h[u])-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:n[l]+", "+h[u]}),p=this._createElement({parent:x,el:"div",class:"p-gui__vector2-area",onclick:d=>{n[l]=parseFloat(this._mapLinear(d.offsetX,0,p.clientWidth,r,o).toFixed(2)),h[u]=parseFloat(this._mapLinear(d.offsetY,0,p.clientHeight,a,s).toFixed(2)),t&&t(n[l],n[u])}});let y=!1;p.addEventListener("pointerdown",d=>{y=!0}),p.addEventListener("pointerup",()=>{y=!1}),p.addEventListener("pointermove",d=>{y&&(n[l]=parseFloat(this._mapLinear(d.offsetX,0,p.clientWidth,r,o).toFixed(2)),h[u]=parseFloat(this._mapLinear(d.offsetY,0,p.clientHeight,a,s).toFixed(2)),t&&t(n[l],n[u]))}),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(n[l],r,o,0,p.clientWidth)+"px",m.style.top=this._mapLinear(h[u],s,a,p.clientHeight,0)+"px",Object.defineProperty(n,l,{set:d=>{this.propReferences[g]=d,m.style.left=this._mapLinear(d,r,o,0,p.clientWidth)+"px",b.textContent=String(d)+", "+h[u]},get:()=>this.propReferences[g]}),Object.defineProperty(h,u,{set:d=>{this.propReferences[f]=d,m.style.top=this._mapLinear(d,s,a,p.clientHeight,0)+"px",b.textContent=n[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 a=r?`background-color: ${r};`:"";a+=o?`max-height: ${o}px;`:"";let n=this._createElement({class:s,inline:a});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:n});let l=new c({isFolder:!0,folderOptions:{wrapper:n}});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.1",
3
+ "version": "4.3.3",
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 = () => {
@@ -466,6 +484,18 @@ export default class GUI {
466
484
 
467
485
  let name = typeof params.name == 'string' ? params.name : ' ';
468
486
  let values = Array.isArray(params.values) ? params.values : null;
487
+ let value = (() => {
488
+ if (!values) {
489
+ return null;
490
+ }
491
+ if (typeof params.value == 'string') {
492
+ return values.indexOf(params.value);
493
+ }
494
+ if (typeof params.value == 'number') {
495
+ return params.value;
496
+ }
497
+ })();
498
+ console.log('->',value);
469
499
  callback = typeof callback == 'function' ? callback : null;
470
500
 
471
501
  this.imageContainer = null;
@@ -486,16 +516,23 @@ export default class GUI {
486
516
  }
487
517
  });
488
518
 
489
- values.forEach(item => {
490
- this._createElement({
491
- parent: select,
492
- el: 'option',
493
- customAttributes: {
494
- value: item,
495
- },
496
- textContent: item
519
+ if (values)
520
+ {
521
+ values.forEach((item, index) =>
522
+ {
523
+ let option = this._createElement({
524
+ parent: select,
525
+ el: 'option',
526
+ customAttributes: {
527
+ value: item,
528
+ },
529
+ textContent: item
530
+ });
531
+ if (value == index) {
532
+ option.setAttribute('selected', '');
533
+ }
497
534
  });
498
- });
535
+ }
499
536
  }
500
537
 
501
538
  options(params, callback) {
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 {