Skip to content

Commit

Permalink
added router/routerLink/NotFoundPage and views
Browse files Browse the repository at this point in the history
  • Loading branch information
i-m-abbhay committed Nov 7, 2024
1 parent c9cdef3 commit aa421a7
Show file tree
Hide file tree
Showing 13 changed files with 819 additions and 122 deletions.
639 changes: 561 additions & 78 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"preview": "vite preview"
},
"dependencies": {
"@primevue/themes": "^4.2.1",
"primevue": "^4.2.1",
"vue": "^3.5.12"
"json-server": "^1.0.0-beta.3",
"primeicons": "^7.0.0",
"vue": "^3.5.12",
"vue-router": "^4.4.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.1.4",
Expand Down
11 changes: 2 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<script setup>
import Navbar from "@/components/Navbar.vue";
import Hero from "@/components/Hero.vue";
import HomeCards from "@/components/HomeCards.vue";
import JobListings from "./components/JobListings.vue";
import { RouterView } from "vue-router";
</script>
<template>
<Navbar />
<Hero
title="Become a Vue Dev!"
subtitle="Find the Vue job that fits your skills and needs"
/>
<HomeCards />
<JobListings :limit="5" :showButton="true" />
<RouterView />
</template>
13 changes: 7 additions & 6 deletions src/components/HomeCards.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup>
import Card from "@/components/Card.vue";
import { RouterLink } from "vue-router";
</script>

<template>
Expand All @@ -11,24 +12,24 @@ import Card from "@/components/Card.vue";
<p class="mt-2 mb-4">
Browse our Vue jobs and start your career today
</p>
<a
href="jobs.html"
<RouterLink
to="/jobs"
class="inline-block bg-black text-white rounded-lg px-4 py-2 hover:bg-gray-700"
>
Browse Jobs
</a>
</RouterLink>
</Card>
<Card bg="bg-green-100">
<h2 class="text-2xl font-bold">For Employers</h2>
<p class="mt-2 mb-4">
List your job to find the perfect developer for the role
</p>
<a
href="add-job.html"
<RouterLink
to="/jobs/add"
class="inline-block bg-green-500 text-white rounded-lg px-4 py-2 hover:bg-green-600"
>
Add Job
</a>
</RouterLink>
</Card>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/components/JobListing.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import { defineProps, ref, computed } from "vue";
import { RouterLink } from "vue-router";
const props = defineProps({ job: Object });
const showFullDesc = ref(false);
Expand Down Expand Up @@ -41,15 +41,15 @@ const truncatedDescription = computed(() => {

<div class="flex flex-col lg:flex-row justify-between mb-4">
<div class="text-orange-700 mb-3">
<i class="fa-solid fa-location-dot text-lg"></i>
<i class="pi pi-map-marker text-orange-700"></i>
{{ job.location }}
</div>
<a
:href="'/job/' + job.id"
<RouterLink
:to="'/jobs/' + job.id"
class="h-[36px] bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded-lg text-center text-sm"
>
Read More
</a>
</RouterLink>
</div>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions src/components/JobListings.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script setup>
import jobData from "@/jobs.json";
import { ref, defineProps } from "vue";
import JobListing from "./JobListing.vue";
import { RouterLink } from "vue-router";
const jobs = ref(jobData);
defineProps({
Expand All @@ -28,10 +30,10 @@ defineProps({
</div>
</section>
<section v-if="showButton" class="m-auto max-w-lg my-10 px-6">
<a
href="/jobs"
<RouterLink
to="/jobs"
class="block bg-black text-white text-center py-4 px-6 rounded-xl hover:bg-gray-700"
>View All Jobs</a
>View All Jobs</RouterLink
>
</section>
</template>
58 changes: 44 additions & 14 deletions src/components/Navbar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<script setup>
import { RouterLink, useRoute } from "vue-router";
import logo from "@/assets/img/logo.png";
const isActiveLink = (routePath) => {
const route = useRoute();
return route.path === routePath;
};
</script>

<template>
Expand All @@ -10,28 +16,52 @@ import logo from "@/assets/img/logo.png";
class="flex flex-1 items-center justify-center md:items-stretch md:justify-start"
>
<!-- Logo -->
<a class="flex flex-shrink-0 items-center mr-4" href="index.html">
<RouterLink class="flex flex-shrink-0 items-center mr-4" to="/">
<img class="h-10 w-auto" :src="logo" alt="Vue Jobs" />
<span class="hidden md:block text-white text-2xl font-bold ml-2"
>Vue Jobs</span
>
</a>
</RouterLink>
<div class="md:ml-auto">
<div class="flex space-x-2">
<a
href="index.html"
class="text-white bg-green-900 hover:bg-gray-900 hover:text-white rounded-md px-3 py-2"
>Home</a
<RouterLink
to="/"
:class="[
isActiveLink('/')
? 'bg-green-900'
: 'hover:bg-gray-900 hover:text-white',
'text-white',
'rounded-md',
'px-3',
'py-2',
]"
>Home</RouterLink
>
<a
href="jobs.html"
class="text-white hover:bg-green-900 hover:text-white rounded-md px-3 py-2"
>Jobs</a
<RouterLink
to="/jobs"
:class="[
isActiveLink('/jobs')
? 'bg-green-900'
: 'hover:bg-gray-900 hover:text-white',
'text-white',
'rounded-md',
'px-3',
'py-2',
]"
>Jobs</RouterLink
>
<a
href="add-job.html"
class="text-white hover:bg-green-900 hover:text-white rounded-md px-3 py-2"
>Add Job</a
<RouterLink
to="/jobs/add"
:class="[
isActiveLink('/jobs/add')
? 'bg-green-900'
: 'hover:bg-gray-900 hover:text-white',
'text-white',
'rounded-md',
'px-3',
'py-2',
]"
>Add Job</RouterLink
>
</div>
</div>
Expand Down
12 changes: 8 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import './assets/main.css'
import "./assets/main.css";
import "primeicons/primeicons.css";

import { createApp } from 'vue'
import App from './App.vue'
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";

createApp(App).mount('#app')
const app = createApp(App);
app.use(router);
app.mount("#app");
34 changes: 34 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { createRouter, createWebHistory } from "vue-router";

import HomeView from "@/views/HomeView.vue";
import JobsView from "@/views/JobsView.vue";
import NotFound from "@/views/404.vue";
import JobView from "@/views/JobView.vue";

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: "/",
name: "Home",
component: HomeView,
},
{
path: "/jobs",
name: "Jobs",
component: JobsView,
},
{
path: "/jobs/:id",
name: "Job",
component: JobView,
},
{
path: "/:catchAll(.*)",
name: "404",
component: NotFound,
},
],
});

