Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"test": "jest",
"prebuild": "rm -rf docs",
"build": "webpack; mv dist docs; git checkout docs/index.html",
"build": "webpack; mv dist docs; cp public/index.html docs/index.html",
"start": "node src/services/shopifyAPI.js"
},
"dependencies": {
Expand Down
10 changes: 10 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>scriptTag test</title>
</head>
<body>
<script src="./bundle.js"></script>
</body>
</html>
58 changes: 58 additions & 0 deletions src/components/custom/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.button {
padding: 10px;
cursor: pointer;
}

.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}

.custom-popup {
padding: 20px;
background: #ccc;
width: 28%;
position: relative;
transition: all 5s ease-in-out;
}

.custom-popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.custom-popup .custom-close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.custom-popup .custom-close:hover {
color: #06d85f;
}
.custom-popup .content {
max-height: 30%;
overflow: auto;
}

@media screen and (max-width: 700px) {
.box {
width: 70%;
}
.custom-popup {
width: 70%;
}
}
19 changes: 19 additions & 0 deletions src/components/custom/custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div id="custom" class="overlay">
<div class="custom-popup">
<h2>Customize the theme</h2>
<a class="custom-close" href="#">&times;</a>
<div class="content">
<form>
<div>
background-color:
<input type="text" name="background-color" value="rgba(100, 91, 91, 0.7)">
</div>
<div>
main-text-color:
<input type="text" name="main-text-color" value="#aaa">
</div>
<button type="submit" class="custom-submit">Submit</button>
</form>
</div>
</div>
</div>
26 changes: 26 additions & 0 deletions src/components/custom/custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import "./custom.css";
import html from "./custom.html";

const $ = document.querySelector.bind(document);

const setStyle = (e) => {
const p = `--${e}`;
const v = $(`[name='${e}']`).value;
document.documentElement.style.setProperty(p, v);
};

const getInputNames = (e) =>
Array.from(e.querySelectorAll("input")).map((e) => e.name);

const init = () => {
$("form").addEventListener("submit", (e) => {
e.preventDefault();
getInputNames(e.target).forEach((e) => setStyle(e));
});
};

const node = document.createElement("div");
node.innerHTML = html;
document.body.appendChild(node);

export const custom = init;
1 change: 1 addition & 0 deletions src/components/popup/popup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div class="cart__loader-container" data-account-loader="" style="display: none;">
<div class="lds-dual-ring"></div>
</div>
<div class=""><a class="button" href="#custom">Edit</a></div>
<div class="account-popup__close-popup">+</div>
<div class="account-popup__container"></div>
</div>
Expand Down
11 changes: 9 additions & 2 deletions src/components/popup/popup.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
:root {
--background-color: rgba(100, 91, 91, 0.7);
--main-text-color: #111;
}

div.account-popup {
width: 100%;
color: var(--main-text-color);
width: 70%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
background-color: var(--background-color);
position: absolute;
top: 0;
display: none;
justify-content: center;
align-items: center;
z-index: 100;
right: 0;
}

div.account-popup__close-popup {
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { popupComponent } from "./components/popup/popup";
import { email } from "./services/change-component";
import { custom } from "./components/custom/custom";

document.body.appendChild(popupComponent());
email();
custom();