💻 | Working with Composition API and TypeScript

This commit is contained in:
2021-03-21 22:31:52 +01:00
parent c0c04205a0
commit f2d420a87a
3 changed files with 63 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
<div class="mb-3 mr-2 p-1 md:p-2 h-32 w-32 border-gray-900 dark:border-dark-200 border-2 duration-300 rounded-3xl hover:bg-opacity-25" :class="getColor">
<div class="w-full h-full flex flex-col justify-center items-center">
<div>
<img class="rounded-sm" alt="Skill Img" :src="require(`@/assets/img/skills/${cover}.png`)">
<img class="rounded-sm" alt="Skill Img" :src="getCoverLink">
</div>
<h1 class="md:text-lg text-md font-bold text-center">{{ skill }}</h1>
</div>
@@ -36,8 +36,11 @@ export default {
},
setup(props: SkillProp) {
const getColor = computed(() => `hover:bg-${props.color}-400`)
const getCoverLink = computed(() => require(`@/assets/images/skills/${props.cover}.png`))
return {
getColor
getColor,
getCoverLink
}
}
}

View File

@@ -3,7 +3,7 @@
:class="getColor">
<div class="w-full h-full flex flex-col justify-center items-center">
<div class="text-center">
<img alt="Project Img" class="rounded-md" width="150" :src="require(`@/assets/img/works/${cover}.png`)">
<img alt="Project Img" class="rounded-md" width="150" :src="getCoverLink">
</div>
<div class="text-center">
<h1 class="md:text-2xl text-lg font-bold">{{ title }}</h1>
@@ -46,10 +46,12 @@ export default {
setup(props: WorkProp) {
const formatLink = computed(() => props.url.replace('https://', '').replace('http://', ''))
const getColor = computed(() => `hover:bg-${props.color}-600`)
const getCoverLink = computed(() => `@/assets/images/works/${props.cover}.png`)
return {
formatLink,
getColor
getColor,
getCoverLink
}
}
}

View File

@@ -0,0 +1,54 @@
<template>
<div
class="m-2 p-1 md:p-2 h-48 w-48 border-gray-900 dark:border-dark-200 border-2 duration-300 rounded-3xl hover:bg-opacity-25"
:class="getColor"
>
<div class="w-full h-full flex flex-col justify-center items-center">
<div>
<img class="rounded-sm" alt="Skill Img" :src="getCoverLink">
</div>
<h1 class="md:text-xl text-lg font-bold text-center">{{ skill }}</h1>
</div>
</div>
</template>
<script lang="ts">
import { computed } from '@nuxtjs/composition-api'
interface WorkSkillProp {
skill: string,
color: string,
cover: string
}
export default {
name: "WorkSkill",
props: {
skill: {
type: String,
default: "Rien"
},
color: {
type: String,
default: "red-100"
},
cover: {
type: String,
default: "logo.jpg"
}
},
setup(props: WorkSkillProp) {
const getColor = computed(() => `hover:bg-${props.color}-600`)
const getCoverLink = computed(() => require(`@/assets/images/skills/${props.cover}.png`))
return {
getColor,
getCoverLink
}
}
}
</script>
<style scoped>
</style>