skillbox/client/src/components/modules/ModuleTeaser.vue

111 lines
2.1 KiB
Vue

<template>
<router-link
:to="moduleLink"
:class="['module-teaser', { 'module-teaser--small': !teaser }]"
>
<div
:style="{ backgroundImage: 'url(' + heroImage + ')' }"
class="module-teaser__image"
/>
<div class="module-teaser__body">
<h3 class="module-teaser__meta-title">{{ metaTitle }}</h3>
<h3 class="module-teaser__title">
{{ title }}
</h3>
<p class="module-teaser__description">
{{ teaser }}
</p>
<div class="module-teaser__pills" v-if="$flavor.showModuleFilter">
<pill :text="level?.name"></pill>
<pill :text="category?.name"></pill>
</div>
</div>
</router-link>
</template>
<script setup lang="ts">
import Pill from '@/components/ui/Pill.vue';
import { ModuleCategoryNode, ModuleLevelNode } from '@/__generated__/graphql';
import { computed } from '@vue/reactivity';
export interface Props {
metaTitle: string;
title: string;
teaser: string;
id: string;
slug: string;
heroImage: string;
level: ModuleLevelNode;
category: ModuleCategoryNode;
language: string;
}
const props = defineProps<Props>();
const moduleLink = computed(() => {
if (props.slug) {
return {
name: 'module',
params: {
slug: props.slug,
},
};
} else {
return {};
}
});
</script>
<style scoped lang="scss">
@import 'styles/helpers';
.module-teaser {
box-shadow: 0 3px 9px 0 rgba(0, 0, 0, 0.12);
border: 1px solid #e2e2e2;
height: 390px;
max-width: 380px;
width: 100%;
border-radius: 12px;
overflow: hidden;
box-sizing: border-box;
cursor: pointer;
&--small {
height: 300px;
}
&__image {
width: 100%;
max-height: 150px;
height: 150px;
background-position: center;
background-size: 100% auto;
background-repeat: no-repeat;
}
&__body {
padding: 20px;
}
&__meta-title {
color: $color-silver-dark;
margin-bottom: $large-spacing;
@include regular-text;
}
&__title {
@include heading-3;
margin-bottom: 5px;
}
&__description {
line-height: $default-line-height;
font-size: 1.2rem;
}
&__pills {
margin-top: $medium-spacing;
}
}
</style>