|
| 1 | +<template> |
| 2 | + <div class="mt-16 custom-block"> |
| 3 | + <div class="relative grid grid-cols-12 gap-8"> |
| 4 | + <RouterLink |
| 5 | + v-for="componentName in components" |
| 6 | + :key="componentName" |
| 7 | + class="col-span-12 overflow-hidden transition-all border rounded-lg hover:-translate-y-1 hover:shadow-md md:col-span-6 lg:col-span-4 hover:border-black dark:hover:border-white dark:border-zinc-700" |
| 8 | + :to="generateComponentPath(framework, componentName, type)" |
| 9 | + > |
| 10 | + <div v-if="!hideThumbnail" class="flex items-center justify-center w-full bg-gray-100"> |
| 11 | + <img |
| 12 | + :src="$withBase(`/thumbnails/${type}/${componentName.replace('Sf', '')}.png`)" |
| 13 | + class="object-cover w-full h-full" |
| 14 | + :alt="componentName" |
| 15 | + /> |
| 16 | + </div> |
| 17 | + <div class="p-4"> |
| 18 | + <h4 class="font-bold">{{ componentName.replace('Sf', '') }}</h4> |
| 19 | + <p v-if="type === 'blocks'" class="mt-2 text-sm">{{ blockCount(componentName) }} blocks</p> |
| 20 | + <p v-if="!hideDescription" class="mt-2 text-sm">{{ componentDescription(componentName) }}</p> |
| 21 | + </div> |
| 22 | + </RouterLink> |
| 23 | + <template v-if="type === 'blocks'"> |
| 24 | + <div |
| 25 | + v-for="componentName in futureBlocks" |
| 26 | + :key="componentName" |
| 27 | + class="col-span-12 overflow-hidden transition-all border rounded-lg opacity-60 md:col-span-6 lg:col-span-4 dark:border-zinc-700" |
| 28 | + > |
| 29 | + <div v-if="!hideThumbnail" class="flex items-center justify-center w-full bg-gray-100"> |
| 30 | + <img |
| 31 | + :src="$withBase(`/thumbnails/${type}/${componentName.replace('Sf', '')}.png`)" |
| 32 | + class="object-cover w-full h-full" |
| 33 | + :alt="componentName" |
| 34 | + /> |
| 35 | + </div> |
| 36 | + <div class="p-4"> |
| 37 | + <h4 class="font-bold">{{ componentName.replace('Sf', '') }}</h4> |
| 38 | + <p class="mt-2 text-sm">Coming Soon</p> |
| 39 | + </div> |
| 40 | + </div> |
| 41 | + </template> |
| 42 | + </div> |
| 43 | + </div> |
| 44 | +</template> |
| 45 | + |
| 46 | +<script> |
| 47 | +import components from '../../utils/components.json'; |
| 48 | +import blocks from '../../utils/blocks.json'; |
| 49 | +import futureBlocks from '../../utils/future-blocks.json'; |
| 50 | +import hooks from '../../utils/hooks.json'; |
| 51 | +import { generateComponentPath } from '../utils/path.util'; |
| 52 | +
|
| 53 | +export default { |
| 54 | + props: { |
| 55 | + framework: { |
| 56 | + type: String, |
| 57 | + required: true, |
| 58 | + }, |
| 59 | + type: { |
| 60 | + type: String, |
| 61 | + default: 'components', |
| 62 | + }, |
| 63 | + hideThumbnail: { |
| 64 | + type: Boolean, |
| 65 | + default: false, |
| 66 | + }, |
| 67 | + hideDescription: { |
| 68 | + type: Boolean, |
| 69 | + default: false, |
| 70 | + }, |
| 71 | + }, |
| 72 | + computed: { |
| 73 | + components() { |
| 74 | + const files = this.type === 'blocks' ? blocks : this.type === 'hooks' ? hooks : components; |
| 75 | + const list = this.framework === 'react' ? files.react : files.vue; |
| 76 | + return list; |
| 77 | + }, |
| 78 | + }, |
| 79 | + methods: { |
| 80 | + componentDescription(componentName) { |
| 81 | + const componentPath = `/${this.framework}/${this.type}/${componentName.replace('Sf', '').toLowerCase()}.html`; |
| 82 | +
|
| 83 | + return this.$site.pages.find((page) => page.path.toLowerCase() === componentPath)?.frontmatter?.description; |
| 84 | + }, |
| 85 | + blockCount(componentName) { |
| 86 | + const componentPath = `/${this.framework}/${this.type}/${componentName.replace('Sf', '').toLowerCase()}.html`; |
| 87 | +
|
| 88 | + return this.$site.pages.find((page) => page.path.toLowerCase() === componentPath)?.frontmatter?.blockCount; |
| 89 | + }, |
| 90 | + }, |
| 91 | + data() { |
| 92 | + return { generateComponentPath, futureBlocks }; |
| 93 | + }, |
| 94 | +}; |
| 95 | +</script> |
0 commit comments