From 2f8f7cbafa90aefd1888f3fc02c953d59ef2b32b Mon Sep 17 00:00:00 2001 From: Kasper Seweryn Date: Sun, 1 May 2022 17:21:33 +0200 Subject: [PATCH] Refactor withDefaults --- front/src/components/common/ActionFeedback.vue | 7 +++---- front/src/components/common/ActorLink.vue | 15 ++++++--------- front/src/components/common/HumanDate.vue | 7 +++---- front/src/components/semantic/Modal.vue | 13 +++++-------- front/src/components/tags/List.vue | 17 +++++++---------- front/src/views/auth/Login.vue | 13 ++++++++----- 6 files changed, 32 insertions(+), 40 deletions(-) diff --git a/front/src/components/common/ActionFeedback.vue b/front/src/components/common/ActionFeedback.vue index 86846b51b..381755f55 100644 --- a/front/src/components/common/ActionFeedback.vue +++ b/front/src/components/common/ActionFeedback.vue @@ -7,10 +7,9 @@ interface Props { size?: string } -const { isLoading, size } = toRefs(withDefaults( - defineProps(), - { size: 'small' } -)) +const { isLoading, size } = toRefs(withDefaults(defineProps(), { + size: 'small' +})) const isDone = refAutoReset(false, 2000) watch(isLoading, loading => { diff --git a/front/src/components/common/ActorLink.vue b/front/src/components/common/ActorLink.vue index 1a4a8f236..9ea839356 100644 --- a/front/src/components/common/ActorLink.vue +++ b/front/src/components/common/ActorLink.vue @@ -12,15 +12,12 @@ interface Props { truncateLength?: number } -const { displayName, actor, truncateLength, admin, avatar } = toRefs(withDefaults( - defineProps(), - { - avatar: true, - admin: false, - displayName: false, - truncateLength: 30 - } -)) +const { displayName, actor, truncateLength, admin, avatar } = toRefs(withDefaults(defineProps(), { + avatar: true, + admin: false, + displayName: false, + truncateLength: 30 +})) const repr = computed(() => { const name = displayName.value || actor.value.is_local diff --git a/front/src/components/common/HumanDate.vue b/front/src/components/common/HumanDate.vue index 93b20751e..881762aba 100644 --- a/front/src/components/common/HumanDate.vue +++ b/front/src/components/common/HumanDate.vue @@ -8,10 +8,9 @@ interface Props { icon?: boolean } -const props = withDefaults( - defineProps(), - { icon: false } -) +const props = withDefaults(defineProps(), { + icon: false +}) const date = computed(() => new Date(props.date)) // TODO (wvffle): Translate useTimeAgo diff --git a/front/src/components/semantic/Modal.vue b/front/src/components/semantic/Modal.vue index acc03aeae..33fe65ba2 100644 --- a/front/src/components/semantic/Modal.vue +++ b/front/src/components/semantic/Modal.vue @@ -12,14 +12,11 @@ interface Props { additionalClasses?: string[] } -const props = withDefaults( - defineProps(), - { - fullscreen: true, - scrolling: false, - additionalClasses: () => [] - } -) +const props = withDefaults(defineProps(), { + fullscreen: true, + scrolling: false, + additionalClasses: () => [] +}) const emit = defineEmits(['approved', 'deny', 'update:show', 'show', 'hide']) diff --git a/front/src/components/tags/List.vue b/front/src/components/tags/List.vue index fcab10983..dd9eb8fed 100644 --- a/front/src/components/tags/List.vue +++ b/front/src/components/tags/List.vue @@ -11,16 +11,13 @@ interface Props { detailRoute?: string } -const props = withDefaults( - defineProps(), - { - showMore: true, - truncateSize: 25, - limit: 5, - labelClasses: '', - detailRoute: 'library.tags.detail' - } -) +const props = withDefaults(defineProps(), { + showMore: true, + truncateSize: 25, + limit: 5, + labelClasses: '', + detailRoute: 'library.tags.detail' +}) const honorLimit = ref(true) diff --git a/front/src/views/auth/Login.vue b/front/src/views/auth/Login.vue index b8dca80a1..c6d65995f 100644 --- a/front/src/views/auth/Login.vue +++ b/front/src/views/auth/Login.vue @@ -5,16 +5,19 @@ import { computed } from 'vue' import { useGettext } from 'vue3-gettext' import { useStore } from 'vuex' +interface Props { + next?: string +} + +const props = withDefaults(defineProps(), { + next: '/library' +}) + const { $pgettext } = useGettext() const labels = computed(() => ({ title: $pgettext('Head/Login/Title', 'Log In') })) -const props = withDefaults( - defineProps<{ next?: string }>(), - { next: '/library' } -) - const store = useStore() if (store.state.auth.authenticated) { const router = useRouter()