|
|
@ -1,4 +1,6 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
|
|
|
|
import { isColorDark, stringToColor } from '~/utils/colorsUtils' |
|
|
|
|
|
|
|
|
|
|
|
const props = withDefaults( |
|
|
|
const props = withDefaults( |
|
|
|
defineProps<{ |
|
|
|
defineProps<{ |
|
|
|
size?: 'small' | 'medium' | 'base' | 'large' | 'xlarge' |
|
|
|
size?: 'small' | 'medium' | 'base' | 'large' | 'xlarge' |
|
|
@ -15,10 +17,10 @@ const emailProp = toRef(props, 'email') |
|
|
|
const backgroundColor = computed(() => { |
|
|
|
const backgroundColor = computed(() => { |
|
|
|
// in comments we need to generate user icon from email |
|
|
|
// in comments we need to generate user icon from email |
|
|
|
if (emailProp.value.length) { |
|
|
|
if (emailProp.value.length) { |
|
|
|
return stringToColour(emailProp.value) |
|
|
|
return stringToColor(emailProp.value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return props.email ? stringToColour(props.email) : '#FFFFFF' |
|
|
|
return props.email ? stringToColor(props.email) : '#FFFFFF' |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const size = computed(() => props.size || 'medium') |
|
|
|
const size = computed(() => props.size || 'medium') |
|
|
@ -44,13 +46,15 @@ const usernameInitials = computed(() => { |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div |
|
|
|
<div |
|
|
|
class="flex nc-user-avatar" |
|
|
|
class="flex nc-user-avatar font-bold" |
|
|
|
:class="{ |
|
|
|
:class="{ |
|
|
|
'min-w-4 min-h-4': size === 'small', |
|
|
|
'min-w-4 min-h-4': size === 'small', |
|
|
|
'min-w-6 min-h-6': size === 'medium', |
|
|
|
'min-w-6 min-h-6': size === 'medium', |
|
|
|
'w-8 h-8 !text-md': size === 'base', |
|
|
|
'w-8 h-8 !text-md': size === 'base', |
|
|
|
'min-w-20 min-h-20 !text-3xl': size === 'large', |
|
|
|
'min-w-20 min-h-20 !text-3xl': size === 'large', |
|
|
|
'min-w-26 min-h-26 !text-4xl': size === 'xlarge', |
|
|
|
'min-w-26 min-h-26 !text-4xl': size === 'xlarge', |
|
|
|
|
|
|
|
'text-white': isColorDark(backgroundColor), |
|
|
|
|
|
|
|
'text-black': !isColorDark(backgroundColor), |
|
|
|
}" |
|
|
|
}" |
|
|
|
:style="{ backgroundColor }" |
|
|
|
:style="{ backgroundColor }" |
|
|
|
> |
|
|
|
> |
|
|
@ -60,6 +64,6 @@ const usernameInitials = computed(() => { |
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
<style lang="scss" scoped> |
|
|
|
.nc-user-avatar { |
|
|
|
.nc-user-avatar { |
|
|
|
@apply rounded-full text-xs flex items-center justify-center text-white uppercase; |
|
|
|
@apply rounded-full text-xs flex items-center justify-center uppercase; |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|
</style> |
|
|
|