-
Pack Preview (${pack.stickers.length} stickers)
-
- ${stickers.join("\n")}
-
-
-`};
-
-module.exports = _packPreview;
diff --git a/src/templates/pack.js b/src/templates/pack.js
deleted file mode 100644
index 8581553..0000000
--- a/src/templates/pack.js
+++ /dev/null
@@ -1,68 +0,0 @@
-const PackHead = require("./components/packHead");
-const PackCard = require("./components/packCard");
-const PackLinks = require("./components/packLinks");
-const PackPreview = require("./components/packPreview");
-const { InjectWSConnection } = require("../utils")
-
-function _CreatePackPage(index, pack, isDev) {
- return `
-
-
-
-
- ${PackHead(index, pack)}
- ${isDev ? InjectWSConnection() : ""}
-
-
-
-
-
- ${PackCard(index, pack)}
-
- ${PackLinks(pack)}
-
- ${PackPreview(index, pack)}
-
-
-
-
- Type /devtools in chat. Other -> Explore account data in Element Web (not "room account data", must be the global one), edit the m.widgets account data event to have the following content:
-
-
-{
- "stickerpicker": {
- "content": {
- "type": "m.stickerpicker",
- "url": "https://matrix.wah.su/stickerpicker/?theme=$theme",
- "name": "Stickerpicker",
- "creatorUserId": "@you:matrix.server.name",
- "data": {}
- },
- "sender": "@you:matrix.server.name",
- "state_key": "stickerpicker",
- "type": "m.widget",
- "id": "stickerpicker"
- }
-}
-
-
- If you do not yet have a m.widgets event, simply create it with that content. You can also use the client-server API directly instead of using Element Web.
-
-
- The theme=$theme query parameter will make the widget conform to Element's theme automatically. You can also use light, dark or black instead of $theme to always use a specific theme.
-
-
Close
-
-
-
-
-
-
- `
-}
-
-module.exports = _CreatePackPage
\ No newline at end of file
diff --git a/src/utils.js b/src/utils.js
index 4ef9484..68cc965 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -1,3 +1,7 @@
+CreateImageURL = function (homeserverUrl, id) {
+ return `${homeserverUrl}${id.slice(0, 2)}/${id.slice(2, 4)}/${id.slice(4)}`;
+};
+
function CreatePackDescription(pack) {
let description = [];
@@ -30,11 +34,15 @@ function CreatePackDescription(pack) {
return description.join(" | ");
}
-function log(level = "INFO" | "ERROR" | "WARN" | "LOG", message, connected = false) {
- const date = new Date;
- const time = date.toLocaleTimeString()
+function log(
+ level = "INFO" | "ERROR" | "WARN" | "LOG",
+ message,
+ connected = false
+) {
+ const date = new Date();
+ const time = date.toLocaleTimeString();
if (connected) {
- message = `↳${message}`
+ message = `↳${message}`;
}
switch (level.toUpperCase()) {
case "INFO":
@@ -54,5 +62,6 @@ function log(level = "INFO" | "ERROR" | "WARN" | "LOG", message, connected = fal
module.exports = {
log,
- CreatePackDescription
+ CreatePackDescription,
+ CreateImageURL
};
diff --git a/src/watch.js b/src/watch.js
index b7c9a29..2418555 100644
--- a/src/watch.js
+++ b/src/watch.js
@@ -10,6 +10,7 @@ const { log } = require("./utils");
let triggered = 0;
const delay = 1000;
let SIGINTCount = 0;
+let WSclients = [];
const InpPath = path
.join(__dirname, "../", config.stickerPacksDir, "./")
@@ -20,7 +21,7 @@ log("INFO", `Sticker sets directory: ${InpPath}`);
log("INFO", `Output directory: ${OutPath}`);
log("INFO", `Working directory: ${ParPath}`);
-function onChange(wss) {
+function onChange() {
if (triggered != 0 && Date.now() - triggered < delay) {
log("WARN", `Rebuild was triggered less than a ${delay}ms ago!`, true);
return;
@@ -38,9 +39,9 @@ function onChange(wss) {
return;
}
log("INFO", stdout);
- if (wss) {
+ if (WSclients.length > 0) {
log("INFO", "Reloading web page...");
- wss.send("RELOAD");
+ WSclients.forEach((ws) => ws.send("RELOAD"));
}
});
}
@@ -86,18 +87,19 @@ function startServerWithRebuild() {
const folder = path.join(__dirname, "..");
const wss = new WebSocket.Server({ port: 3001 });
- let WSclient = null;
wss.on("connection", (ws) => {
- WSclient = ws;
+ WSclients.push(ws);
+ log("INFO", `Client ${WSclients.length} connected`)
ws.send("CONNECTED");
});
+
process.on("SIGINT", () => {
SIGINTCount += 1;
- if (WSclient) {
+ if (WSclients.length > 0) {
async function _closeWS() {
- await WSclient.close();
+ WSclients.forEach(async (ws) => await ws.close())
}
_closeWS();
}
@@ -118,15 +120,15 @@ function startServerWithRebuild() {
watcher
.on("add", (path) => {
log("INFO", `File ${path} has been added, rebuilding...`);
- onChange(WSclient);
+ onChange();
})
.on("change", (path) => {
log("INFO", `File ${path} has been changed, rebuilding...`);
- onChange(WSclient);
+ onChange();
})
.on("unlink", (path) => {
log("INFO", `File ${path} has been removed, rebuilding...`);
- onChange(WSclient);
+ onChange();
});
});
}
diff --git a/static/OpenPopUp.js b/static/OpenPopUp.js
deleted file mode 100644
index 6fbdfb4..0000000
--- a/static/OpenPopUp.js
+++ /dev/null
@@ -1,13 +0,0 @@
-const ElementInstructionOV = document.getElementById(
- "preview_sticker_pack_add_to_element_overlay"
-);
-const ElementInstruction = document.getElementById(
- "preview_sticker_pack_add_to_element"
-);
-
-function toggleElementInstruction() {
- ElementInstructionOV.classList.toggle("hidden");
- ElementInstruction.classList.toggle("hidden");
-
- ElementInstruction.classList.toggle("flex");
-}
diff --git a/static/RenderImages.js b/static/RenderImages.js
index 57509a1..b26f0e8 100644
--- a/static/RenderImages.js
+++ b/static/RenderImages.js
@@ -1,26 +1,26 @@
const images = document.querySelectorAll("[data-image-id]");
images.forEach((image, i) => {
+ if (i < 4) {
+ image.setAttribute("loading", "eager");
+ }
- if (i < 4) {
- image.setAttribute("loading", "eager")
- }
+ const spinner = document.querySelector(
+ `[data-spinner-id="${image.getAttribute("data-image-id")}"]`
+ );
- const spinner = document.querySelector(`[data-spinner-id="${image.getAttribute("data-image-id")}"]`)
+ if (image.height > 0 && image.complete) {
+ image.classList.remove("invisible");
+ spinner.classList.add("invisible");
+ return;
+ } else {
+ image.classList.add("invisible");
+ spinner.classList.remove("invisible");
+ }
- if (image.height > 0 && image.complete) {
- image.classList.remove("invisible");
- spinner.classList.add("invisible");
- return
- } else {
- image.classList.add("invisible");
- spinner.classList.remove("invisible");
- }
-
- image.addEventListener("load", () => {
- console.log("image " + image.getAttribute("data-image-id") + " loaded");
- image.classList.remove("invisible");
- spinner.classList.add("invisible");
- image.removeEventListener("load", this);
- });
-
-});
\ No newline at end of file
+ image.addEventListener("load", () => {
+ console.log("image " + image.getAttribute("data-image-id") + " loaded");
+ image.classList.remove("invisible");
+ spinner.classList.add("invisible");
+ image.removeEventListener("load", this);
+ });
+});
diff --git a/static/tailwind.css b/static/tailwind.css
index 4409599..b54ece5 100644
--- a/static/tailwind.css
+++ b/static/tailwind.css
@@ -588,18 +588,6 @@ video {
}
}
-.sr-only {
- position: absolute;
- width: 1px;
- height: 1px;
- padding: 0;
- margin: -1px;
- overflow: hidden;
- clip: rect(0, 0, 0, 0);
- white-space: nowrap;
- border-width: 0;
-}
-
.invisible {
visibility: hidden;
}
@@ -620,10 +608,6 @@ video {
left: 0px;
}
-.left-1\/2 {
- left: 50%;
-}
-
.right-0 {
right: 0px;
}
@@ -632,10 +616,6 @@ video {
top: 0px;
}
-.top-8 {
- top: 2rem;
-}
-
.-z-10 {
z-index: -10;
}
@@ -648,15 +628,15 @@ video {
z-index: 10;
}
-.z-20 {
- z-index: 20;
-}
-
.mx-auto {
margin-left: auto;
margin-right: auto;
}
+.mb-4 {
+ margin-bottom: 1rem;
+}
+
.line-clamp-1 {
overflow: hidden;
display: -webkit-box;
@@ -664,6 +644,10 @@ video {
-webkit-line-clamp: 1;
}
+.block {
+ display: block;
+}
+
.inline {
display: inline;
}
@@ -684,26 +668,23 @@ video {
aspect-ratio: 1 / 1;
}
-.h-16 {
- height: 4rem;
-}
-
-.h-24 {
- height: 6rem;
-}
-
-.h-48 {
- height: 12rem;
-}
-
.h-6 {
height: 1.5rem;
}
+.h-fit {
+ height: -moz-fit-content;
+ height: fit-content;
+}
+
.h-full {
height: 100%;
}
+.min-h-16 {
+ min-height: 4rem;
+}
+
.min-h-screen {
min-height: 100vh;
}
@@ -720,10 +701,6 @@ video {
width: 6rem;
}
-.w-48 {
- width: 12rem;
-}
-
.w-8 {
width: 2rem;
}
@@ -732,8 +709,8 @@ video {
width: 100%;
}
-.-translate-x-1\/2 {
- --tw-translate-x: -50%;
+.translate-y-\[var\(--tw-translate-y\)\] {
+ --tw-translate-y: var(--tw-translate-y);
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}
@@ -751,6 +728,10 @@ video {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
+.grid-cols-3 {
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+}
+
.grid-rows-1 {
grid-template-rows: repeat(1, minmax(0, 1fr));
}
@@ -787,6 +768,10 @@ video {
overflow-x: hidden;
}
+.whitespace-pre {
+ white-space: pre;
+}
+
.rounded-full {
border-radius: 9999px;
}
@@ -804,39 +789,22 @@ video {
border-bottom-left-radius: 0.5rem;
}
+.border-b {
+ border-bottom-width: 1px;
+}
+
+.border-slate-400 {
+ --tw-border-opacity: 1;
+ border-color: rgb(148 163 184 / var(--tw-border-opacity, 1));
+}
+
.bg-\[\#1d1f3d\] {
--tw-bg-opacity: 1;
background-color: rgb(29 31 61 / var(--tw-bg-opacity, 1));
}
-.bg-\[\#259d7b\] {
- --tw-bg-opacity: 1;
- background-color: rgb(37 157 123 / var(--tw-bg-opacity, 1));
-}
-
-.bg-\[\#282443\] {
- --tw-bg-opacity: 1;
- background-color: rgb(40 36 67 / var(--tw-bg-opacity, 1));
-}
-
-.bg-\[\#2f7ca3\] {
- --tw-bg-opacity: 1;
- background-color: rgb(47 124 163 / var(--tw-bg-opacity, 1));
-}
-
-.bg-\[\#373737\] {
- --tw-bg-opacity: 1;
- background-color: rgb(55 55 55 / var(--tw-bg-opacity, 1));
-}
-
-.bg-black {
- --tw-bg-opacity: 1;
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
-}
-
-.bg-red-600 {
- --tw-bg-opacity: 1;
- background-color: rgb(220 38 38 / var(--tw-bg-opacity, 1));
+.bg-\[var\(--bg-color\)\] {
+ background-color: var(--bg-color);
}
.bg-slate-800 {
@@ -844,16 +812,6 @@ video {
background-color: rgb(30 41 59 / var(--tw-bg-opacity, 1));
}
-.bg-stone-800 {
- --tw-bg-opacity: 1;
- background-color: rgb(41 37 36 / var(--tw-bg-opacity, 1));
-}
-
-.bg-stone-900 {
- --tw-bg-opacity: 1;
- background-color: rgb(28 25 23 / var(--tw-bg-opacity, 1));
-}
-
.bg-gradient-to-b {
background-image: linear-gradient(to bottom, var(--tw-gradient-stops));
}
@@ -901,21 +859,11 @@ video {
padding-bottom: 1rem;
}
-.py-8 {
- padding-top: 2rem;
- padding-bottom: 2rem;
-}
-
.text-2xl {
font-size: 1.5rem;
line-height: 2rem;
}
-.text-4xl {
- font-size: 2.25rem;
- line-height: 2.5rem;
-}
-
.text-lg {
font-size: 1.125rem;
line-height: 1.75rem;
@@ -926,11 +874,20 @@ video {
line-height: 1.25rem;
}
+.text-xl {
+ font-size: 1.25rem;
+ line-height: 1.75rem;
+}
+
.text-xs {
font-size: 0.75rem;
line-height: 1rem;
}
+.font-bold {
+ font-weight: 700;
+}
+
.text-gray-200 {
--tw-text-opacity: 1;
color: rgb(229 231 235 / var(--tw-text-opacity, 1));
@@ -961,25 +918,10 @@ video {
color: rgb(234 179 8 / var(--tw-text-opacity, 1));
}
-.text-zinc-100 {
- --tw-text-opacity: 1;
- color: rgb(244 244 245 / var(--tw-text-opacity, 1));
-}
-
.underline {
text-decoration-line: underline;
}
-.opacity-40 {
- opacity: 0.4;
-}
-
-.shadow-lg {
- --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
- --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);
- box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
-}
-
.transition-transform {
transition-property: transform;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
@@ -994,10 +936,6 @@ video {
grid-row: 1;
}
-.\[grid-template-columns\:repeat\(auto-fill\2c 96px\)\] {
- grid-template-columns: repeat(auto-fill,96px);
-}
-
.tiledBackground {
background-image: url('images/background-white.png');
background-repeat: repeat;
@@ -1019,8 +957,8 @@ video {
}
@media (min-width: 640px) {
- .sm\:inline {
- display: inline;
+ .sm\:flex {
+ display: flex;
}
.sm\:h-10 {
@@ -1035,10 +973,19 @@ video {
width: 8rem;
}
+ .sm\:grid-cols-4 {
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ }
+
.sm\:gap-4 {
gap: 1rem;
}
+ .sm\:px-8 {
+ padding-left: 2rem;
+ padding-right: 2rem;
+ }
+
.sm\:text-2xl {
font-size: 1.5rem;
line-height: 2rem;
@@ -1061,37 +1008,52 @@ video {
}
@media (min-width: 768px) {
- .md\:top-32 {
- top: 8rem;
+ .md\:block {
+ display: block;
}
- .md\:w-\[768px\] {
- width: 768px;
- }
-
- .md\:max-w-\[768px\] {
- max-width: 768px;
- }
-
- .md\:flex-row {
- flex-direction: row;
- }
-
- .md\:whitespace-pre {
- white-space: pre;
+ .md\:text-2xl {
+ font-size: 1.5rem;
+ line-height: 2rem;
}
}
@media (min-width: 1024px) {
+ .lg\:block {
+ display: block;
+ }
+
+ .lg\:hidden {
+ display: none;
+ }
+
+ .lg\:w-\[49\%\] {
+ width: 49%;
+ }
+
.lg\:grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
+
+ .lg\:grid-cols-3 {
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ }
+}
+
+@media (min-width: 1280px) {
+ .xl\:grid-cols-4 {
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ }
}
@media (min-width: 1536px) {
.\32xl\:grid-cols-3 {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
+
+ .\32xl\:grid-cols-5 {
+ grid-template-columns: repeat(5, minmax(0, 1fr));
+ }
}
@media (prefers-color-scheme: dark) {