feat: add Avatar component and integrate into index page

This commit is contained in:
2026-06-16 08:30:29 +02:00
parent b61720fd24
commit 7c65e70c8f
4 changed files with 60 additions and 7 deletions
+21
View File
@@ -0,0 +1,21 @@
@use '../../styles/tokens/typography' as *;
.avatar {
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
overflow: hidden;
width: 40px;
height: 40px;
&__content {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
@include text-base;
color: var(--nds-color-on-primary);
background-color: var(--nds-disabled);
}
}
+31
View File
@@ -0,0 +1,31 @@
---
import { ProfileIcon } from '../Icons';
export interface Props {
type: 'photo' | 'initials';
name: string;
image?: string;
}
const { type, name, image } = Astro.props;
---
<div class={`avatar`}>
{type === 'photo' && image ? (
<div class="avatar__content avatar__content--photo">
<img
src={image}
alt={name}
class="avatar__content"
onerror="this.style.display='none'; this.nextElementSibling.style.display='flex';"
/>
<span class="avatar__fallback" style="display:none;">
<ProfileIcon size={24}/>
</span>
</div>
) : (
<span class="avatar__content">{name.split(' ').map(word => word[0]).join('').toUpperCase()}</span>
)}
</div>
<style lang="scss">
@use './_avatar.scss';
</style>