Move toju-app into own its folder
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { NgOptimizedImage } from '@angular/common';
|
||||
import { Component, input } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-avatar',
|
||||
standalone: true,
|
||||
imports: [NgOptimizedImage],
|
||||
templateUrl: './user-avatar.component.html',
|
||||
host: {
|
||||
style: 'display: contents;'
|
||||
}
|
||||
})
|
||||
export class UserAvatarComponent {
|
||||
name = input.required<string>();
|
||||
avatarUrl = input<string | undefined | null>();
|
||||
size = input<'xs' | 'sm' | 'md' | 'lg'>('sm');
|
||||
ringClass = input<string>('');
|
||||
|
||||
initial(): string {
|
||||
return this.name()?.charAt(0)
|
||||
?.toUpperCase() ?? '?';
|
||||
}
|
||||
|
||||
sizeClasses(): string {
|
||||
switch (this.size()) {
|
||||
case 'xs': return 'w-7 h-7';
|
||||
case 'sm': return 'w-8 h-8';
|
||||
case 'md': return 'w-10 h-10';
|
||||
case 'lg': return 'w-12 h-12';
|
||||
}
|
||||
}
|
||||
|
||||
sizePx(): number {
|
||||
switch (this.size()) {
|
||||
case 'xs': return 28;
|
||||
case 'sm': return 32;
|
||||
case 'md': return 40;
|
||||
case 'lg': return 48;
|
||||
}
|
||||
}
|
||||
|
||||
textClass(): string {
|
||||
switch (this.size()) {
|
||||
case 'xs': return 'text-xs';
|
||||
case 'sm': return 'text-sm';
|
||||
case 'md': return 'text-base font-semibold';
|
||||
case 'lg': return 'text-lg font-semibold';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user