Refactor #3965 - For ProgressSpinner

pull/3997/head
Bahadır Sofuoğlu 2023-05-24 14:44:15 +03:00
parent 9377287826
commit ee81d3b10c
3 changed files with 78 additions and 45 deletions

View File

@ -0,0 +1,70 @@
<script>
import BaseComponent from 'primevue/basecomponent';
import { useStyle } from 'primevue/usestyle';
const styles = `
.p-progress-spinner {
position: relative;
margin: 0 auto;
width: 100px;
height: 100px;
display: inline-block;
}
.p-progress-spinner::before {
content: '';
display: block;
padding-top: 100%;
}
.p-progress-spinner-svg {
height: 100%;
transform-origin: center center;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
`;
const classes = {
root: 'p-progress-spinner',
spinner: 'p-progress-spinner-svg',
circle: 'p-progress-spinner-circle'
};
const { load: loadStyle } = useStyle(styles, { id: 'primevue_progressspinner_style', manual: true });
export default {
name: 'BaseProgressSpinner',
extends: BaseComponent,
props: {
strokeWidth: {
type: String,
default: '2'
},
fill: {
type: String,
default: 'none'
},
animationDuration: {
type: String,
default: '2s'
}
},
css: {
classes
},
watch: {
isUnstyled: {
immediate: true,
handler(newValue) {
!newValue && loadStyle();
}
}
}
};
</script>

View File

@ -67,6 +67,11 @@ export interface ProgressSpinnerProps {
* @type {ProgressSpinnerPassThroughOptions} * @type {ProgressSpinnerPassThroughOptions}
*/ */
pt?: ProgressSpinnerPassThroughOptions; pt?: ProgressSpinnerPassThroughOptions;
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
} }
/** /**

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="p-progress-spinner" role="progressbar" v-bind="ptm('root')"> <div :class="cx('root')" role="progressbar" v-bind="ptm('root')">
<svg class="p-progress-spinner-svg" viewBox="25 25 50 50" :style="svgStyle" v-bind="ptm('spinner')"> <svg :class="cx('spinner')" viewBox="25 25 50 50" :style="svgStyle" v-bind="ptm('spinner')">
<circle class="p-progress-spinner-circle" cx="50" cy="50" r="20" :fill="fill" :stroke-width="strokeWidth" strokeMiterlimit="10" v-bind="ptm('circle')" /> <circle :class="cx('circle')" cx="50" cy="50" r="20" :fill="fill" :stroke-width="strokeWidth" strokeMiterlimit="10" v-bind="ptm('circle')" />
</svg> </svg>
</div> </div>
</template> </template>
@ -12,20 +12,6 @@ import BaseComponent from 'primevue/basecomponent';
export default { export default {
name: 'ProgressSpinner', name: 'ProgressSpinner',
extends: BaseComponent, extends: BaseComponent,
props: {
strokeWidth: {
type: String,
default: '2'
},
fill: {
type: String,
default: 'none'
},
animationDuration: {
type: String,
default: '2s'
}
},
computed: { computed: {
svgStyle() { svgStyle() {
return { return {
@ -35,31 +21,3 @@ export default {
} }
}; };
</script> </script>
<style>
.p-progress-spinner {
position: relative;
margin: 0 auto;
width: 100px;
height: 100px;
display: inline-block;
}
.p-progress-spinner::before {
content: '';
display: block;
padding-top: 100%;
}
.p-progress-spinner-svg {
height: 100%;
transform-origin: center center;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
</style>