Skip to content

Commit

Permalink
feat: add NextQueryPreview carousel in results grid (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismmdev committed Aug 10, 2022
1 parent 67906f3 commit 60065ad
Show file tree
Hide file tree
Showing 9 changed files with 35,012 additions and 4,864 deletions.
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"screenshotOnRunFailure": false,
"video": false,
"testFiles": "**/*.feature",
"retries": 1
"retries": 1,
"ignoreTestFiles": ["**/scroll.feature"]
}
39,645 changes: 34,796 additions & 4,849 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"csv:json": "csv-json ./output ./src/i18n/messages"
},
"dependencies": {
"@empathyco/x-adapter": "^8.0.0-alpha.3",
"@empathyco/x-components": "^3.0.0-alpha.148",
"@empathyco/x-adapter-platform": "^1.0.0-alpha.25",
"@empathyco/x-adapter": "^8.0.0-alpha.4",
"@empathyco/x-components": "^3.0.0-alpha.151",
"@empathyco/x-adapter-platform": "^1.0.0-alpha.29",
"@empathyco/x-deep-merge": "^1.3.0-alpha.19",
"@empathyco/x-types": "^10.0.0-alpha.27",
"@empathyco/x-types": "^10.0.0-alpha.30",
"@empathyco/x-utils": "^1.0.0-alpha.5",
"tslib": "~2.3.0",
"vue": "~2.6.14",
Expand All @@ -40,8 +40,8 @@
},
"devDependencies": {
"@cypress/webpack-preprocessor": "~5.11.1",
"@empathyco/eslint-plugin-x": "^2.0.0-alpha.10",
"@empathyco/x-translations": "^1.1.0-alpha.22",
"@empathyco/eslint-plugin-x": "^2.0.0-alpha.11",
"@empathyco/x-translations": "^1.1.0-alpha.23",
"@rollup/plugin-commonjs": "~21.0.1",
"@rollup/plugin-json": "~4.1.0",
"@rollup/plugin-node-resolve": "~13.1.3",
Expand Down
71 changes: 71 additions & 0 deletions src/components/desktop/desktop-next-query-preview.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<NextQueryPreview
#default="{ results, totalResults, suggestion }"
class="x-list x-background--neutral-95 x-list--gap-06 x-padding--06"
:suggestion="nextQuery"
>
<span class="x-title2 x-font-weight--bold">{{ $t('nextQueryPreview.title') }}</span>
<div class="x-list x-list--horizontal x-list--align-center x-list--gap-03">
<span class="x-title3 x-font-weight--bold">
{{
$t('nextQueryPreview.query', {
query: suggestion.query
})
}}
</span>
<span class="x-text">
{{
$t('nextQueryPreview.totalResults', {
totalResults: totalResults
})
}}
</span>
</div>
<BaseGrid
#default="{ item }"
:columns="maxItemsToRender"
:items="results.slice(0, maxItemsToRender)"
class="x-padding--00"
>
<Result :result="item" />
</BaseGrid>
<NextQuery
:suggestion="nextQuery"
class="
x-tag x-tag--pill
x-font-weight--bold
x-margin--left-auto x-margin--right-auto
x-padding--top-04 x-padding--bottom-04 x-padding--right-05 x-padding--left-05
x-font-color--lead
x-border-color--lead
"
>
{{ $t('nextQueryPreview.viewResults', { totalResults }) }}
</NextQuery>
</NextQueryPreview>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { BaseGrid } from '@empathyco/x-components';
import { NextQuery, NextQueryPreview } from '@empathyco/x-components/next-queries';
import { NextQuery as NextQueryModel } from '@empathyco/x-types';
import Result from '../results/result.vue';
@Component({
components: {
BaseGrid,
NextQuery,
NextQueryPreview,
Result
}
})
export default class DesktopNextQueryPreview extends Vue {
// TODO: Remove this and configure NextQueryPreview after doing EX-6819.
@Prop({ default: 4 })
protected maxItemsToRender!: number;
@Prop({ required: true })
protected nextQuery!: NextQueryModel;
}
</script>
99 changes: 99 additions & 0 deletions src/components/mobile/mobile-next-query-preview.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<template>
<NextQueryPreview
#default="{ results, totalResults, suggestion }"
class="
x-list x-list--gap-05
x-background--neutral-95
x-padding--top-06 x-padding--bottom-06
x-margin--top-10 x-margin--bottom-05
"
:suggestion="nextQuery"
>
<span class="x-next-query-preview__title x-title2 x-font-weight--bold">
{{ $t('nextQueryPreview.title') }}
</span>
<div class="x-next-query-preview__header x-list x-list--horizontal x-list--align-center">
<div class="x-list x-list--horizontal x-list--align-baseline x-list--gap-02">
<span class="x-title3 x-font-weight--bold">
{{
$t('nextQueryPreview.query', {
query: suggestion.query
})
}}
</span>
<span class="x-text x-font-size--04">
{{
$t('nextQueryPreview.totalResults', {
totalResults: totalResults
})
}}
</span>
</div>
<NextQuery
:suggestion="nextQuery"
class="x-button x-button--ghost x-padding--00 x-margin--left-auto x-font-weight--bold"
>
{{ $t('nextQueryPreview.viewResults') }}
</NextQuery>
</div>
<SlidingPanel
class="x-background--neutral-95"
:showButtons="false"
:resetOnContentChange="false"
>
<div class="x-list x-list--gap-05">
<Result
v-for="result in results"
:key="result.id"
:result="result"
class="x-next-query-preview__result"
/>
</div>
</SlidingPanel>
</NextQueryPreview>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { SlidingPanel } from '@empathyco/x-components';
import { NextQuery, NextQueryPreview } from '@empathyco/x-components/next-queries';
import { NextQuery as NextQueryModel } from '@empathyco/x-types';
import Result from '../results/result.vue';
@Component({
components: {
NextQuery,
NextQueryPreview,
Result,
SlidingPanel
}
})
export default class MobileNextQueryPreview extends Vue {
@Prop({ required: true })
protected nextQuery!: NextQueryModel;
}
</script>

<style lang="scss">
.x-mobile {
.x-next-query-preview {
margin-inline: calc(-1 * var(--x-size-padding-grid));
&__title {
padding-inline: var(--x-size-padding-grid);
}
&__header {
padding-inline: var(--x-size-padding-grid);
}
&__result {
width: calc(38vw - var(--x-size-gap-list-05));
}
.x-sliding-panel__scroll {
padding-left: var(--x-size-padding-grid);
}
}
}
</style>
22 changes: 14 additions & 8 deletions src/components/search/results/results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
<ResultsList v-if="$x.totalResults" v-infinite-scroll:main-scroll>
<BannersList>
<PromotedsList>
<NextQueriesList
:offset="24"
:frequency="48"
:maxNextQueriesPerGroup="$x.device === 'mobile' ? 6 : 12"
>
<NextQueriesList :offset="24" :frequency="48" :maxNextQueriesPerGroup="1">
<BaseVariableColumnGrid
class="x-grid x-padding--top-00"
:animation="staggeredFadeAndSlide"
Expand All @@ -25,7 +21,8 @@
</MainScrollItem>
</template>
<template #next-queries-group="{ item: { nextQueries } }">
<NextQueriesGroup :nextQueries="nextQueries" />
<MobileNextQueryPreview v-if="$x.device === 'mobile'" :nextQuery="nextQueries[0]" />
<DesktopNextQueryPreview v-else :nextQuery="nextQueries[0]" />
</template>
</BaseVariableColumnGrid>
</NextQueriesList>
Expand All @@ -52,15 +49,17 @@
import { Component } from 'vue-property-decorator';
import { NextQueriesList } from '@empathyco/x-components/next-queries';
import Result from '../../results/result.vue';
import NextQueriesGroup from './next-queries-group.vue';
import DesktopNextQueryPreview from '../../desktop/desktop-next-query-preview.vue';
import MobileNextQueryPreview from '../../mobile/mobile-next-query-preview.vue';
@Component({
components: {
Banner,
BannersList,
BaseVariableColumnGrid,
DesktopNextQueryPreview,
MainScrollItem,
NextQueriesGroup,
MobileNextQueryPreview,
NextQueriesList,
Promoted,
PromotedsList,
Expand All @@ -75,3 +74,10 @@
protected staggeredFadeAndSlide = StaggeredFadeAndSlide;
}
</script>

<style lang="scss">
.x-base-grid__next-queries-group {
grid-column-start: 1;
grid-column-end: -1;
}
</style>
6 changes: 6 additions & 0 deletions src/i18n/messages.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export interface Messages {
nextQueriesGroup: {
message: string;
};
nextQueryPreview: {
title: string;
query: string;
totalResults: string;
viewResults: string;
};
recommendations: {
title: string;
};
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/messages/en.messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
"title": "You may be interested",
"message": "Those who searched for <span class=\"x-text x-text--bold x-font-size--05\">\"{query}\"</span> also viewed:"
},
"nextQueryPreview": {
"title": "Next Queries",
"query": "{query}",
"totalResults": "({totalResults})",
"viewResults": "View all results ({totalResults})"
},
"identifierResults": {
"title": "SKU Search"
},
Expand Down Expand Up @@ -99,6 +105,9 @@
"nextQueriesGroup": {
"message": "Those who searched for <span class=\"x-text x-text--bold\">\"{query}\"</span> also viewed:"
},
"nextQueryPreview": {
"viewResults": "VIEW ALL"
},
"noResults": {
"message": "<span>Sorry but there are no results for <span class=\"x-text x-font-color--neutral-10 x-text--bold\">\"{query}\"</span></span>You may be interested in these products"
},
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/messages/es.messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"nextQueriesGroup": {
"message": "Los que buscaron <span class=\"x-text x-text--bold x-font-size--05\">\"{query}\"</span> también han visto:"
},
"nextQueryPreview": {
"title": "Next Queries",
"query": "{query}",
"totalResults": "({totalResults})",
"viewResults": "Ver todos los resultados ({totalResults})"
},
"recommendations": {
"title": "Top Clicked"
},
Expand Down Expand Up @@ -95,6 +101,9 @@
"nextQueriesGroup": {
"message": "Los que buscaron <span class=\"x-text x-text--bold\">\"{query}\"</span> también han visto:"
},
"nextQueryPreview": {
"viewResults": "VER TODOS"
},
"noResults": {
"message": "<span>No se han encontrado resultados para <span class=\"x-text x-font-color--neutral-10 x-text--bold\">\"{query}\"</span></span>Quizás te interesen estos productos"
},
Expand Down

0 comments on commit 60065ad

Please sign in to comment.