From 5896c35d541c1e51c0a1209b357038d2b09b3524 Mon Sep 17 00:00:00 2001 From: anulax1225 Date: Fri, 15 Dec 2023 09:04:26 +0100 Subject: [PATCH] Testing templates --- css/style.css | 27 ++++++++++++++++++++++----- html/template.html | 10 +++++----- html/templates/contracts.html | 0 html/templates/home.html | 4 ++++ html/templates/login.html | 8 ++++++++ html/templates/register.html | 0 html/templates/ships.html | 0 html/templates/systems.html | 0 js/index.js | 22 ++++++++++++++-------- js/ui/templeting_engine.js | 4 ++-- 10 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 html/templates/contracts.html create mode 100644 html/templates/login.html create mode 100644 html/templates/register.html create mode 100644 html/templates/ships.html create mode 100644 html/templates/systems.html diff --git a/css/style.css b/css/style.css index 0fa94e7..4157a3a 100644 --- a/css/style.css +++ b/css/style.css @@ -20,6 +20,20 @@ body { padding: 0px; } +/* Main */ +.container { + display: flex; + margin: 10px; + flex-direction: column; + align-items: center; + border: 4px solid rgba(68, 68, 68, 0.575); +} + +.container .con-title { + font-size: 15px; + border-bottom: 2px solid black; +} + /*footer*/ footer { position: fixed; @@ -39,11 +53,13 @@ footer { justify-content: space-between; align-items: center; } + .nav-nav .nav-brand { display: flex; justify-content: center; align-items: center; } + .nav-nav .nav-brand img { width: var(--nav-img-width); } @@ -57,11 +73,6 @@ footer { justify-content: space-between; } -.smooth { - padding: 5px; - border-radius: 10px; -} - .nav-link { margin-right: 10px; background-color: var(--links-backcolor); @@ -72,4 +83,10 @@ footer { justify-content: center; align-items: center; box-shadow: 3px 2px white; +} + +/* General */ +.smooth { + padding: 5px; + border-radius: 10px; } \ No newline at end of file diff --git a/html/template.html b/html/template.html index 1dd5c17..d988745 100644 --- a/html/template.html +++ b/html/template.html @@ -3,11 +3,11 @@
diff --git a/html/templates/contracts.html b/html/templates/contracts.html new file mode 100644 index 0000000..e69de29 diff --git a/html/templates/home.html b/html/templates/home.html index e69de29..6692b32 100644 --- a/html/templates/home.html +++ b/html/templates/home.html @@ -0,0 +1,4 @@ +
+

Bienvenue sur SkamCraft

+

Application client pour l'API Space Tarders.

+
\ No newline at end of file diff --git a/html/templates/login.html b/html/templates/login.html new file mode 100644 index 0000000..6ffa211 --- /dev/null +++ b/html/templates/login.html @@ -0,0 +1,8 @@ +
+

Login

+ +
+ + +
+
\ No newline at end of file diff --git a/html/templates/register.html b/html/templates/register.html new file mode 100644 index 0000000..e69de29 diff --git a/html/templates/ships.html b/html/templates/ships.html new file mode 100644 index 0000000..e69de29 diff --git a/html/templates/systems.html b/html/templates/systems.html new file mode 100644 index 0000000..e69de29 diff --git a/js/index.js b/js/index.js index a155af6..e5bd147 100644 --- a/js/index.js +++ b/js/index.js @@ -1,13 +1,19 @@ import {UIRenderer} from "./ui/templeting_engine.js"; let UI = new UIRenderer("html"); +UI.render("templates/home.html") +function init_menu_link(tag, template) { + UI.add_event(tag, "click", () => { + UI.render(`templates/${template}`); + }) +} -UI.render("templates/home.html"); - -UI.add_event("#btn1", "click", () => { - UI.render("templates/test2.html"); -}); -UI.add_event("#btn2", "click", () => { - UI.render("templates/test.html"); -}) \ No newline at end of file +$(document).ready(() => { + init_menu_link("#contracts-link", "contracts.html"); + init_menu_link("#ships-link", "ships.html"); + init_menu_link("#systems-link", "systems.html"); + init_menu_link("#signup-link", "register.html"); + init_menu_link("#signin-link", "login.html"); + init_menu_link(".nav-brand", "home.html"); +}); \ No newline at end of file diff --git a/js/ui/templeting_engine.js b/js/ui/templeting_engine.js index 05af941..886a52a 100644 --- a/js/ui/templeting_engine.js +++ b/js/ui/templeting_engine.js @@ -2,11 +2,11 @@ export class UIRenderer { constructor(path) { this.templatePath = path; } - render(template) { + render(template, tag = "#block-content") { this.get_template((reponse) => { $('body').html(reponse); this.get_template((reponse) => { - $('#block-content').html(reponse); + $(tag).html(reponse); }, template) }); }