export default router;
44 changes: 44 additions & 0 deletions src/views/404.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<div
class="flex flex-col items-center justify-center min-h-screen bg-gray-900 text-white"
>
<i class="pi pi-exclamation-triangle text-6xl mb-4"></i>
<h1 class="text-6xl font-bold mb-2">404</h1>
<p class="text-2xl mb-4">Page Not Found</p>
<RouterLink to="/" class="text-blue-500 hover:underline">
Go back to Home
</RouterLink>
</div>
</template>

<script>
import { RouterLink } from "vue-router";
export default {
name: "NotFound",
};
</script>

<style scoped>
@keyframes float {
0% {
transform: translatey(0px);
}
50% {
transform: translatey(-20px);
}
100% {
transform: translatey(0px);
}
}
.pi-exclamation-triangle {
animation: float 3s ease-in-out infinite;
}
h1 {
animation: float 3s ease-in-out infinite;
animation-delay: 0.5s;
}
p {
animation: float 3s ease-in-out infinite;
animation-delay: 1s;
}
</style>
13 changes: 13 additions & 0 deletions src/views/HomeView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup>
import Hero from "@/components/Hero.vue";
import HomeCards from "@/components/HomeCards.vue";
import JobListings from "@/components/JobListings.vue";
</script>
<template>
<Hero
title="Become a Vue Dev!"
subtitle="Find the Vue job that fits your skills and needs"
/>
<HomeCards />
<JobListings :limit="3" :showButton="true" />
</template>
86 changes: 86 additions & 0 deletions src/views/JobView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<script setup></script>
<template>
<section class="bg-green-50">
<div class="container m-auto py-10 px-6">
<div class="grid grid-cols-1 md:grid-cols-70/30 w-full gap-6">
<main>
<div
class="bg-white p-6 rounded-lg shadow-md text-center md:text-left"
>
<div class="text-gray-500 mb-4">Full-Time</div>
<h1 class="text-3xl font-bold mb-4">Senior Vue Developer</h1>
<div
class="text-gray-500 mb-4 flex align-middle justify-center md:justify-start"
>
<i
class="fa-solid fa-location-dot text-lg text-orange-700 mr-2"
></i>
<p class="text-orange-700">Boston, MA</p>
</div>
</div>

<div class="bg-white p-6 rounded-lg shadow-md mt-6">
<h3 class="text-green-800 text-lg font-bold mb-6">
Job Description
</h3>

<p class="mb-4">
We are seeking a talented Front-End Developer to join our team in
Boston, MA. The ideal candidate will have strong skills in HTML,
CSS, and JavaScript, with experience working with modern
JavaScript frameworks such as Vue or Angular.
</p>

<h3 class="text-green-800 text-lg font-bold mb-2">Salary</h3>

<p class="mb-4">$70k - $80K / Year</p>
</div>
</main>

<!-- Sidebar -->
<aside>
<!-- Company Info -->
<div class="bg-white p-6 rounded-lg shadow-md">
<h3 class="text-xl font-bold mb-6">Company Info</h3>

<h2 class="text-2xl">NewTek Solutions</h2>

<p class="my-2">
NewTek Solutions is a leading technology company specializing in
web development and digital solutions. We pride ourselves on
delivering high-quality products and services to our clients while
fostering a collaborative and innovative work environment.
</p>

<hr class="my-4" />

<h3 class="text-xl">Contact Email:</h3>

<p class="my-2 bg-green-100 p-2 font-bold">
contact@newteksolutions.com
</p>

<h3 class="text-xl">Contact Phone:</h3>

<p class="my-2 bg-green-100 p-2 font-bold">555-555-5555</p>
</div>

<!-- Manage -->
<div class="bg-white p-6 rounded-lg shadow-md mt-6">
<h3 class="text-xl font-bold mb-6">Manage Job</h3>
<a
href="add-job.html"
class="bg-green-500 hover:bg-green-600 text-white text-center font-bold py-2 px-4 rounded-full w-full focus:outline-none focus:shadow-outline mt-4 block"
>Edit Job</a
>
<button
class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded-full w-full focus:outline-none focus:shadow-outline mt-4 block"
>
Delete Job
</button>
</div>
</aside>
</div>
</div>
</section>
</template>
Loading

0 comments on commit aa421a7

Please sign in to comment.