Skip to content

Commit

Permalink
added vite alpinejs
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryoalli committed Jun 10, 2023
1 parent e19a3f3 commit ff85aa5
Show file tree
Hide file tree
Showing 9 changed files with 2,571 additions and 1,677 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
node_modules/
vendor/
public/css/build/
public/build/
public/manifest.json
26 changes: 26 additions & 0 deletions app/Core/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,29 @@ function clearSession()
session_destroy();
}
}


function js($key)
{
// Ruta al archivo manifest.json
$manifestPath = __DIR__ . '/../../public/manifest.json';

// Comprueba si el archivo existe
if (!file_exists($manifestPath)) {
throw new Exception('Manifest file does not exist.');
}

// Obtiene el contenido del archivo
$manifestContents = file_get_contents($manifestPath);

// Decodifica el JSON
$manifest = json_decode($manifestContents, true);

// Comprueba si la clave existe en el manifiesto
if (!array_key_exists($key, $manifest)) {
throw new Exception("Key {$key} does not exist in manifest.");
}

// Devuelve el valor de la clave
return "/{$manifest[$key]["file"]}";
}
11 changes: 11 additions & 0 deletions app/views/index.view.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php require('partials/head.view.php'); ?>

<div x-data="{open:false}" class="max-w-screen-lg mx-auto">
<h1>Home Page</h1>
<button @click="open = !open" class="bg-blue-500 px-4 py-1.5">Open Modal</button>
<div x-show="open" class="fixed inset-0 z-10 flex items-center justify-center bg-black bg-opacity-50">
<div class="p-8 bg-white rounded-lg">
<h2>Modal Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatum.</p>
<button class="text-xs bg-gray-300" @click="open = false">Close</button>
</div>
</div>

</div>

<?php require('partials/footer.view.php'); ?>
3 changes: 2 additions & 1 deletion app/views/partials/head.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<head>
<meta charset="UTF-8">
<title><?php echo env('APP_NAME','Mini PHP Framework'); ?></title>
<link href="/css/build/app.css" rel="stylesheet">
<link href="/build/css/app.css" rel="stylesheet">
<script defer src="<?= js('resources/js/app.js') ?>"></script>
</head>
<body class="h-screen bg-gray-50">

Expand Down
Loading

0 comments on commit ff85aa5

Please sign in to comment.