2023-05-24 10:36:51 +00:00
|
|
|
<script>
|
|
|
|
import BaseComponent from 'primevue/basecomponent';
|
|
|
|
import { useStyle } from 'primevue/usestyle';
|
|
|
|
|
|
|
|
const styles = `
|
2023-09-25 19:11:55 +00:00
|
|
|
@layer primevue {
|
|
|
|
.p-skeleton {
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-skeleton::after {
|
|
|
|
content: '';
|
|
|
|
animation: p-skeleton-animation 1.2s infinite;
|
|
|
|
height: 100%;
|
|
|
|
left: 0;
|
|
|
|
position: absolute;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
2023-05-24 10:36:51 +00:00
|
|
|
transform: translateX(-100%);
|
2023-09-25 19:11:55 +00:00
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-skeleton.p-skeleton-circle {
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-skeleton-none::after {
|
|
|
|
animation: none;
|
2023-05-24 10:36:51 +00:00
|
|
|
}
|
2023-09-25 19:11:55 +00:00
|
|
|
|
|
|
|
@keyframes p-skeleton-animation {
|
|
|
|
from {
|
|
|
|
transform: translateX(-100%);
|
|
|
|
}
|
|
|
|
to {
|
|
|
|
transform: translateX(100%);
|
|
|
|
}
|
2023-05-24 10:36:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2023-05-25 14:43:15 +00:00
|
|
|
const inlineStyles = {
|
|
|
|
root: { position: 'relative' }
|
|
|
|
};
|
|
|
|
|
2023-05-24 10:36:51 +00:00
|
|
|
const classes = {
|
|
|
|
root: ({ props }) => [
|
|
|
|
'p-skeleton p-component',
|
|
|
|
{
|
|
|
|
'p-skeleton-circle': props.shape === 'circle',
|
|
|
|
'p-skeleton-none': props.animation === 'none'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2023-07-03 22:20:35 +00:00
|
|
|
const { load: loadStyle } = useStyle(styles, { name: 'skeleton', manual: true });
|
2023-05-24 10:36:51 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'BaseSkeleton',
|
|
|
|
extends: BaseComponent,
|
|
|
|
props: {
|
|
|
|
shape: {
|
|
|
|
type: String,
|
|
|
|
default: 'rectangle'
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: String,
|
|
|
|
default: '100%'
|
|
|
|
},
|
|
|
|
height: {
|
|
|
|
type: String,
|
|
|
|
default: '1rem'
|
|
|
|
},
|
|
|
|
borderRadius: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
animation: {
|
|
|
|
type: String,
|
|
|
|
default: 'wave'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
css: {
|
2023-05-25 14:43:15 +00:00
|
|
|
classes,
|
2023-05-30 12:28:04 +00:00
|
|
|
inlineStyles,
|
|
|
|
loadStyle
|
2023-05-24 10:36:51 +00:00
|
|
|
},
|
2023-05-30 12:28:04 +00:00
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
$parentInstance: this
|
|
|
|
};
|
2023-05-24 10:36:51 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|