fix: propType validation in message.vue

This commit is contained in:
Dominik Pschenitschni 2021-12-21 16:07:38 +01:00
parent 27cd9535bf
commit 9a3069c20d
No known key found for this signature in database
GPG key ID: B257AC0149F43A77

View file

@ -7,7 +7,15 @@
</template>
<script lang="ts" setup>
import {computed} from 'vue'
import {computed, PropType} from 'vue'
const TEXT_ALIGN_MAP = Object.freeze({
left: '',
center: 'has-text-centered',
right: 'has-text-right',
})
type textAlignVariants = keyof typeof TEXT_ALIGN_MAP
const props = defineProps({
variant: {
@ -15,21 +23,12 @@ const props = defineProps({
default: 'info',
},
textAlign: {
type: String,
type: String as PropType<textAlignVariants>,
default: 'left',
},
})
const textAlignClass = computed(() => {
switch (props.textAlign) {
case 'left':
return ''
case 'right':
return 'has-text-right'
case 'center':
return 'has-text-centered'
}
})
const textAlignClass = computed(() => TEXT_ALIGN_MAP[props.textAlign])
</script>