mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
4.7 KiB
131 lines
4.7 KiB
2 years ago
|
<script lang="ts" setup>
|
||
|
import type { ProjectType } from 'nocodb-sdk'
|
||
|
import { navigateTo } from '#app'
|
||
2 years ago
|
import { useColors } from '#imports'
|
||
2 years ago
|
import MdiMenuDown from '~icons/mdi/menu-down'
|
||
|
import MdiDeleteOutline from '~icons/mdi/delete-outline'
|
||
|
import MdiPlus from '~icons/mdi/plus'
|
||
|
import MdiDatabaseOutline from '~icons/mdi/database-outline'
|
||
2 years ago
|
import MdiEditOutline from '~icons/mdi/edit-outline'
|
||
2 years ago
|
|
||
|
interface Props {
|
||
2 years ago
|
projects?: ProjectType[]
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
const { projects = [] } = defineProps<Props>()
|
||
2 years ago
|
|
||
2 years ago
|
const emit = defineEmits(['delete-project'])
|
||
|
|
||
2 years ago
|
const { $e } = useNuxtApp()
|
||
|
|
||
2 years ago
|
const { getColorByIndex } = useColors(true)
|
||
2 years ago
|
|
||
|
const openProject = async (project: ProjectType) => {
|
||
|
await navigateTo(`/nc/${project.id}`)
|
||
|
$e('a:project:open', { count: projects.length })
|
||
|
}
|
||
|
|
||
|
const formatTitle = (title: string) =>
|
||
|
title
|
||
|
.split(' ')
|
||
|
.map((w) => w[0])
|
||
|
.slice(0, 2)
|
||
|
.join('')
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 3xl:grid-cols-8 gap-6 md:(gap-y-16)">
|
||
2 years ago
|
<div class="group flex flex-col items-center gap-2">
|
||
|
<v-menu>
|
||
|
<template #activator="{ props }">
|
||
|
<div
|
||
2 years ago
|
class="thumbnail hover:(after:!opacity-100 shadow-lg to-primary/50)"
|
||
|
:style="{ '--thumbnail-color': '#1348ba' }"
|
||
2 years ago
|
@click="props.onClick"
|
||
|
>
|
||
|
<MdiPlus />
|
||
|
</div>
|
||
|
<div class="prose-lg font-semibold">
|
||
|
{{ $t('title.newProj') }}
|
||
|
</div>
|
||
|
</template>
|
||
|
<v-list class="!py-0 flex flex-col bg-white rounded-lg shadow-md border-1 border-gray-300 mt-2 ml-2">
|
||
2 years ago
|
<div
|
||
|
class="grid grid-cols-12 cursor-pointer hover:bg-gray-200 flex items-center p-2"
|
||
2 years ago
|
@click="navigateTo('/project/create')"
|
||
2 years ago
|
>
|
||
2 years ago
|
<MdiPlus class="col-span-2 mr-1 mt-[1px] text-primary text-lg" />
|
||
|
<div class="col-span-10 text-sm xl:text-md">{{ $t('activity.createProject') }}</div>
|
||
|
</div>
|
||
|
<div
|
||
|
class="grid grid-cols-12 cursor-pointer hover:bg-gray-200 flex items-center p-2"
|
||
2 years ago
|
@click="navigateTo('/project/create-external')"
|
||
2 years ago
|
>
|
||
|
<MdiDatabaseOutline class="col-span-2 mr-1 mt-[1px] text-green-500 text-lg" />
|
||
|
<div class="col-span-10 text-sm xl:text-md" v-html="$t('activity.createProjectExtended.extDB')" />
|
||
|
</div>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
|
||
|
<div v-for="(project, i) of projects" :key="project.id" class="group flex flex-col items-center gap-2">
|
||
2 years ago
|
<div class="thumbnail" :style="{ '--thumbnail-color': getColorByIndex(i) }" @click="openProject(project)">
|
||
2 years ago
|
{{ formatTitle(project.title) }}
|
||
2 years ago
|
<a-dropdown @click.stop>
|
||
|
<MdiMenuDown class="menu-icon" />
|
||
|
<template #overlay>
|
||
2 years ago
|
<a-menu>
|
||
|
<a-menu-item @click.stop="emit('delete-project', project)">
|
||
|
<div class="grid grid-cols-6 cursor-pointer flex items-center p-2">
|
||
|
<MdiDeleteOutline class="col-span-2 mr-1 mt-[1px] text-red text-lg" />
|
||
|
<div class="col-span-4 text-sm xl:text-md">{{ $t('general.delete') }}</div>
|
||
|
</div>
|
||
|
</a-menu-item>
|
||
2 years ago
|
<a-menu-item @click.stop="navigateTo(`/project/${project.id}`)">
|
||
2 years ago
|
<div class="grid grid-cols-6 cursor-pointer flex items-center p-2">
|
||
|
<MdiEditOutline class="col-span-2 mr-1 mt-[1px] text-primary text-lg" />
|
||
|
<div class="col-span-4 text-sm xl:text-md">{{ $t('general.edit') }}</div>
|
||
|
</div>
|
||
|
</a-menu-item>
|
||
|
</a-menu>
|
||
2 years ago
|
</template>
|
||
|
</a-dropdown>
|
||
2 years ago
|
</div>
|
||
|
|
||
2 years ago
|
<div class="prose-lg font-semibold overflow-ellipsis w-full overflow-hidden text-center capitalize">
|
||
2 years ago
|
{{ project.title || 'Untitled' }}
|
||
|
</div>
|
||
|
</div>
|
||
2 years ago
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<style scoped>
|
||
2 years ago
|
.thumbnail {
|
||
2 years ago
|
@apply relative rounded-md opacity-75 font-bold text-white text-[75px] h-[100px] w-full w-[100px] shadow-md cursor-pointer uppercase flex items-center justify-center color-transition hover:(after:opacity-100 shadow-none);
|
||
2 years ago
|
}
|
||
|
|
||
|
.thumbnail::after {
|
||
|
@apply rounded-md absolute top-0 left-0 right-0 bottom-0 transition-all duration-150 ease-in-out opacity-75;
|
||
|
background-color: var(--thumbnail-color);
|
||
|
content: '';
|
||
|
z-index: -1;
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
.thumbnail:hover::after {
|
||
|
@apply shadow-2xl transform scale-110;
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
.menu-icon,
|
||
|
.star-icon {
|
||
2 years ago
|
@apply w-auto opacity-0 absolute h-[1.75rem] transition-opacity !duration-200 group-hover:opacity-100;
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
.star-icon {
|
||
2 years ago
|
@apply top-1 right-1 transform hover:(scale-120 text-yellow-300/75) transition-all duration-100 ease;
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
.menu-icon {
|
||
2 years ago
|
@apply bottom-1 right-1 transform hover:(scale-150 text-gray-200) transition-all duration-100 ease;
|
||
2 years ago
|
}
|
||
|
</style>
|