Add Modal and Table components: implement modal functionality and table structure with props
This commit is contained in:
1 parent
cb0c87a4ca
commit
111a3cc677
2 files changed
+82
No files matched your search
@@ -0,0 +1,40 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const open = defineModel("open")
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Transition>
|
||||||
|
<div class="modal-container" v-show="open" @click="open = false">
|
||||||
|
<Card @click.stop>
|
||||||
|
<slot />
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.modal-container {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 10;
|
||||||
|
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-enter-active,
|
||||||
|
.v-leave-active {
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-enter-from,
|
||||||
|
.v-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
export type Row = {
|
||||||
|
name: string
|
||||||
|
class?: string
|
||||||
|
width?: string
|
||||||
|
type?: "image"
|
||||||
|
displayName?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type TableProps = {
|
||||||
|
rows: Row[]
|
||||||
|
data: any
|
||||||
|
}
|
||||||
|
|
||||||
|
const { rows, data } = defineProps<TableProps>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th
|
||||||
|
v-for="row in rows"
|
||||||
|
:key="row.name"
|
||||||
|
:class="row.class"
|
||||||
|
:style="{ width: row.width }"
|
||||||
|
>
|
||||||
|
{{ row.displayName || row.name }}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(item, i) in data" :key="i">
|
||||||
|
<td v-for="(row, j) in rows" :key="j">
|
||||||
|
<slot :name="row.name" :item="item" :index="i">
|
||||||
|
<p v-if="row.type != 'image'">{{ item[row.name] }}</p>
|
||||||
|
</slot>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</template>
|
||||||
Reference in new issue
Block a user