Created
August 13, 2021 11:53
-
-
Save dietergoetelen/9c16d7b5cdba73beaf2d6b9c983d5ccf to your computer and use it in GitHub Desktop.
Content placeholder component in #vue3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="content-placeholder gap-1 animate-pulse"> | |
<div v-for="template of templates" :key="template" class="bg-gray-300" :style="{gridArea: template}" /> | |
</div> | |
</template> | |
<script lang="ts" setup> | |
const props = defineProps<{ | |
template: Array<Array<string>> | |
rows: string | |
columns: string | |
}>() | |
const cssGridTemplate = computed(() => props.template.map(template => `"${template.join(' ')}"`).join('\n')) | |
const templates = computed(() => Array.from(new Set(props.template.flat()))) | |
const rows = computed(() => props.rows) | |
const columns = computed(() => props.columns) | |
</script> | |
<style scoped> | |
.content-placeholder { | |
display: grid; | |
grid-template-areas: v-bind(cssGridTemplate); | |
grid-template-columns: v-bind(columns); | |
grid-template-rows: v-bind(rows); | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment