magnetar/fe_calckey/frontend/client/src/components/MagAvatars.vue

67 lines
1.5 KiB
Vue

<template>
<div class="defgtij">
<div v-for="user in users" :key="user.id" class="avatar-holder">
<MkAvatar :user="user" class="avatar" />
</div>
</div>
</template>
<script lang="ts" setup>
import { onMounted, ref, watch } from "vue";
import * as os from "@/os";
import { packed, endpoints } from "magnetar-common";
const props = defineProps<{
userIds: string[];
}>();
const users = ref<packed.PackUserBase[]>([]);
onMounted(async () => {
users.value = await os
.magApi(
endpoints.GetManyUsersById,
{
id: props.userIds,
},
{}
)
.then((p) => p.filter((u) => u !== null).map((u) => u!));
watch(
() => props.userIds,
async (userIds) => {
users.value = await os
.magApi(
endpoints.GetManyUsersById,
{
id: userIds,
},
{}
)
.then((p) => p.filter((u) => u !== null).map((u) => u!));
}
);
});
</script>
<style lang="scss">
.defgtij {
padding: 12px;
grid-gap: 12px;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(30px, 40px));
place-content: center;
> .avatar-holder {
aspect-ratio: 1;
> .avatar {
width: 100%;
height: 100%;
aspect-ratio: 1;
}
}
}
</style>