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

View File

@@ -34,55 +34,49 @@
</svg> </svg>
</template> </template>
<script> <script setup>
export default { const pixelated = ref(false)
props: {
src: { defineProps({
type: String, src: {
default: null, type: String,
}, default: null,
alt: { },
type: String, alt: {
default: '', type: String,
}, default: '',
size: { },
type: String, size: {
default: 'sm', type: String,
validator(value) { default: 'sm',
return ['xxs', 'xs', 'sm', 'md', 'lg'].includes(value) validator(value) {
}, return ['xxs', 'xs', 'sm', 'md', 'lg'].includes(value)
},
circle: {
type: Boolean,
default: false,
},
noShadow: {
type: Boolean,
default: false,
},
loading: {
type: String,
default: 'eager',
},
raised: {
type: Boolean,
default: false,
}, },
}, },
data() { circle: {
return { type: Boolean,
pixelated: false, default: false,
}
}, },
methods: { noShadow: {
updatePixelated() { type: Boolean,
if (this.$refs.img && this.$refs.img.naturalWidth && this.$refs.img.naturalWidth <= 96) { default: false,
this.pixelated = true
} else {
this.pixelated = false
}
},
}, },
loading: {
type: String,
default: 'eager',
},
raised: {
type: Boolean,
default: false,
},
})
function updatePixelated() {
if (this.$refs.img && this.$refs.img.naturalWidth && this.$refs.img.naturalWidth <= 96) {
this.pixelated = true
} else {
this.pixelated = false
}
} }
</script> </script>

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,33 +49,16 @@ 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: { type: {
ModrinthIcon, type: String,
ListIcon, required: true,
DraftIcon,
EyeOffIcon,
ModeratorIcon,
CreatorIcon,
CrossIcon,
ArchiveIcon,
ProcessingIcon,
CheckIcon,
LockIcon,
CalendarIcon,
CloseIcon,
}, },
props: { color: {
type: { type: String,
type: String, default: '',
required: true,
},
color: {
type: String,
default: '',
},
}, },
} })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>