|
|
|
@ -4,7 +4,7 @@ import { isColorDark, stringToColor } from '#imports'
|
|
|
|
|
const props = withDefaults( |
|
|
|
|
defineProps<{ |
|
|
|
|
size?: 'small' | 'medium' | 'base' | 'large' | 'xlarge' | 'auto' |
|
|
|
|
name?: string |
|
|
|
|
name?: string | null |
|
|
|
|
email?: string |
|
|
|
|
disabled?: boolean |
|
|
|
|
}>(), |
|
|
|
@ -16,17 +16,19 @@ const props = withDefaults(
|
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const { size, email } = toRefs(props) |
|
|
|
|
const { size } = toRefs(props) |
|
|
|
|
|
|
|
|
|
const displayName = computed(() => props.name?.trim() || '') |
|
|
|
|
|
|
|
|
|
const userEmail = computed(() => props.email?.trim() || '') |
|
|
|
|
|
|
|
|
|
const backgroundColor = computed(() => { |
|
|
|
|
if (props.disabled) { |
|
|
|
|
return '#bbbbbb' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// in comments we need to generate user icon from email |
|
|
|
|
return displayName.value ? stringToColor(displayName.value) : email.value ? stringToColor(email.value) : '#FFFFFF' |
|
|
|
|
return displayName.value ? stringToColor(displayName.value) : userEmail.value ? stringToColor(userEmail.value) : '#FFFFFF' |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const usernameInitials = computed(() => { |
|
|
|
@ -43,7 +45,7 @@ const usernameInitials = computed(() => {
|
|
|
|
|
return displayName.value.slice(0, 2) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return email.value?.split('@')[0].slice(0, 2) |
|
|
|
|
return userEmail.value?.split('@')[0].slice(0, 2) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
</script> |
|
|
|
|