2021-08-06 08:31:17 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2020 Anticrm Platform Contributors.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-11-09 17:39:38 +00:00
|
|
|
import Avatar from './icons/Avatar.svelte'
|
2021-08-06 08:31:17 +00:00
|
|
|
|
2021-11-09 17:39:38 +00:00
|
|
|
import { getFileUrl } from '../utils'
|
|
|
|
|
|
|
|
export let avatar: string | undefined = undefined
|
2021-08-17 14:46:06 +00:00
|
|
|
export let size: 'x-small' | 'small' | 'medium' | 'large' | 'x-large'
|
2021-11-09 17:39:38 +00:00
|
|
|
|
2021-11-10 20:10:11 +00:00
|
|
|
$: url = avatar ? getFileUrl(avatar) : undefined
|
2021-08-06 08:31:17 +00:00
|
|
|
</script>
|
|
|
|
|
2021-11-16 16:12:23 +00:00
|
|
|
<div class="ava-{size} flex-center avatar-container" class:no-img={!url}>
|
2021-11-09 17:39:38 +00:00
|
|
|
{#if url}
|
2021-11-10 20:10:11 +00:00
|
|
|
{#if size === 'large' || size === 'x-large'}
|
2021-11-17 13:34:40 +00:00
|
|
|
<img class="ava-{size} ava-blur" src={url} alt={''}/>
|
2021-11-10 20:10:11 +00:00
|
|
|
{/if}
|
2021-11-17 13:34:40 +00:00
|
|
|
<img class="ava-{size} ava-mask" src={url} alt={''}/>
|
2021-11-09 17:39:38 +00:00
|
|
|
{:else}
|
|
|
|
<Avatar {size}/>
|
|
|
|
{/if}
|
2021-08-06 08:31:17 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2021-11-16 16:12:23 +00:00
|
|
|
.avatar-container {
|
2021-11-10 20:10:11 +00:00
|
|
|
flex-shrink: 0;
|
|
|
|
position: relative;
|
|
|
|
overflow: hidden;
|
2021-12-08 09:24:24 +00:00
|
|
|
background-color: rgba(196, 196, 204, .2);
|
2021-11-10 20:10:11 +00:00
|
|
|
border-radius: 50%;
|
|
|
|
pointer-events: none;
|
|
|
|
|
2021-12-08 09:24:24 +00:00
|
|
|
img {
|
|
|
|
object-fit: cover;
|
2021-11-10 20:10:11 +00:00
|
|
|
border: 2px solid var(--theme-avatar-border);
|
|
|
|
}
|
2021-12-08 09:24:24 +00:00
|
|
|
&.no-img { border-color: transparent; }
|
2021-11-10 20:10:11 +00:00
|
|
|
}
|
|
|
|
|
2021-11-16 16:12:23 +00:00
|
|
|
.ava-x-small {
|
2021-11-10 20:10:11 +00:00
|
|
|
width: 1.5rem; // 24
|
2021-08-17 14:46:06 +00:00
|
|
|
height: 1.5rem;
|
|
|
|
}
|
2021-11-16 16:12:23 +00:00
|
|
|
.ava-small {
|
2021-11-10 20:10:11 +00:00
|
|
|
width: 2rem; // 32
|
2021-08-17 14:46:06 +00:00
|
|
|
height: 2rem;
|
|
|
|
}
|
2021-11-16 16:12:23 +00:00
|
|
|
.ava-medium {
|
2021-11-10 20:10:11 +00:00
|
|
|
width: 2.25rem; // 36
|
2021-08-17 14:46:06 +00:00
|
|
|
height: 2.25rem;
|
|
|
|
}
|
2021-11-16 16:12:23 +00:00
|
|
|
.ava-large {
|
2021-11-10 20:10:11 +00:00
|
|
|
width: 4.5rem; // 72
|
|
|
|
height: 4.5rem;
|
2021-08-17 14:46:06 +00:00
|
|
|
}
|
2021-11-16 16:12:23 +00:00
|
|
|
.ava-x-large {
|
2021-11-10 20:10:11 +00:00
|
|
|
width: 7.5rem; // 120
|
|
|
|
height: 7.5rem;
|
2021-08-17 14:46:06 +00:00
|
|
|
}
|
2021-11-10 20:10:11 +00:00
|
|
|
|
2021-11-16 16:12:23 +00:00
|
|
|
.ava-blur {
|
2021-11-10 20:10:11 +00:00
|
|
|
position: absolute;
|
|
|
|
filter: blur(32px);
|
|
|
|
}
|
2021-11-16 16:12:23 +00:00
|
|
|
.ava-mask {
|
2021-11-10 20:10:11 +00:00
|
|
|
position: absolute;
|
|
|
|
border: 2px solid var(--theme-avatar-border);
|
|
|
|
border-radius: 50%;
|
2021-08-06 08:31:17 +00:00
|
|
|
}
|
2021-11-16 16:12:23 +00:00
|
|
|
|
|
|
|
.ava-x-small .ava-mask, .ava-x-small.no-img,
|
|
|
|
.ava-small .ava-mask, .ava-small.no-img,
|
|
|
|
.ava-medium .ava-mask, .ava-medium.no-img { border-style: none; }
|
2021-08-06 08:31:17 +00:00
|
|
|
</style>
|