Skip to content

Commit 7d6a239

Browse files
committed
Pass dummy data to dashboard component, vue rendering logic based on the data (Unlocked, level selected)
1 parent ff65c4c commit 7d6a239

File tree

4 files changed

+67
-50
lines changed

4 files changed

+67
-50
lines changed

resources/js/Components/LessonCard.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,13 @@ defineProps(["title", "description", "image"]);
1212
<div class="pl-12 pt-8 w-1/2">
1313
<img
1414
class="border-black border-2 "
15-
src="/images/placeholder.png"
15+
:src="image"
16+
:alt="image"
1617
/>
1718
</div>
1819
<div class="pt-8 w-1/2">
1920
<p class="">
20-
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
21-
Pellentesque elementum erat vitae lorem condimentum, a
22-
rutrum tellus molestie. Proin tincidunt eros sit amet
23-
posuere dapibus. Maecenas fermentum et eros imperdiet
24-
tempor. Sed vestibulum ex leo, ut ultrices tortor cursus
25-
non.
21+
{{description}}
2622
</p>
2723
</div>
2824
</div>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<script>
2+
export default {
3+
props: ['selected', 'unlocked'],
4+
methods: {
5+
}
6+
}
7+
</script>
8+
9+
<template>
10+
<div v-if="selected"
11+
class="bg-green-400 w-32 h-32 m-10 border-2 border-black"
12+
v-on:click="updateIsSelected"
13+
>
14+
<img src="/images/placeholder_2.png"/>
15+
</div>
16+
<div v-else
17+
class="bg-green-400 w-32 h-32 m-10 border-2 border-green"
18+
>
19+
<img src="/images/placeholder_2.png"/>
20+
</div>
21+
</template>

resources/js/Pages/Dashboard.vue

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
1-
<script setup>
2-
import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout.vue";
3-
import { Head } from "@inertiajs/inertia-vue3";
4-
import LessonCard from "@/Components/LessonCard.vue";
5-
6-
// NOTE:
7-
/*
8-
Lesson data will be loaded and passed through to the grid component
9-
When the component is interacted with, the component will handle its own
10-
interaction event, but here another event will be made and it will
11-
change current lesson data
12-
*/
13-
14-
// Current lesson data
15-
defineProps(["curTitle", "curDesc", "curImage"]);
16-
1+
<script>
2+
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue';
3+
import LessonCard from '@/Components/LessonCard.vue';
4+
import LessonItem from '@/Components/LessonItem.vue';
5+
export default {
6+
components: { AuthenticatedLayout, LessonCard, LessonItem },
7+
props: ['lessonData'],
8+
data() {
9+
return {
10+
'title': 'Default title',
11+
'desc': 'Default description',
12+
'img': '/images/placeholder.png',
13+
'prevSelected': 0
14+
}
15+
},created() {
16+
this.changeLessonCard(0);
17+
}, methods: {
18+
changeLessonCard: function(index) {
19+
this.lessonData[this.prevSelected].selected=false;
20+
this.prevSelected = index;
21+
this.lessonData[index].selected=true;
22+
this.title = this.lessonData[index].title;
23+
this.desc = this.lessonData[index].desc;
24+
this.img = this.lessonData[index].src;
25+
}
26+
}
27+
}
1728
</script>
1829

1930
<template>
@@ -22,30 +33,16 @@ defineProps(["curTitle", "curDesc", "curImage"]);
2233
<AuthenticatedLayout>
2334
<div class="flex justify-center mt-10">
2435
<LessonCard
25-
:title="curTitle"
26-
:description="curDesc"
27-
:image="curImage"
36+
:title="title"
37+
:description="desc"
38+
:image="img"
2839
/>
29-
<div class="flex">
40+
</div>
41+
<div class="flex justify-center">
42+
<div v-for="(lesson, index) in lessonData"
43+
class="">
44+
<LessonItem :title="lesson.title" :unlocked="lesson.unlocked" :selected="lesson.selected" v-on:click="changeLessonCard(index)"/>
3045
</div>
3146
</div>
3247
</AuthenticatedLayout>
3348
</template>
34-
35-
<!-- <template #header>
36-
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
37-
Dashboard
38-
</h2>
39-
</template>
40-
41-
<h2> SOmein</h2>
42-
43-
<div class="py-12">
44-
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
45-
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
46-
<div class="p-6 bg-white border-b border-gray-200">
47-
You're logged in!
48-
</div>
49-
</div>
50-
</div>
51-
</div> -->

routes/web.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@
2424
]);
2525
});
2626

27-
// Rotue::get('/dashboard', function () {
28-
// return Inertia::render('Dash')
29-
// });
30-
3127
Route::get('/dashboard', function () {
32-
return Inertia::render('Dashboard');
28+
$data = [
29+
['title'=>'Lesson - 1', 'desc'=>'Lesson 1 desc', 'src'=>'/images/placeholder.png', 'selected'=>false, 'unlocked'=>true],
30+
['title'=>'Lesson - 2', 'desc'=>'Lesson 2 desc', 'src'=>'/images/placeholder.png', 'selected'=>false, 'unlocked'=>false],
31+
['title'=>'Lesson - 3', 'desc'=>'Lesson 3 desc', 'src'=>'/images/placeholder.png', 'selected'=>false, 'unlocked'=>false]
32+
];
33+
return Inertia('Dashboard', [
34+
'lessonData' => $data
35+
]);
3336
})->middleware(['auth', 'verified'])->name('dashboard');
3437

3538
require __DIR__.'/auth.php';

0 commit comments

Comments
 (0)