feat: Add new Avatar component (#10280)
**Screenshot from story** **Light** <img width="949" alt="image" src="https://github.com/user-attachments/assets/b4a61e64-7c1d-408a-9009-13fa1ad43b67"> **Dark** <img width="949" alt="image" src="https://github.com/user-attachments/assets/21496540-aea5-4ca6-a92d-e7935b5e03d1">
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup>
|
||||||
|
import Avatar from './Avatar.vue';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Story title="Components/Avatar" :layout="{ type: 'grid', width: '400' }">
|
||||||
|
<Variant title="Default">
|
||||||
|
<div class="p-4 bg-white dark:bg-slate-900">
|
||||||
|
<Avatar
|
||||||
|
src="https://api.dicebear.com/9.x/avataaars/svg?seed=Amaya"
|
||||||
|
class="bg-ruby-300 dark:bg-ruby-900"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Variant>
|
||||||
|
|
||||||
|
<Variant title="Different Sizes">
|
||||||
|
<div class="flex flex-wrap gap-4 p-4 bg-white dark:bg-slate-900">
|
||||||
|
<Avatar
|
||||||
|
src="https://api.dicebear.com/9.x/avataaars/svg?seed=Felix"
|
||||||
|
:size="48"
|
||||||
|
class="bg-green-300 dark:bg-green-900"
|
||||||
|
/>
|
||||||
|
<Avatar
|
||||||
|
:size="72"
|
||||||
|
src="https://api.dicebear.com/9.x/avataaars/svg?seed=Jade"
|
||||||
|
class="bg-indigo-300 dark:bg-indigo-900"
|
||||||
|
/>
|
||||||
|
<Avatar
|
||||||
|
src="https://api.dicebear.com/9.x/avataaars/svg?seed=Emery"
|
||||||
|
:size="96"
|
||||||
|
class="bg-woot-300 dark:bg-woot-900"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Variant>
|
||||||
|
</Story>
|
||||||
|
</template>
|
||||||
52
app/javascript/dashboard/components-next/avatar/Avatar.vue
Normal file
52
app/javascript/dashboard/components-next/avatar/Avatar.vue
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import FluentIcon from 'shared/components/FluentIcon/DashboardIcon.vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
src: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
type: Number,
|
||||||
|
default: 72,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['upload']);
|
||||||
|
|
||||||
|
const avatarSize = computed(() => `${props.size}px`);
|
||||||
|
const iconSize = computed(() => `${props.size / 2}px`);
|
||||||
|
|
||||||
|
const handleUploadAvatar = () => {
|
||||||
|
emit('upload');
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="relative flex flex-col items-center gap-2 select-none rounded-xl group/avatar"
|
||||||
|
:style="{
|
||||||
|
width: avatarSize,
|
||||||
|
height: avatarSize,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="src"
|
||||||
|
:src="props.src"
|
||||||
|
alt="avatar"
|
||||||
|
class="w-full h-full shadow-sm rounded-xl"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="absolute inset-0 flex items-center justify-center invisible w-full h-full transition-all duration-500 ease-in-out opacity-0 rounded-xl dark:bg-slate-900/50 bg-slate-900/20 group-hover/avatar:visible group-hover/avatar:opacity-100"
|
||||||
|
@click="handleUploadAvatar"
|
||||||
|
>
|
||||||
|
<FluentIcon
|
||||||
|
icon="upload-lucide"
|
||||||
|
icon-lib="lucide"
|
||||||
|
:size="iconSize"
|
||||||
|
class="text-white dark:text-white"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -287,6 +287,7 @@
|
|||||||
],
|
],
|
||||||
"scan-person-outline": "M5.25 3.5A1.75 1.75 0 0 0 3.5 5.25v3a.75.75 0 0 1-1.5 0v-3A3.25 3.25 0 0 1 5.25 2h3a.75.75 0 0 1 0 1.5zm0 17a1.75 1.75 0 0 1-1.75-1.75v-3a.75.75 0 0 0-1.5 0v3A3.25 3.25 0 0 0 5.25 22h3a.75.75 0 0 0 .707-1l-.005-.015a.75.75 0 0 0-.702-.485zM20.5 5.25a1.75 1.75 0 0 0-1.75-1.75h-3a.75.75 0 0 1 0-1.5h3A3.25 3.25 0 0 1 22 5.25v3a.75.75 0 0 1-1.5 0zM18.75 20.5a1.75 1.75 0 0 0 1.75-1.75v-3a.75.75 0 0 1 1.5 0v3A3.25 3.25 0 0 1 18.75 22h-3a.75.75 0 0 1 0-1.5zM6.5 18.616q0 .465.258.884H5.25a1 1 0 0 1-.129-.011A3.1 3.1 0 0 1 5 18.616v-.366A2.25 2.25 0 0 1 7.25 16h9.5A2.25 2.25 0 0 1 19 18.25v.366c0 .31-.047.601-.132.875a1 1 0 0 1-.118.009h-1.543a1.56 1.56 0 0 0 .293-.884v-.366a.75.75 0 0 0-.75-.75h-9.5a.75.75 0 0 0-.75.75zm8.25-8.866a2.75 2.75 0 1 0-5.5 0a2.75 2.75 0 0 0 5.5 0m1.5 0a4.25 4.25 0 1 1-8.5 0a4.25 4.25 0 0 1 8.5 0",
|
"scan-person-outline": "M5.25 3.5A1.75 1.75 0 0 0 3.5 5.25v3a.75.75 0 0 1-1.5 0v-3A3.25 3.25 0 0 1 5.25 2h3a.75.75 0 0 1 0 1.5zm0 17a1.75 1.75 0 0 1-1.75-1.75v-3a.75.75 0 0 0-1.5 0v3A3.25 3.25 0 0 0 5.25 22h3a.75.75 0 0 0 .707-1l-.005-.015a.75.75 0 0 0-.702-.485zM20.5 5.25a1.75 1.75 0 0 0-1.75-1.75h-3a.75.75 0 0 1 0-1.5h3A3.25 3.25 0 0 1 22 5.25v3a.75.75 0 0 1-1.5 0zM18.75 20.5a1.75 1.75 0 0 0 1.75-1.75v-3a.75.75 0 0 1 1.5 0v3A3.25 3.25 0 0 1 18.75 22h-3a.75.75 0 0 1 0-1.5zM6.5 18.616q0 .465.258.884H5.25a1 1 0 0 1-.129-.011A3.1 3.1 0 0 1 5 18.616v-.366A2.25 2.25 0 0 1 7.25 16h9.5A2.25 2.25 0 0 1 19 18.25v.366c0 .31-.047.601-.132.875a1 1 0 0 1-.118.009h-1.543a1.56 1.56 0 0 0 .293-.884v-.366a.75.75 0 0 0-.75-.75h-9.5a.75.75 0 0 0-.75.75zm8.25-8.866a2.75 2.75 0 1 0-5.5 0a2.75 2.75 0 0 0 5.5 0m1.5 0a4.25 4.25 0 1 1-8.5 0a4.25 4.25 0 0 1 8.5 0",
|
||||||
|
|
||||||
|
"upload-lucide-outline": "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4m14-7l-5-5l-5 5m5-5v12",
|
||||||
"chevrons-lucide-left-outline": "m11 17l-5-5l5-5m7 10l-5-5l5-5",
|
"chevrons-lucide-left-outline": "m11 17l-5-5l5-5m7 10l-5-5l5-5",
|
||||||
"chevrons-lucide-right-outline": "m6 17l5-5l-5-5m7 10l5-5l-5-5",
|
"chevrons-lucide-right-outline": "m6 17l5-5l-5-5m7 10l5-5l-5-5",
|
||||||
"chevron-lucide-left-outline": "m15 18l-6-6l6-6",
|
"chevron-lucide-left-outline": "m15 18l-6-6l6-6",
|
||||||
|
|||||||
Reference in New Issue
Block a user