Client - register globally some custom components

This commit is contained in:
Sam 2021-10-23 15:29:39 +02:00
parent 8d93024a5f
commit d78470062d
21 changed files with 26 additions and 70 deletions

View File

@ -47,7 +47,6 @@
onMounted, onMounted,
} from 'vue' } from 'vue'
import Loader from '@/components/Common/Loader.vue'
import Footer from '@/components/Footer.vue' import Footer from '@/components/Footer.vue'
import NavBar from '@/components/NavBar.vue' import NavBar from '@/components/NavBar.vue'
import NoConfig from '@/components/NoConfig.vue' import NoConfig from '@/components/NoConfig.vue'
@ -74,7 +73,6 @@
name: 'App', name: 'App',
components: { components: {
Footer, Footer,
Loader,
NavBar, NavBar,
NoConfig, NoConfig,
}, },

View File

@ -18,7 +18,7 @@
import { defineComponent, ref, watch } from 'vue' import { defineComponent, ref, watch } from 'vue'
export default defineComponent({ export default defineComponent({
name: 'CustomTextarea', name: 'CustomTextArea',
props: { props: {
charLimit: { charLimit: {
type: Number, type: Number,

View File

@ -25,17 +25,11 @@
<script lang="ts"> <script lang="ts">
import { ComputedRef, computed, defineComponent, onUnmounted } from 'vue' import { ComputedRef, computed, defineComponent, onUnmounted } from 'vue'
import Card from '@/components/Common/Card.vue'
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
import { ROOT_STORE } from '@/store/constants' import { ROOT_STORE } from '@/store/constants'
import { useStore } from '@/use/useStore' import { useStore } from '@/use/useStore'
export default defineComponent({ export default defineComponent({
name: 'Modal', name: 'Modal',
components: {
Card,
ErrorMessage,
},
props: { props: {
title: { title: {
type: String, type: String,

View File

@ -19,7 +19,6 @@
import { endOfMonth, startOfMonth } from 'date-fns' import { endOfMonth, startOfMonth } from 'date-fns'
import { PropType, defineComponent } from 'vue' import { PropType, defineComponent } from 'vue'
import Card from '@/components/Common/Card.vue'
import StatChart from '@/components/Common/StatsChart/index.vue' import StatChart from '@/components/Common/StatsChart/index.vue'
import { ISport } from '@/types/sports' import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user' import { IAuthUserProfile } from '@/types/user'
@ -27,7 +26,6 @@
export default defineComponent({ export default defineComponent({
name: 'UserMonthStats', name: 'UserMonthStats',
components: { components: {
Card,
StatChart, StatChart,
}, },
props: { props: {

View File

@ -30,14 +30,12 @@
import { PropType, defineComponent } from 'vue' import { PropType, defineComponent } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import Card from '@/components/Common/Card.vue'
import SportImage from '@/components/Common/Images/SportImage/index.vue' import SportImage from '@/components/Common/Images/SportImage/index.vue'
import { IRecord } from '@/types/workouts' import { IRecord } from '@/types/workouts'
export default defineComponent({ export default defineComponent({
name: 'RecordsCard', name: 'RecordsCard',
components: { components: {
Card,
SportImage, SportImage,
}, },
props: { props: {

View File

@ -77,7 +77,6 @@
import { ComputedRef, computed, defineComponent, ref } from 'vue' import { ComputedRef, computed, defineComponent, ref } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import Dropdown from '@/components/Common/Dropdown.vue'
import UserPicture from '@/components/User/UserPicture.vue' import UserPicture from '@/components/User/UserPicture.vue'
import { ROOT_STORE, USER_STORE } from '@/store/constants' import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { IDropdownOption } from '@/types/forms' import { IDropdownOption } from '@/types/forms'
@ -88,7 +87,6 @@
export default defineComponent({ export default defineComponent({
name: 'NavBar', name: 'NavBar',
components: { components: {
Dropdown,
UserPicture, UserPicture,
}, },
emits: ['menuInteraction'], emits: ['menuInteraction'],

View File

@ -12,13 +12,11 @@
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue' import { defineComponent } from 'vue'
import Card from '@/components/Common/Card.vue'
import UserAuthForm from '@/components/User/UserAuthForm.vue' import UserAuthForm from '@/components/User/UserAuthForm.vue'
export default defineComponent({ export default defineComponent({
name: 'PasswordResetForm', name: 'PasswordResetForm',
components: { components: {
Card,
UserAuthForm, UserAuthForm,
}, },
props: { props: {

View File

@ -106,20 +106,12 @@
onMounted, onMounted,
} from 'vue' } from 'vue'
import CustomTextArea from '@/components/Common/CustomTextArea.vue'
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
import Modal from '@/components/Common/Modal.vue'
import { ROOT_STORE, USER_STORE } from '@/store/constants' import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { IAuthUserProfile, IUserPayload } from '@/types/user' import { IAuthUserProfile, IUserPayload } from '@/types/user'
import { useStore } from '@/use/useStore' import { useStore } from '@/use/useStore'
export default defineComponent({ export default defineComponent({
name: 'UserInfosEdition', name: 'UserInfosEdition',
components: {
CustomTextArea,
ErrorMessage,
Modal,
},
props: { props: {
user: { user: {
type: Object as PropType<IAuthUserProfile>, type: Object as PropType<IAuthUserProfile>,

View File

@ -37,7 +37,6 @@
ref, ref,
} from 'vue' } from 'vue'
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
import UserPicture from '@/components/User/UserPicture.vue' import UserPicture from '@/components/User/UserPicture.vue'
import { ROOT_STORE, USER_STORE } from '@/store/constants' import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { IAppConfig } from '@/types/application' import { IAppConfig } from '@/types/application'
@ -48,7 +47,6 @@
export default defineComponent({ export default defineComponent({
name: 'UserPictureEdition', name: 'UserPictureEdition',
components: { components: {
ErrorMessage,
UserPicture, UserPicture,
}, },
props: { props: {

View File

@ -59,16 +59,12 @@
} from 'vue' } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
import { ROOT_STORE, USER_STORE } from '@/store/constants' import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { IAuthUserProfile, IUserPreferencesPayload } from '@/types/user' import { IAuthUserProfile, IUserPreferencesPayload } from '@/types/user'
import { useStore } from '@/use/useStore' import { useStore } from '@/use/useStore'
export default defineComponent({ export default defineComponent({
name: 'UserPreferencesEdition', name: 'UserPreferencesEdition',
components: {
ErrorMessage,
},
props: { props: {
user: { user: {
type: Object as PropType<IAuthUserProfile>, type: Object as PropType<IAuthUserProfile>,

View File

@ -20,7 +20,6 @@
<script lang="ts"> <script lang="ts">
import { PropType, computed, defineComponent, ref } from 'vue' import { PropType, computed, defineComponent, ref } from 'vue'
import Card from '@/components/Common/Card.vue'
import UserInfosEdition from '@/components/User/ProfileEdition/UserInfosEdition.vue' import UserInfosEdition from '@/components/User/ProfileEdition/UserInfosEdition.vue'
import UserPictureEdition from '@/components/User/ProfileEdition/UserPictureEdition.vue' import UserPictureEdition from '@/components/User/ProfileEdition/UserPictureEdition.vue'
import UserPreferencesEdition from '@/components/User/ProfileEdition/UserPreferencesEdition.vue' import UserPreferencesEdition from '@/components/User/ProfileEdition/UserPreferencesEdition.vue'
@ -32,7 +31,6 @@
export default defineComponent({ export default defineComponent({
name: 'ProfileEdition', name: 'ProfileEdition',
components: { components: {
Card,
UserInfosEdition, UserInfosEdition,
UserPictureEdition, UserPictureEdition,
UserPreferencesEdition, UserPreferencesEdition,

View File

@ -80,8 +80,6 @@
import { ComputedRef, computed, defineComponent, reactive, watch } from 'vue' import { ComputedRef, computed, defineComponent, reactive, watch } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import AlertMessage from '@/components/Common/AlertMessage.vue'
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
import { ROOT_STORE, USER_STORE } from '@/store/constants' import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { IAppConfig } from '@/types/application' import { IAppConfig } from '@/types/application'
import { ILoginRegisterFormData } from '@/types/user' import { ILoginRegisterFormData } from '@/types/user'
@ -89,10 +87,6 @@
export default defineComponent({ export default defineComponent({
name: 'UserAuthForm', name: 'UserAuthForm',
components: {
AlertMessage,
ErrorMessage,
},
props: { props: {
action: { action: {
type: String, type: String,

View File

@ -42,7 +42,6 @@
import { LineChart, useLineChart } from 'vue-chart-3' import { LineChart, useLineChart } from 'vue-chart-3'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import Card from '@/components/Common/Card.vue'
import { IAuthUserProfile } from '@/types/user' import { IAuthUserProfile } from '@/types/user'
import { import {
IWorkoutChartData, IWorkoutChartData,
@ -54,7 +53,6 @@
export default defineComponent({ export default defineComponent({
name: 'WorkoutChart', name: 'WorkoutChart',
components: { components: {
Card,
LineChart, LineChart,
}, },
props: { props: {

View File

@ -38,8 +38,6 @@
} from 'vue' } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import Card from '@/components/Common/Card.vue'
import Modal from '@/components/Common/Modal.vue'
import WorkoutCardTitle from '@/components/Workout/WorkoutDetail/WorkoutCardTitle.vue' import WorkoutCardTitle from '@/components/Workout/WorkoutDetail/WorkoutCardTitle.vue'
import WorkoutData from '@/components/Workout/WorkoutDetail/WorkoutData.vue' import WorkoutData from '@/components/Workout/WorkoutDetail/WorkoutData.vue'
import WorkoutMap from '@/components/Workout/WorkoutDetail/WorkoutMap.vue' import WorkoutMap from '@/components/Workout/WorkoutDetail/WorkoutMap.vue'
@ -59,8 +57,6 @@
export default defineComponent({ export default defineComponent({
name: 'WorkoutDetail', name: 'WorkoutDetail',
components: { components: {
Card,
Modal,
WorkoutCardTitle, WorkoutCardTitle,
WorkoutData, WorkoutData,
WorkoutMap, WorkoutMap,

View File

@ -219,10 +219,6 @@
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import Card from '@/components/Common/Card.vue'
import CustomTextArea from '@/components/Common/CustomTextArea.vue'
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
import Loader from '@/components/Common/Loader.vue'
import { ROOT_STORE, WORKOUTS_STORE } from '@/store/constants' import { ROOT_STORE, WORKOUTS_STORE } from '@/store/constants'
import { IAppConfig } from '@/types/application' import { IAppConfig } from '@/types/application'
import { ISport } from '@/types/sports' import { ISport } from '@/types/sports'
@ -235,12 +231,6 @@
export default defineComponent({ export default defineComponent({
name: 'WorkoutEdition', name: 'WorkoutEdition',
components: {
Card,
CustomTextArea,
ErrorMessage,
Loader,
},
props: { props: {
authUser: { authUser: {
type: Object as PropType<IAuthUserProfile>, type: Object as PropType<IAuthUserProfile>,

View File

@ -12,13 +12,8 @@
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue' import { defineComponent } from 'vue'
import Card from '@/components/Common/Card.vue'
export default defineComponent({ export default defineComponent({
name: 'WorkoutNotes', name: 'WorkoutNotes',
components: {
Card,
},
props: { props: {
notes: { notes: {
type: String, type: String,

View File

@ -27,14 +27,10 @@
<script lang="ts"> <script lang="ts">
import { PropType, defineComponent } from 'vue' import { PropType, defineComponent } from 'vue'
import Card from '@/components/Common/Card.vue'
import { IWorkoutSegment } from '@/types/workouts' import { IWorkoutSegment } from '@/types/workouts'
export default defineComponent({ export default defineComponent({
name: 'WorkoutSegments', name: 'WorkoutSegments',
components: {
Card,
},
props: { props: {
segments: { segments: {
type: Object as PropType<IWorkoutSegment[]>, type: Object as PropType<IWorkoutSegment[]>,

View File

@ -0,0 +1,17 @@
import AlertMessage from '@/components/Common/AlertMessage.vue'
import Card from '@/components/Common/Card.vue'
import CustomTextArea from '@/components/Common/CustomTextArea.vue'
import Dropdown from '@/components/Common/Dropdown.vue'
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
import Loader from '@/components/Common/Loader.vue'
import Modal from '@/components/Common/Modal.vue'
export const customComponents = [
AlertMessage,
Card,
CustomTextArea,
Dropdown,
ErrorMessage,
Loader,
Modal,
]

View File

@ -6,11 +6,17 @@ import i18n from './i18n'
import router from './router' import router from './router'
import store from './store' import store from './store'
import { customComponents } from '@/custom-components'
import { clickOutsideDirective } from '@/directives' import { clickOutsideDirective } from '@/directives'
createApp(App) const app = createApp(App)
.use(i18n) .use(i18n)
.use(store) .use(store)
.use(router) .use(router)
.directive('click-outside', clickOutsideDirective) .directive('click-outside', clickOutsideDirective)
.mount('#app')
customComponents.forEach((component) => {
app.component(component.name, component)
})
app.mount('#app')

View File

@ -78,7 +78,6 @@
onUnmounted, onUnmounted,
} from 'vue' } from 'vue'
import Loader from '@/components/Common/Loader.vue'
import Timeline from '@/components/Dashboard/Timeline.vue' import Timeline from '@/components/Dashboard/Timeline.vue'
import UserCalendar from '@/components/Dashboard/UserCalendar/index.vue' import UserCalendar from '@/components/Dashboard/UserCalendar/index.vue'
import UserMonthStats from '@/components/Dashboard/UserMonthStats.vue' import UserMonthStats from '@/components/Dashboard/UserMonthStats.vue'
@ -92,7 +91,6 @@
export default defineComponent({ export default defineComponent({
name: 'Dashboard', name: 'Dashboard',
components: { components: {
Loader,
Timeline, Timeline,
UserCalendar, UserCalendar,
UserMonthStats, UserMonthStats,

View File

@ -19,7 +19,6 @@
<script lang="ts"> <script lang="ts">
import { ComputedRef, computed, defineComponent } from 'vue' import { ComputedRef, computed, defineComponent } from 'vue'
import Card from '@/components/Common/Card.vue'
import Statistics from '@/components/Statistics/index.vue' import Statistics from '@/components/Statistics/index.vue'
import NoWorkouts from '@/components/Workouts/NoWorkouts.vue' import NoWorkouts from '@/components/Workouts/NoWorkouts.vue'
import { USER_STORE, SPORTS_STORE } from '@/store/constants' import { USER_STORE, SPORTS_STORE } from '@/store/constants'
@ -30,7 +29,6 @@
export default defineComponent({ export default defineComponent({
name: 'StatisticsView', name: 'StatisticsView',
components: { components: {
Card,
NoWorkouts, NoWorkouts,
Statistics, Statistics,
}, },