Skip to content

Commit

Permalink
Use Vue Router to get started on different screens
Browse files Browse the repository at this point in the history
  • Loading branch information
range-of-motion committed Oct 23, 2023
1 parent 3695b3c commit 75c8108
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 11 deletions.
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"dependencies": {
"axios": "^0.26.0",
"vue-color": "^2.7.0"
"vue-color": "^2.7.0",
"vue-router": "3"
}
}
25 changes: 22 additions & 3 deletions resources/assets/js/prototype/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
import Vue from 'vue';
import VueRouter from 'vue-router';

import App from './components/App.vue';

const app = new Vue({
import Login from './screens/Login.vue';

Vue.use(VueRouter);

const routes = [
{
path: '/prototype/login',
name: 'login',
component: Login,
},
];

const router = new VueRouter({
mode: 'history',
routes,
});

new Vue({
el: '#app',
render: h => h(App)
})
router,
render: h => h(App),
});
6 changes: 2 additions & 4 deletions resources/assets/js/prototype/components/App.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<script setup>
//
</script>

<template>
<div>
<div>Hello world</div>
</div>
<router-view></router-view>
</template>
19 changes: 19 additions & 0 deletions resources/assets/js/prototype/screens/Login.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script setup>
//
</script>

<template>
<div class="max-w-sm mx-auto my-12">
<div class="p-5 bg-white border rounded-md space-y-5">
<div>
<label class="block mb-1 text-sm text-gray-700">E-mail</label>
<input class="w-full px-3 py-2 text-sm border rounded-md" type="email" />
</div>
<div>
<label class="block mb-1 text-sm text-gray-700">Password</label>
<input class="w-full px-3 py-2 text-sm border rounded-md" type="password" />
</div>
<button class="w-full py-2.5 hover:bg-blue-600 transition text-sm bg-blue-500 text-white rounded-md">Log in</button>
</div>
</div>
</template>
3 changes: 3 additions & 0 deletions resources/views/prototype.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div id="app"></div>
@vite('resources/assets/js/prototype/app.js')
Expand Down
8 changes: 6 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

Route::get('/', [IndexController::class, 'index'])->name('index');

Route::get('/prototype', \App\Http\Controllers\PrototypeController::class);

Route::group(['middleware' => ['guest']], function () {
Route::get('/login', [LoginController::class, 'index'])->name('login');
Route::post('/login', [LoginController::class, 'store']);
Expand Down Expand Up @@ -133,3 +131,9 @@
});

Route::get('/logout', [LogoutController::class, 'index'])->name('logout');

Route::prefix('prototype')
->group(function () {
Route::get('/', fn () => 'Hello world');
Route::get('/{any}', \App\Http\Controllers\PrototypeController::class);
});

0 comments on commit 75c8108

Please sign in to comment.