Fixed pulsation in Avatar (#5377)

Signed-off-by: Alexander Platov <alexander.platov@hardcoreeng.com>
This commit is contained in:
Alexander Platov 2024-04-16 23:21:29 +03:00 committed by GitHub
parent 82e1b734de
commit a506c36298
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 5 deletions

View File

@ -603,6 +603,7 @@
.textInput { .textInput {
flex-grow: 1; flex-grow: 1;
gap: 1rem;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: flex-start; align-items: flex-start;

View File

@ -55,19 +55,29 @@
export let icon: Asset | AnySvelteComponent | undefined = undefined export let icon: Asset | AnySvelteComponent | undefined = undefined
export let variant: 'circle' | 'roundedRect' | 'none' = 'roundedRect' export let variant: 'circle' | 'roundedRect' | 'none' = 'roundedRect'
export let borderColor: number | undefined = undefined export let borderColor: number | undefined = undefined
export let standby: boolean = false
export function pulse (): void { export function pulse (): void {
if (element) element.animate(pulsating, { duration: 150, easing: 'ease-in' }) if (element) element.animate(pulsating, { duration: 150, easing: 'ease-out' })
if (standby) {
standbyMode = false
if (timer) clearTimeout(timer)
timer = setTimeout(() => {
standbyMode = true
}, 2000)
}
} }
let url: string[] | undefined let url: string[] | undefined
let avatarProvider: AvatarProvider | undefined let avatarProvider: AvatarProvider | undefined
let color: ColorDefinition | undefined = undefined let color: ColorDefinition | undefined = undefined
let standbyMode: boolean = standby
let timer: any | undefined = undefined
let fontSize: number = 16 let fontSize: number = 16
let element: HTMLElement let element: HTMLElement
const pulsating: Keyframe[] = [ const pulsating: Keyframe[] = [
{ boxShadow: '0 0 .75rem 0 var(--theme-bg-color), 0 0 .75rem .125rem var(--border-color)' }, { boxShadow: '0 0 .125rem 0 var(--theme-bg-color), 0 0 0 .125rem var(--border-color)' },
{ boxShadow: '0 0 0 0 var(--theme-bg-color), 0 0 0 0 var(--border-color)' } { boxShadow: '0 0 .375rem .375rem var(--theme-bg-color), 0 0 0 .25rem var(--border-color)' }
] ]
$: displayName = getDisplayName(name) $: displayName = getDisplayName(name)
@ -135,6 +145,8 @@
class:no-img={!url && color} class:no-img={!url && color}
class:bordered={!url && color === undefined} class:bordered={!url && color === undefined}
class:border={bColor !== undefined} class:border={bColor !== undefined}
class:standby
class:standbyOn={standby && !standbyMode}
style:--border-color={bColor ?? 'var(--primary-button-default)'} style:--border-color={bColor ?? 'var(--primary-button-default)'}
style:background-color={color && !url ? color.icon : 'var(--theme-button-default)'} style:background-color={color && !url ? color.icon : 'var(--theme-button-default)'}
use:resizeObserver={(element) => { use:resizeObserver={(element) => {
@ -155,6 +167,8 @@
class:no-img={!url && color} class:no-img={!url && color}
class:bordered={!url && color === undefined} class:bordered={!url && color === undefined}
class:border={bColor !== undefined} class:border={bColor !== undefined}
class:standby
class:standbyOn={standby && !standbyMode}
style:--border-color={bColor ?? 'var(--primary-button-default)'} style:--border-color={bColor ?? 'var(--primary-button-default)'}
style:background-color={color && !url ? color.icon : 'var(--theme-button-default)'} style:background-color={color && !url ? color.icon : 'var(--theme-button-default)'}
> >
@ -190,6 +204,19 @@
&.roundedRect img.ava-image { &.roundedRect img.ava-image {
border-radius: 20%; border-radius: 20%;
} }
&.standby {
opacity: 0.5;
transition: opacity 0.5s ease-in-out;
pointer-events: all;
&:hover,
&.standbyOn {
opacity: 1;
}
&:hover {
transition-duration: 0.1s;
}
}
&.no-img { &.no-img {
color: var(--primary-button-color); color: var(--primary-button-color);
@ -204,7 +231,9 @@
outline: 2px solid var(--border-color); outline: 2px solid var(--border-color);
&.ava-inline, &.ava-inline,
&.ava-tiny { &.ava-tiny,
&.ava-card,
&.ava-x-small {
outline-width: 1px; outline-width: 1px;
} }
&.ava-large, &.ava-large,

View File

@ -39,5 +39,5 @@
</script> </script>
{#if person} {#if person}
<Avatar bind:this={avatar} {size} avatar={person.avatar} name={person.name} borderColor={user.color} /> <Avatar bind:this={avatar} {size} avatar={person.avatar} name={person.name} borderColor={user.color} standby />
{/if} {/if}