Refactor withDefaults

This commit is contained in:
Kasper Seweryn 2022-05-01 17:21:33 +02:00 committed by Georg Krause
parent e29819f314
commit 2f8f7cbafa
6 changed files with 32 additions and 40 deletions

View File

@ -7,10 +7,9 @@ interface Props {
size?: string size?: string
} }
const { isLoading, size } = toRefs(withDefaults( const { isLoading, size } = toRefs(withDefaults(defineProps<Props>(), {
defineProps<Props>(), size: 'small'
{ size: 'small' } }))
))
const isDone = refAutoReset(false, 2000) const isDone = refAutoReset(false, 2000)
watch(isLoading, loading => { watch(isLoading, loading => {

View File

@ -12,15 +12,12 @@ interface Props {
truncateLength?: number truncateLength?: number
} }
const { displayName, actor, truncateLength, admin, avatar } = toRefs(withDefaults( const { displayName, actor, truncateLength, admin, avatar } = toRefs(withDefaults(defineProps<Props>(), {
defineProps<Props>(),
{
avatar: true, avatar: true,
admin: false, admin: false,
displayName: false, displayName: false,
truncateLength: 30 truncateLength: 30
} }))
))
const repr = computed(() => { const repr = computed(() => {
const name = displayName.value || actor.value.is_local const name = displayName.value || actor.value.is_local

View File

@ -8,10 +8,9 @@ interface Props {
icon?: boolean icon?: boolean
} }
const props = withDefaults( const props = withDefaults(defineProps<Props>(), {
defineProps<Props>(), icon: false
{ icon: false } })
)
const date = computed(() => new Date(props.date)) const date = computed(() => new Date(props.date))
// TODO (wvffle): Translate useTimeAgo // TODO (wvffle): Translate useTimeAgo

View File

@ -12,14 +12,11 @@ interface Props {
additionalClasses?: string[] additionalClasses?: string[]
} }
const props = withDefaults( const props = withDefaults(defineProps<Props>(), {
defineProps<Props>(),
{
fullscreen: true, fullscreen: true,
scrolling: false, scrolling: false,
additionalClasses: () => [] additionalClasses: () => []
} })
)
const emit = defineEmits(['approved', 'deny', 'update:show', 'show', 'hide']) const emit = defineEmits(['approved', 'deny', 'update:show', 'show', 'hide'])

View File

@ -11,16 +11,13 @@ interface Props {
detailRoute?: string detailRoute?: string
} }
const props = withDefaults( const props = withDefaults(defineProps<Props>(), {
defineProps<Props>(),
{
showMore: true, showMore: true,
truncateSize: 25, truncateSize: 25,
limit: 5, limit: 5,
labelClasses: '', labelClasses: '',
detailRoute: 'library.tags.detail' detailRoute: 'library.tags.detail'
} })
)
const honorLimit = ref(true) const honorLimit = ref(true)

View File

@ -5,16 +5,19 @@ import { computed } from 'vue'
import { useGettext } from 'vue3-gettext' import { useGettext } from 'vue3-gettext'
import { useStore } from 'vuex' import { useStore } from 'vuex'
interface Props {
next?: string
}
const props = withDefaults(defineProps<Props>(), {
next: '/library'
})
const { $pgettext } = useGettext() const { $pgettext } = useGettext()
const labels = computed(() => ({ const labels = computed(() => ({
title: $pgettext('Head/Login/Title', 'Log In') title: $pgettext('Head/Login/Title', 'Log In')
})) }))
const props = withDefaults(
defineProps<{ next?: string }>(),
{ next: '/library' }
)
const store = useStore() const store = useStore()
if (store.state.auth.authenticated) { if (store.state.auth.authenticated) {
const router = useRouter() const router = useRouter()