From c072ac261fed78f0609074718f34ad89ddc0a842 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Wed, 22 May 2024 14:36:32 +0400 Subject: [PATCH] remove js and css from profile view --- public/js_original/profile-view.js | 30 ++++++++++ public/styles/views/Profile.css | 27 ++++++++- src/views/Profile.php | 88 ++++++------------------------ webpack.config.js | 1 + 4 files changed, 72 insertions(+), 74 deletions(-) create mode 100644 public/js_original/profile-view.js diff --git a/public/js_original/profile-view.js b/public/js_original/profile-view.js new file mode 100644 index 00000000..63ef7341 --- /dev/null +++ b/public/js_original/profile-view.js @@ -0,0 +1,30 @@ +function openTab(evt, tabName) { + console.log("New tab = " + tabName); + + // hide all tab contents + const tabcontents = [...document.getElementsByClassName("tabcontent")]; + for (let i = 0; i < tabcontents.length; i++) { + tabcontents[i].style.display = "none"; + } + + // remove active class from the currently active tab link + const tablinks = document.getElementsByClassName("tablink"); + for (let i = 0; i < tablinks.length; i++) { + tablinks[i].className = tablinks[i].className.replace(" active", ""); + } + + // display content for clicked tab + document.getElementById(tabName).style.display = "block"; + + // set active class only to the clicked tab link + evt.currentTarget.className += " active"; +} + +const tabs = ["Account", "Orders", "Settings"]; + +window.addEventListener("DOMContentLoaded", () => { + [...document.getElementsByClassName("tablink")].forEach((tablink, i) => { + console.log(i, tablink); + tablink.addEventListener("click", (e) => openTab(e, tabs[i])); + }); +}); \ No newline at end of file diff --git a/public/styles/views/Profile.css b/public/styles/views/Profile.css index dd8bc4cb..f89067b5 100644 --- a/public/styles/views/Profile.css +++ b/public/styles/views/Profile.css @@ -18,11 +18,32 @@ button[name="account_delete_submit"] { background-color: red; } -table button{ - padding:5px; +table button { + padding: 5px; } -table tr button:first-of-type{ +table tr button:first-of-type { border: 0; background-color: red; +} + +/* Style tab links */ +.tablink { + float: left; + border: none; + outline: none; + cursor: pointer; + font-size: 17px; + background-color: var(--secondary); +} + +.active { + background-color: var(--contrast); + color: var(--contrast-inverse); +} + +/* Style the tab content (and add height:100% for full page content) */ +.tabcontent { + display: none; + padding: 20px 0; } \ No newline at end of file diff --git a/src/views/Profile.php b/src/views/Profile.php index 14f600b3..e4b95f30 100644 --- a/src/views/Profile.php +++ b/src/views/Profile.php @@ -15,27 +15,22 @@ ?> - + + +
+

Deleting your account!

+

Are you sure you want to delete your account? This action is irreversible.

+ +
+
+

My profile

@@ -173,53 +168,4 @@
- - - - -
-

Deleting your account!

-

Are you sure you want to delete your account? This action is irreversible.

- -
-
- \ No newline at end of file + \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 0e3497f2..42397bb1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,6 +7,7 @@ module.exports = { global_view: entryPath + "global-view.js", home_view: entryPath + "home-view.js", product_view: entryPath + "product-view.js", + profile_view: entryPath + "profile-view.js", cart_view: entryPath + "cart-view.js", theme_switcher: entryPath + "theme-switcher.js", },