/ Fixed the scope of the nest-loader component

This commit is contained in:
Alexis
2021-03-29 09:33:08 +02:00
parent 6402011ee0
commit 9fca291603
3 changed files with 60 additions and 74 deletions

View File

@@ -1,6 +1,8 @@
<template> <template>
<div class="celestial-list-wrapper"> <div class="celestial-list-wrapper">
<div v-if="celestials && celestials.length > 1">
<celestial-filters v-if="hasFilters" @filter:celestials="filterCelestials" /> <celestial-filters v-if="hasFilters" @filter:celestials="filterCelestials" />
<ul v-if="celestials" class="celestial-list grid no-style"> <ul v-if="celestials" class="celestial-list grid no-style">
<li <li
v-for="(celestial, index) in sortedCelestials" v-for="(celestial, index) in sortedCelestials"
@@ -11,19 +13,26 @@
</li> </li>
</ul> </ul>
</div> </div>
<div v-else>
<nest-loader />
</div>
</div>
</template> </template>
<script> <script>
import { defineComponent } from '@vue/composition-api' import { defineComponent } from '@vue/composition-api'
import CelestialCard from '@/components/celestials/CelestialCard.vue' import CelestialCard from '@/components/celestials/CelestialCard.vue'
import NestLoader from '@/components/NestLoader.vue'
import CelestialFilters from './CelestialFilters.vue' import CelestialFilters from './CelestialFilters.vue'
export default defineComponent({ export default defineComponent({
name: 'CelestialList', name: 'CelestialList',
components: { components: {
CelestialCard, CelestialCard,
CelestialFilters CelestialFilters,
NestLoader
}, },
props: { props: {
celestials: { celestials: {

View File

@@ -1,6 +1,5 @@
<template> <template>
<section class="celestial bg-image"> <section class="celestial bg-image">
<div v-if="celestialLoaded">
<header> <header>
<h1 class="heading-1"> <h1 class="heading-1">
<span>{{ celestial.name }}</span> <span>{{ celestial.name }}</span>
@@ -38,10 +37,6 @@
</div> </div>
</main> </main>
</div> </div>
</div>
<div v-else>
<nest-loader />
</div>
</section> </section>
</template> </template>
@@ -51,20 +46,14 @@ import { fetchCelestial } from '@/api/le-systeme-solaire'
// import { fetchWikipediaExcerpt } from "@/api/wikipedia"; // import { fetchWikipediaExcerpt } from "@/api/wikipedia";
// Global methods // Global methods
import NestLoader from '@/components/NestLoader.vue'
export default { export default {
name: 'Celestial', name: 'Celestial',
components: {
NestLoader
},
data () { data () {
return { return {
celestial: {}, celestial: {},
celestialLoaded: false, celestialLoaded: false
excerpt: '',
error: ''
} }
}, },

View File

@@ -6,16 +6,8 @@
</h1> </h1>
</header> </header>
<div class="section-content"> <div class="section-content">
<div v-if="error">
Une erreur est survenue : {{ error }}
</div>
<div v-if="celestials.length > 1">
<celestials-list :celestials="celestials" /> <celestials-list :celestials="celestials" />
</div> </div>
<div v-else>
<nest-loader />
</div>
</div>
</section> </section>
</template> </template>
@@ -24,20 +16,16 @@
import { fetchCelestials } from '@/api/le-systeme-solaire' import { fetchCelestials } from '@/api/le-systeme-solaire'
// Global methods // Global methods
import CelestialsList from '@/components/celestials/CelestialsList.vue' import CelestialsList from '@/components/celestials/CelestialsList.vue'
import NestLoader from '@/components/NestLoader.vue'
export default { export default {
name: 'Celestials', name: 'Celestials',
components: { components: {
CelestialsList, CelestialsList
NestLoader
}, },
data () { data () {
return { return {
celestials: [], celestials: []
error: ''
} }
}, },