create new Skeleton loading for AIS-Search input when not loaded - better support for on demand customization of the component

This commit is contained in:
Xevion
2020-09-14 16:29:25 -05:00
parent 4b91c11562
commit 427d4c6b4f
2 changed files with 62 additions and 25 deletions

View File

@@ -2,9 +2,7 @@
<div id="app"> <div id="app">
<b-navbar> <b-navbar>
<b-navbar-brand> <b-navbar-brand>
<router-link :to="{ name: 'Home' }" class="no-link"> <router-link :to="{ name: 'Home' }" class="no-link">The Office Quotes</router-link>
The Office Quotes
</router-link>
</b-navbar-brand> </b-navbar-brand>
<b-collapse id="nav-collapse" is-nav> <b-collapse id="nav-collapse" is-nav>
<b-navbar-nav> <b-navbar-nav>
@@ -28,19 +26,14 @@
</b-navbar-nav> </b-navbar-nav>
</b-collapse> </b-collapse>
</b-navbar> </b-navbar>
<ais-instant-search <ais-instant-search index-name="prod_THEOFFICEQUOTES" :search-client="searchClient"
index-name="prod_THEOFFICEQUOTES" :insights-client="insightsClient">
:search-client="searchClient"
:insights-client="insightsClient"
>
<b-container :fluid="true" class="py-2 px-lg-5 px-md-4"> <b-container :fluid="true" class="py-2 px-lg-5 px-md-4">
<b-row class="my-3 pl-1" cols="12"> <b-row class="my-3 pl-1" cols="12">
<b-col lg="3" xl="2" md="12"> <b-col lg="3" xl="2" md="12">
<ais-search-box <ais-search-box @keydown.native="showResults" ref="searchbox" placeholder="Search here…"/>
@keydown.native="showResults" <Skeleton secondary_color="#3e3e3e" border_radius="1px" primary_color="#4A4A4A"
ref="searchbox" :inner_style="{ 'min-height': '35.6px' }"></Skeleton>
placeholder="Search here…"
/>
</b-col> </b-col>
</b-row> </b-row>
<b-row align-h="start" cols="12"> <b-row align-h="start" cols="12">
@@ -52,12 +45,16 @@
</b-col> </b-col>
</b-row> </b-row>
</b-container> </b-container>
<ais-configure :clickAnalytics="true" /> <ais-configure :clickAnalytics="true"/>
</ais-instant-search> </ais-instant-search>
</div> </div>
</template> </template>
<style lang="scss"> <style lang="scss">
.outer-skeleton:not(:first-child) {
display: none;
}
.ais-SearchBox-form { .ais-SearchBox-form {
border: none; border: none;
} }
@@ -85,11 +82,13 @@
import algoliasearch from "algoliasearch/lite"; import algoliasearch from "algoliasearch/lite";
import SeasonList from "./components/SeasonList.vue"; import SeasonList from "./components/SeasonList.vue";
import "instantsearch.css/themes/algolia-min.css"; import "instantsearch.css/themes/algolia-min.css";
import Skeleton from "./components/Skeleton.vue";
export default { export default {
name: "App", name: "App",
components: { components: {
SeasonList, SeasonList,
Skeleton
}, },
data() { data() {
return { return {
@@ -102,12 +101,8 @@ export default {
}, },
methods: { methods: {
showResults() { showResults() {
if ( if (this.$refs.searchbox.currentRefinement !== "" && this.$route.path !== "/search_results")
this.$refs.searchbox.currentRefinement !== "" &&
this.$route.path !== "/search_results"
) {
this.$router.push({name: "SearchResults"}); this.$router.push({name: "SearchResults"});
}
}, },
}, },
}; };

View File

@@ -1,27 +1,32 @@
<template> <template>
<div class="outer-skeleton"> <div class="outer-skeleton">
<div class="skeleton"></div> <div class="skeleton" :class="[animated ? undefined : 'no-animate']" :style="[style, inner_style]"></div>
</div> </div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.skeleton { .skeleton {
background-color: $grey-4;
background-image: linear-gradient(90deg, $grey-4, $grey-6, $grey-4);
animation: 1.25s ease-in-out 0s infinite normal none running SkeletonLoading;
width: 100%; width: 100%;
display: block; display: block;
line-height: 1; line-height: 1;
background-size: 200px 100%; background-size: 200px 100%;
background-repeat: no-repeat; background-repeat: no-repeat;
border-radius: 3px; background-image: linear-gradient(90deg, var(--secondary-color, $grey-4), var(--primary-color, $grey-6), var(--secondary-color, $grey-4));
background-color: var(--secondary-color, $grey-4);
animation: 1.25s ease-in-out 0s infinite normal none running SkeletonLoading;
border-radius: var(--border-radius, 3px);
&.no-animate {
animation: none;
}
} }
.outer-skeleton { .outer-skeleton {
padding: 0.2em 0; padding: 0.2em 0;
} }
@-webkit-keyframes SkeletonLoading { @-webkit-keyframes SkeletonLoading {
0% { 0% {
background-position: 0px 0; background-position: 0 0;
} }
100% { 100% {
background-position: calc(200px + 100%) 0; background-position: calc(200px + 100%) 0;
@@ -41,3 +46,40 @@ span {
font-size: 24px; font-size: 24px;
} }
</style> </style>
<script>
export default {
props: {
inner_style: {
type: String,
default: ''
},
inner_class: {
type: String,
default: ''
},
animated: {
type: Boolean,
default: true
},
border_radius: {
type: String,
},
primary_color: {
type: String,
},
secondary_color: {
type: String,
}
},
computed: {
style() {
return {
'--primary-color': this.primary_color,
'--secondary-color': this.secondary_color,
'--border-radius': this.border_radius
}
}
}
}
</script>