mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-02-23 13:31:06 +08:00
refactor(spin): set base radius to 100
This commit is contained in:
parent
5bbd7c0e31
commit
df459e6ec3
@ -5,7 +5,7 @@
|
|||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class="n-base-loading-circular"
|
class="n-base-loading-circular"
|
||||||
viewBox="25 25 50 50"
|
:viewBox="`0 0 ${radius * 2} ${radius * 2}`"
|
||||||
>
|
>
|
||||||
<circle
|
<circle
|
||||||
:style="{
|
:style="{
|
||||||
@ -13,10 +13,10 @@
|
|||||||
stroke
|
stroke
|
||||||
}"
|
}"
|
||||||
class="n-base-loading-circular-path"
|
class="n-base-loading-circular-path"
|
||||||
cx="50"
|
:cx="radius"
|
||||||
cy="50"
|
:cy="radius"
|
||||||
fill="none"
|
fill="none"
|
||||||
r="20"
|
:r="radius - (strokeWidth) / 2"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
@ -26,21 +26,22 @@
|
|||||||
export default {
|
export default {
|
||||||
name: 'NBaseLoading',
|
name: 'NBaseLoading',
|
||||||
props: {
|
props: {
|
||||||
|
radius: {
|
||||||
|
type: Number,
|
||||||
|
default: 100
|
||||||
|
},
|
||||||
theme: {
|
theme: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
strokeWidth: {
|
strokeWidth: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: null
|
default: 28
|
||||||
},
|
},
|
||||||
stroke: {
|
stroke: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
// console.log(this.strokeWidth)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
transition: hollowOutColorTransitionDisabled ? 'none' : null
|
transition: hollowOutColorTransitionDisabled ? 'none' : null
|
||||||
}"
|
}"
|
||||||
:stroke="simulateHollowOut ? ascendantBackgroundColor : null"
|
:stroke="simulateHollowOut ? ascendantBackgroundColor : null"
|
||||||
:stroke-width="4"
|
:stroke-width="24"
|
||||||
/>
|
/>
|
||||||
<n-icon
|
<n-icon
|
||||||
v-else
|
v-else
|
||||||
@ -81,7 +81,6 @@
|
|||||||
transition: hollowOutColorTransitionDisabled ? 'none' : null
|
transition: hollowOutColorTransitionDisabled ? 'none' : null
|
||||||
}"
|
}"
|
||||||
:stroke="simulateHollowOut ? ascendantBackgroundColor : null"
|
:stroke="simulateHollowOut ? ascendantBackgroundColor : null"
|
||||||
:stroke-width="4"
|
|
||||||
/>
|
/>
|
||||||
<n-icon
|
<n-icon
|
||||||
v-else
|
v-else
|
||||||
|
@ -3,18 +3,6 @@
|
|||||||
v-if="$slots.default"
|
v-if="$slots.default"
|
||||||
class="n-spin-container"
|
class="n-spin-container"
|
||||||
>
|
>
|
||||||
<transition name="n-spin--transition">
|
|
||||||
<n-base-loading
|
|
||||||
v-if="spinning"
|
|
||||||
:class="{
|
|
||||||
[`n-spin--${size}-size`]: true
|
|
||||||
}"
|
|
||||||
:stroke="stroke"
|
|
||||||
:stroke-width="strokeWidth"
|
|
||||||
:theme="synthesizedTheme"
|
|
||||||
class="n-spin"
|
|
||||||
/>
|
|
||||||
</transition>
|
|
||||||
<div
|
<div
|
||||||
:class="{
|
:class="{
|
||||||
'n-spin-content--spinning': spinning
|
'n-spin-content--spinning': spinning
|
||||||
@ -23,6 +11,18 @@
|
|||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
<transition name="n-spin--transition">
|
||||||
|
<n-base-loading
|
||||||
|
v-if="spinning"
|
||||||
|
:class="{
|
||||||
|
[`n-spin--${size}-size`]: true
|
||||||
|
}"
|
||||||
|
:stroke="stroke"
|
||||||
|
:stroke-width="synthesizedStrokeWidth"
|
||||||
|
:theme="synthesizedTheme"
|
||||||
|
class="n-spin"
|
||||||
|
/>
|
||||||
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
<n-base-loading
|
<n-base-loading
|
||||||
v-else
|
v-else
|
||||||
@ -30,9 +30,8 @@
|
|||||||
[`n-spin--${size}-size`]: size
|
[`n-spin--${size}-size`]: size
|
||||||
}"
|
}"
|
||||||
:stroke="stroke"
|
:stroke="stroke"
|
||||||
:stroke-width="strokeWidth"
|
:stroke-width="synthesizedStrokeWidth"
|
||||||
:theme="synthesizedTheme"
|
:theme="synthesizedTheme"
|
||||||
:style="synthesizedStyle"
|
|
||||||
class="n-spin"
|
class="n-spin"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@ -43,6 +42,15 @@ import withapp from '../../../mixins/withapp'
|
|||||||
import themeable from '../../../mixins/themeable'
|
import themeable from '../../../mixins/themeable'
|
||||||
import asthemecontext from '../../../mixins/asthemecontext'
|
import asthemecontext from '../../../mixins/asthemecontext'
|
||||||
|
|
||||||
|
const STROKE_WIDTH = {
|
||||||
|
small: 22,
|
||||||
|
medium: 20,
|
||||||
|
large: 18,
|
||||||
|
'in-small': 30,
|
||||||
|
'in-medium': 28,
|
||||||
|
'in-large': 26
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'NSpin',
|
name: 'NSpin',
|
||||||
components: {
|
components: {
|
||||||
@ -67,6 +75,13 @@ export default {
|
|||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {}
|
computed: {
|
||||||
|
synthesizedStrokeWidth () {
|
||||||
|
const strokeWidth = this.strokeWidth
|
||||||
|
if (strokeWidth !== null) return strokeWidth
|
||||||
|
const size = this.size
|
||||||
|
return STROKE_WIDTH[size]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,26 +1,31 @@
|
|||||||
@import './mixins/mixins.scss';
|
@import './mixins/mixins.scss';
|
||||||
@import './themes/vars.scss';
|
@import './themes/vars.scss';
|
||||||
|
|
||||||
|
$--base-loading-stroke-dashoffset: 500;
|
||||||
|
|
||||||
@keyframes n-base-loading-rotate {
|
@keyframes n-base-loading-rotate {
|
||||||
to {
|
0% {
|
||||||
transform: rotate(1turn)
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: rotate(270deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes n-base-loading-dash {
|
@keyframes n-base-loading-dash {
|
||||||
0% {
|
0% {
|
||||||
stroke-dasharray: 1,200;
|
stroke-dashoffset: $--base-loading-stroke-dashoffset;
|
||||||
stroke-dashoffset: 0
|
|
||||||
}
|
}
|
||||||
50% {
|
50% {
|
||||||
stroke-dasharray: 90,150;
|
stroke-dashoffset: $--base-loading-stroke-dashoffset / 4;
|
||||||
stroke-dashoffset: -40px
|
transform: rotate(135deg);
|
||||||
}
|
}
|
||||||
to {
|
100% {
|
||||||
stroke-dasharray: 90,150;
|
stroke-dashoffset: $--base-loading-stroke-dashoffset;
|
||||||
stroke-dashoffset: -120px
|
transform: rotate(450deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@include themes-mixin {
|
@include themes-mixin {
|
||||||
@include b(base-loading) {
|
@include b(base-loading) {
|
||||||
@include once {
|
@include once {
|
||||||
@ -30,16 +35,17 @@
|
|||||||
@include once {
|
@include once {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
animation: n-base-loading-rotate 2s linear infinite;
|
animation: n-base-loading-rotate 1.5s linear infinite;
|
||||||
|
transform-origin: center;
|
||||||
}
|
}
|
||||||
@include b(base-loading-circular-path) {
|
@include b(base-loading-circular-path) {
|
||||||
stroke: $--base-loading-stroke;
|
stroke: $--base-loading-stroke;
|
||||||
@include once {
|
@include once {
|
||||||
|
transform-origin: center;
|
||||||
transition: stroke .3s $--n-ease-in-out-cubic-bezier;
|
transition: stroke .3s $--n-ease-in-out-cubic-bezier;
|
||||||
animation: n-base-loading-dash 1.5s ease-in-out infinite;
|
animation: n-base-loading-dash 1.5s ease-in-out infinite;
|
||||||
stroke-dasharray: 90, 150;
|
stroke-dasharray: $--base-loading-stroke-dashoffset;
|
||||||
stroke-dashoffset: 0;
|
stroke-dashoffset: 0;
|
||||||
stroke-width: 8;
|
|
||||||
stroke-linecap: round;
|
stroke-linecap: round;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,49 +9,32 @@
|
|||||||
@include m(in-small-size) {
|
@include m(in-small-size) {
|
||||||
width: 14px;
|
width: 14px;
|
||||||
height: 14px;
|
height: 14px;
|
||||||
@include b(base-loading-circular-path) {
|
|
||||||
stroke-width: 8!important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@include m(in-medium-size) {
|
@include m(in-medium-size) {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
@include b(base-loading-circular-path) {
|
|
||||||
stroke-width: 7!important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@include m(in-large-size) {
|
@include m(in-large-size) {
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
@include b(base-loading-circular-path) {
|
|
||||||
stroke-width: 6!important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@include m(small-size) {
|
@include m(small-size) {
|
||||||
width: 28px;
|
width: 28px;
|
||||||
height: 28px;
|
height: 28px;
|
||||||
@include b(base-loading-circular-path) {
|
|
||||||
stroke-width: 6!important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@include m(medium-size) {
|
@include m(medium-size) {
|
||||||
width: 34px;
|
width: 34px;
|
||||||
height: 34px;
|
height: 34px;
|
||||||
@include b(base-loading-circular-path) {
|
|
||||||
stroke-width: 5!important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@include m(large-size) {
|
@include m(large-size) {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
@include b(base-loading-circular-path) {
|
|
||||||
stroke-width: 4.25!important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@include b(spin-container) {
|
@include b(spin-container) {
|
||||||
position: relative;
|
position: relative;
|
||||||
@include b(spin) {
|
@include b(spin) {
|
||||||
|
pointer-events: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
|
Loading…
Reference in New Issue
Block a user