Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #23 from Laaouatni/popup-created-automatically-wih…
Browse files Browse the repository at this point in the history
…out-write-it-in-html

fix: #22 Popup created automatically wihout write it in html
  • Loading branch information
Laaouatni authored Aug 19, 2022
2 parents 5e2d85f + e148ec9 commit 3caef5d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
10 changes: 2 additions & 8 deletions gcode/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
</head>
<body>
<div id="app">
<div id="tooltip" role="tooltip">
<span>hello waaaaaaa</span>

<div id="arrow"></div>
</div>

<section id="hello"></section>
</div>

Expand Down Expand Up @@ -60,6 +54,7 @@
top: var(--line-top);
left: var(--line-left);
transform: rotate(var(--line-rotate));
z-index: var(--line-zIndex);
}

.Gline::before {
Expand All @@ -86,8 +81,7 @@
position: absolute;
top: 50%;
right: 0;
transform: translate(0, -50%);
z-index: 5 !important;
transform: translate(50%, -50%);
}

.Gline::before {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
import updatePopup from "./other/Methods/updatePopup/updatePopup";
import updatePopup from "./other/Methods/updatePopup/updatePopup.js";

export default class CssFloatPopup {
static popup;
static span;
static arrow;

static {
CssFloatPopup.popup = document.createElement("div");
CssFloatPopup.span = document.createElement("span");
CssFloatPopup.arrow = document.createElement("div");

CssFloatPopup.popup.id = "tooltip";
CssFloatPopup.popup.role = "tooltip";

CssFloatPopup.span.style.setProperty("white-space", "pre");

CssFloatPopup.arrow.id = "arrow";

CssFloatPopup.popup.appendChild(CssFloatPopup.span);
CssFloatPopup.popup.appendChild(CssFloatPopup.arrow);
}

constructor(_obj) {
this.obj = _obj;

this.button = this.obj.button;
this.popup = this.obj.popup;
this.arrow = this.obj.arrow ?? this.obj.popup.querySelector("#arrow");

this.popupText = this.popup.querySelector("span");

this.popup = CssFloatPopup.popup;
this.arrow = CssFloatPopup.arrow;
this.span = CssFloatPopup.span;

this.addDefaultStyles();
this.addEvents();
Expand All @@ -20,7 +40,7 @@ export default class CssFloatPopup {

showPopup() {
this.popup.style.display = "block";
this.popupText.textContent = `${this.button.dataset.after}`;
this.span.textContent = `${this.button.dataset.line}`;
updatePopup(this);
}

Expand Down Expand Up @@ -49,7 +69,7 @@ export default class CssFloatPopup {
this.popup.style.setProperty(key, this.PopupValuesArray[index]);
});

this.popupText.style.setProperty("white-space", "pre");
this.span.style.setProperty("white-space", "pre");
}

styleArrow() {
Expand Down
5 changes: 2 additions & 3 deletions gcode/src/API/GcodeApi/Gsimulator/Gcss/CssLine/CssLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default class CssLine {
constructor(_CurrentObj, _index) {
this.index = _index;
this.lineElement = document.createElement("div");
this.popupEl = document.querySelector("#tooltip");

this.currentObj = _CurrentObj;
this.previusObj = GcodeAPI.array[this.index - 1 > 0 ? this.index - 1 : 0];
Expand Down Expand Up @@ -34,7 +33,6 @@ export default class CssLine {

this.createPopup({
button: this.lineElement,
popup: this.popupEl
});

}
Expand All @@ -59,6 +57,7 @@ export default class CssLine {
top: `${this.smallestPos.y}px`,
rotate: `${this.lineAngle}deg`,
backgroundColor: "red",
zIndex: `${GcodeAPI.array.length - this.index}`
};

this.stylesKeysArray = Object.keys(this.lineStylesObj);
Expand All @@ -74,7 +73,7 @@ export default class CssLine {
this.lineElement.classList.add("Gline");
this.lineElement.setAttribute("key", this.index);
this.lineElement.setAttribute(
"data-after",
"data-line",
`${JSON.stringify({
length: this.lineLength,
x: this.currentObj.x,
Expand Down
3 changes: 3 additions & 0 deletions gcode/src/API/GcodeApi/Gsimulator/Gcss/Gcss.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Gsimulator from "../Gsimulator.js";
import GcodeAPI from "../../GcodeAPI_main/GcodeAPI.js";
import CssLine from "./CssLine/CssLine.js";
import CssFloatPopup from "./CssFloatPopup/CssFloatPopup.js";

export default class Gcss extends Gsimulator {
constructor(_GcssObj) {
Expand All @@ -14,6 +15,8 @@ export default class Gcss extends Gsimulator {
document.querySelector("#app") ??
document.body;

this.parentHtmlContainer.appendChild(CssFloatPopup.popup);

this.create();
}

Expand Down

1 comment on commit 3caef5d

@vercel
Copy link

@vercel vercel bot commented on 3caef5d Aug 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gcode-js – ./

gcode-js-laaouatni.vercel.app
gcode-js.vercel.app
gcode-js-git-main-laaouatni.vercel.app

Please sign in to comment.