Skip to content

Commit cdc8531

Browse files
committed
exercise 1
1 parent 26bebf1 commit cdc8531

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import '@vue/runtime-core'
66
declare module '@vue/runtime-core' {
77
export interface GlobalComponents {
88
AppButton: typeof import('./src/components/AppButton.vue')['default']
9+
AppImage: typeof import('./src/components/AppImage.vue')['default']
10+
BoardCard: typeof import('./src/components/BoardCard.vue')['default']
911
RouterLink: typeof import('vue-router')['RouterLink']
1012
RouterView: typeof import('vue-router')['RouterView']
1113
}

src/components/AppImage.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<img v-bind="$attrs" />
3+
</template>

src/components/BoardCard.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script setup lang="ts">
2+
import {
3+
Card as KCard,
4+
CardTitle as KCardTitle,
5+
} from "@progress/kendo-vue-layout";
6+
import type { Board } from "@/types";
7+
defineProps<{
8+
board: Board;
9+
}>();
10+
const randomColor = "#" + Math.floor(Math.random() * 16777215).toString(16);
11+
</script>
12+
<template>
13+
<router-link :to="`/boards/${board.id}`" class="block w-96">
14+
<KCard class="m-5">
15+
<AppImage
16+
v-if="board.image"
17+
:src="board.image?.downloadUrl"
18+
width="384"
19+
class="aspect-video w-full"
20+
/>
21+
<div
22+
v-else
23+
class="aspect-video w-full"
24+
:style="{ backgroundColor: randomColor }"
25+
></div>
26+
<KCardTitle class="p-2">
27+
<span class="text-gray-700 text-xl">{{ board.title }}</span>
28+
</KCardTitle>
29+
</KCard>
30+
</router-link>
31+
</template>

src/pages/boards/index.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script setup lang="ts">
2+
import type { Board } from "@/types";
3+
import { ref } from "vue";
4+
const boards = ref<Partial<Board>[]>([
5+
{
6+
id: "1",
7+
title: "My First Board",
8+
order: "[]",
9+
image: {
10+
downloadUrl: "https://picsum.photos/480/270?board=1",
11+
},
12+
},
13+
{
14+
id: "2",
15+
title: "My Second Board",
16+
order: "[]",
17+
image: {
18+
downloadUrl: "https://picsum.photos/480/270?board=2",
19+
},
20+
},
21+
{
22+
id: "3",
23+
title: "My Third Board",
24+
order: "[]",
25+
},
26+
]);
27+
</script>
28+
29+
<template>
30+
<h1 class="text-3xl mb-5">Boards</h1>
31+
<div class="flex">
32+
<BoardCard v-for="board in boards" :key="board.id" :board="board" />
33+
<button class="text-gray-500" @click="createBoard(newBoardTemplate)">
34+
<span>New Board +</span>
35+
</button>
36+
</div>
37+
</template>

0 commit comments

Comments
 (0)