From 5aafbe94d1bd3cd62f3ed3888c83fa46c5a513f0 Mon Sep 17 00:00:00 2001 From: Refringe Date: Wed, 19 Jun 2024 12:56:33 -0400 Subject: [PATCH] Moves Livewire into App JS Makes it easier to bundle for prod. --- composer.json | 11 ++++------- package-lock.json | 2 +- resources/js/app.js | 12 +++++++++--- resources/js/bootstrap.js | 3 +++ resources/views/layouts/app.blade.php | 2 +- resources/views/layouts/guest.blade.php | 5 +++-- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index bcdbae6..ca58eff 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,9 @@ { - "name": "laravel/laravel", + "name": "sp-tarkov/forge", "type": "project", - "description": "The skeleton application for the Laravel framework.", - "keywords": [ - "laravel", - "framework" - ], - "license": "MIT", + "description": "A Laravel-based web application that provides a platform for the Single Player Tarkov community to share and discover user-generated content, such as mods, guides, and other tools.", + "keywords": [], + "license": "MPL-2.0", "require": { "php": "^8.3", "ext-curl": "*", diff --git a/package-lock.json b/package-lock.json index 0e7a82a..8a574be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "html", + "name": "forge", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/resources/js/app.js b/resources/js/app.js index 1f65529..d42163c 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -2,12 +2,18 @@ import "./bootstrap"; import.meta.glob(["../video/**"]); -document.addEventListener("DOMContentLoaded", function () { +document.addEventListener("DOMContentLoaded", function() { const themeToggleIcon = { dark: document.getElementById("theme-toggle-dark-icon"), - light: document.getElementById("theme-toggle-light-icon"), + light: document.getElementById("theme-toggle-light-icon") }; + // Make sure the theme toggle icons are available. + if (themeToggleIcon.dark === null || themeToggleIcon.light === null) { + console.log("Theme toggle icons not found."); + return; + } + // Function to update the visibility of the theme icons based on the theme function updateIconVisibility(theme) { if (theme === "dark") { @@ -41,7 +47,7 @@ document.addEventListener("DOMContentLoaded", function () { // Set up the theme toggle button const themeToggleBtn = document.getElementById("theme-toggle"); - themeToggleBtn.addEventListener("click", function () { + themeToggleBtn.addEventListener("click", function() { // Determine the current theme by checking the classList of documentElement const currentTheme = document.documentElement.classList.contains("dark") ? "dark" : "light"; const newTheme = currentTheme === "light" ? "dark" : "light"; diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index f63c129..d86a460 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -1,4 +1,7 @@ +import { Livewire } from "../../vendor/livewire/livewire/dist/livewire.esm"; import axios from "axios"; +Livewire.start(); + window.axios = axios; window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest"; diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 11e17a4..65eb5f5 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -56,6 +56,6 @@ @livewire('global-search') @stack('modals') -@livewireScripts +@livewireScriptConfig diff --git a/resources/views/layouts/guest.blade.php b/resources/views/layouts/guest.blade.php index 3a33820..1281504 100644 --- a/resources/views/layouts/guest.blade.php +++ b/resources/views/layouts/guest.blade.php @@ -11,6 +11,8 @@ + +