2023-05-23 13:16:38 +00:00
|
|
|
<script>
|
|
|
|
import BaseComponent from 'primevue/basecomponent';
|
|
|
|
import { useStyle } from 'primevue/usestyle';
|
|
|
|
|
|
|
|
const styles = `
|
|
|
|
.p-avatar {
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
width: 2rem;
|
|
|
|
height: 2rem;
|
|
|
|
font-size: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-avatar.p-avatar-image {
|
|
|
|
background-color: transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-avatar.p-avatar-circle {
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-avatar-circle img {
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-avatar .p-avatar-icon {
|
|
|
|
font-size: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-avatar img {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
root: ({ props }) => [
|
|
|
|
'p-avatar p-component',
|
|
|
|
{
|
|
|
|
'p-avatar-image': props.image != null,
|
|
|
|
'p-avatar-circle': props.shape === 'circle',
|
|
|
|
'p-avatar-lg': props.size === 'large',
|
|
|
|
'p-avatar-xl': props.size === 'xlarge'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
label: 'p-avatar-text',
|
2023-05-25 14:41:58 +00:00
|
|
|
icon: 'p-avatar-icon'
|
2023-05-23 13:16:38 +00:00
|
|
|
};
|
|
|
|
|
2023-07-03 22:20:35 +00:00
|
|
|
const { load: loadStyle } = useStyle(styles, { name: 'avatar', manual: true });
|
2023-05-23 13:16:38 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'BaseAvatar',
|
|
|
|
extends: BaseComponent,
|
|
|
|
props: {
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
image: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
default: 'normal'
|
|
|
|
},
|
|
|
|
shape: {
|
|
|
|
type: String,
|
|
|
|
default: 'square'
|
|
|
|
},
|
|
|
|
'aria-labelledby': {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
'aria-label': {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
css: {
|
2023-05-30 12:28:04 +00:00
|
|
|
classes,
|
|
|
|
loadStyle
|
2023-05-23 13:16:38 +00:00
|
|
|
},
|
2023-05-30 12:28:04 +00:00
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
$parentInstance: this
|
|
|
|
};
|
2023-05-23 13:16:38 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|