From 05e20d25d26b53f99ded58fcad59bdb0ad29a886 Mon Sep 17 00:00:00 2001 From: NetMan <13informatyka14@gmail.com> Date: Wed, 7 Feb 2024 17:38:08 +0100 Subject: [PATCH] Little changes, grid, adding "template" elements --- src/elements/project.js | 0 src/elements/task.js | 9 +++++++++ src/main.js | 5 ++++- src/modules/genElement.js | 11 +++++++++++ src/template.html | 10 +++++----- tailwind.config.js | 6 +++++- 6 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 src/elements/project.js create mode 100644 src/elements/task.js create mode 100644 src/modules/genElement.js diff --git a/src/elements/project.js b/src/elements/project.js new file mode 100644 index 0000000..e69de29 diff --git a/src/elements/task.js b/src/elements/task.js new file mode 100644 index 0000000..4eb3dda --- /dev/null +++ b/src/elements/task.js @@ -0,0 +1,9 @@ +import generateElement from "../modules/genElement"; + +const task = generateElement({ + element: "div", + className: "task text-4xl", + innerHTML: "task", +}) + +export default task; \ No newline at end of file diff --git a/src/main.js b/src/main.js index 319c5bb..b267151 100644 --- a/src/main.js +++ b/src/main.js @@ -19,4 +19,7 @@ function firstLaunch() { document.addEventListener("DOMContentLoaded", firstLaunch); -pubsub.subscribe("refreshDOM", refreshDOM); \ No newline at end of file +pubsub.subscribe("refreshDOM", refreshDOM); + +import task from "./elements/task"; +app.append(task); \ No newline at end of file diff --git a/src/modules/genElement.js b/src/modules/genElement.js new file mode 100644 index 0000000..f8bdbe0 --- /dev/null +++ b/src/modules/genElement.js @@ -0,0 +1,11 @@ +export default function generateElement(obj) { + if (!obj.element) { + throw new Error("No element argument provided"); + } else { + const element = document.createElement(`${obj.element}`); + for (let key in obj) { + element[key] = obj[key]; + } + return element; + } +} \ No newline at end of file diff --git a/src/template.html b/src/template.html index 107f7fe..90230bb 100644 --- a/src/template.html +++ b/src/template.html @@ -5,17 +5,17 @@