Convert Avatar & Badge components to Composition API (#1386)

This commit is contained in:
Mysterious_Dev
2023-10-01 17:47:47 +02:00
committed by GitHub
parent 4a74ee0d72
commit 3fa86cb441
2 changed files with 48 additions and 71 deletions
+7 -13
View File
@@ -34,9 +34,10 @@
</svg> </svg>
</template> </template>
<script> <script setup>
export default { const pixelated = ref(false)
props: {
defineProps({
src: { src: {
type: String, type: String,
default: null, default: null,
@@ -68,21 +69,14 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
}, })
data() {
return { function updatePixelated() {
pixelated: false,
}
},
methods: {
updatePixelated() {
if (this.$refs.img && this.$refs.img.naturalWidth && this.$refs.img.naturalWidth <= 96) { if (this.$refs.img && this.$refs.img.naturalWidth && this.$refs.img.naturalWidth <= 96) {
this.pixelated = true this.pixelated = true
} else { } else {
this.pixelated = false this.pixelated = false
} }
},
},
} }
</script> </script>
+3 -20
View File
@@ -34,7 +34,7 @@
</span> </span>
</template> </template>
<script> <script setup>
import ModrinthIcon from '~/assets/images/logo.svg' import ModrinthIcon from '~/assets/images/logo.svg'
import ModeratorIcon from '~/assets/images/sidebar/admin.svg' import ModeratorIcon from '~/assets/images/sidebar/admin.svg'
import CreatorIcon from '~/assets/images/utils/box.svg' import CreatorIcon from '~/assets/images/utils/box.svg'
@@ -49,23 +49,7 @@ import LockIcon from '~/assets/images/utils/lock.svg'
import CalendarIcon from '~/assets/images/utils/calendar.svg' import CalendarIcon from '~/assets/images/utils/calendar.svg'
import CloseIcon from '~/assets/images/utils/check-circle.svg' import CloseIcon from '~/assets/images/utils/check-circle.svg'
export default { defineProps({
components: {
ModrinthIcon,
ListIcon,
DraftIcon,
EyeOffIcon,
ModeratorIcon,
CreatorIcon,
CrossIcon,
ArchiveIcon,
ProcessingIcon,
CheckIcon,
LockIcon,
CalendarIcon,
CloseIcon,
},
props: {
type: { type: {
type: String, type: String,
required: true, required: true,
@@ -74,8 +58,7 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
}, })
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>