avatars, Inter font added

This commit is contained in:
svensken 2022-11-03 03:01:39 +03:00
parent 500a56e429
commit 4d26d2dec6
5 changed files with 36 additions and 21 deletions

View File

@ -1 +1 @@
{{shortUsername}} <span>{{shortUsername}}</span>

View File

@ -3,22 +3,30 @@
aspect-ratio: 1/1; aspect-ratio: 1/1;
text-transform: uppercase; text-transform: uppercase;
color: #000; color: #000;
display: flex; line-height: var(--local-size, 50px);
justify-content: center; text-align: center;
align-items: center;
width: var(--local-size, 50px); width: var(--local-size, 50px);
font-size: var(--local-size); font-size: calc(var(--local-size, 50px) / 2.5);
border-radius: 50%;
user-select: none;
&[data-size="default"] { span {
--local-size: 50px; display: block;
translate: 0px 1px;
} }
&[data-size="small"] {
--local-size: 50px; &[data-size="large"] {
--local-size: 64px;
} }
&[data-size="medium"] { &[data-size="medium"] {
--local-size: 50px; --local-size: 50px;
} }
&[data-size="large"] { &[data-size="default"] {
--local-size: 50px; --local-size: 42px;
font-weight: 500;
}
&[data-size="small"] {
--local-size: 32px;
font-weight: 600;
} }
} }

View File

@ -8,8 +8,13 @@ import { AvatarSize } from './avatar.interface';
styleUrls: ['./avatar.component.scss'], styleUrls: ['./avatar.component.scss'],
}) })
export class AvatarComponent implements OnInit { export class AvatarComponent implements OnInit {
@Input() username: string = 'username'; @Input()
@Input() size: AvatarSize = 'default'; @HostBinding('title')
username: string = 'username';
@Input()
@HostBinding('attr.data-size')
size: AvatarSize = 'default';
constructor() {} constructor() {}
@ -20,11 +25,6 @@ export class AvatarComponent implements OnInit {
return stringHashToHsl(this.username); return stringHashToHsl(this.username);
} }
@HostBinding('data-size')
get avatarSize() {
return `${this.size}px`;
}
get shortUsername() { get shortUsername() {
let array = this.username.split(' '); let array = this.username.split(' ');
if (array.length >= 2) return array[0].charAt(0) + array[1].charAt(0); if (array.length >= 2) return array[0].charAt(0) + array[1].charAt(0);

View File

@ -33,4 +33,9 @@
<hr> <hr>
<h3>Avatar</h3> <h3>Avatar</h3>
<skirda-avatar></skirda-avatar> <div class="line">
<skirda-avatar size="large" username="Vlad Simonov"></skirda-avatar>
<skirda-avatar size="medium" username="Greg Brzezinski"></skirda-avatar>
<skirda-avatar size="default" username="svensken"></skirda-avatar>
<skirda-avatar size="small" username="cyberdream"></skirda-avatar>
</div>

View File

@ -1,10 +1,12 @@
/* You can add global styles to this file, and also import other style files */ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');
html, body { html, body {
background-color: #222; background-color: #222;
color: #fff; color: #fff;
font-size: 16px; font-size: 16px;
margin: 0; margin: 0;
font-family: var(--font); font-family: var(--font);
line-height: 90%;
} }
button, input, textarea { button, input, textarea {
@ -12,7 +14,7 @@ button, input, textarea {
} }
:root { :root {
--font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
--sk-gap-xs: 0.125rem; --sk-gap-xs: 0.125rem;
--sk-gap-s: 0.25rem; --sk-gap-s: 0.25rem;
--sk-gap-m: 0.5rem; --sk-gap-m: 0.5rem;