-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Replace FacetsMixin by useFacets composable (#1462)
- Loading branch information
Showing
16 changed files
with
429 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/_vue3-migration-test/src/x-modules/facets/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as TestFacets } from './test-facets.vue'; |
44 changes: 44 additions & 0 deletions
44
packages/_vue3-migration-test/src/x-modules/facets/components/test-facets.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<template> | ||
<div> | ||
<h2>Facets</h2> | ||
<Facets :renderableFacets="facetsIds.join(',')"> | ||
<template #default="{ facet }"> | ||
<h3>{{ facet.label }}</h3> | ||
<ul> | ||
<li v-for="filter in facet.filters" :key="filter.id"> | ||
<BaseEventButton :events="{ UserClickedAFilter: filter }"> | ||
{{ filter.label }} | ||
<span v-if="filter.selected">✅</span> | ||
</BaseEventButton> | ||
</li> | ||
</ul> | ||
</template> | ||
</Facets> | ||
<h2>SelectedFilters</h2> | ||
<SelectedFilters :facetsIds="facetsIds" alwaysVisible> | ||
<template #default="{ selectedFilters }"> | ||
Selected filters: {{ selectedFilters.length }} | ||
</template> | ||
</SelectedFilters> | ||
<h2>SelectedFiltersList</h2> | ||
<SelectedFiltersList :facetsIds="facetsIds" alwaysVisible> | ||
<template #default="{ filter }">{{ filter.facetId }}: {{ filter.label }}</template> | ||
</SelectedFiltersList> | ||
<h2>ClearFilters</h2> | ||
<ClearFilters :facetsIds="facetsIds" alwaysVisible> | ||
<template #default="{ selectedFilters }"> | ||
Clear filters ({{ selectedFilters.length }} selected) | ||
</template> | ||
</ClearFilters> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import BaseEventButton from '../../../../../x-components/src/components/base-event-button.vue'; | ||
import ClearFilters from '../../../../../x-components/src/x-modules/facets/components/clear-filters.vue'; | ||
import Facets from '../../../../../x-components/src/x-modules/facets/components/facets/facets.vue'; | ||
import SelectedFilters from '../../../../../x-components/src/x-modules/facets/components/lists/selected-filters.vue'; | ||
import SelectedFiltersList from '../../../../../x-components/src/x-modules/facets/components/lists/selected-filters-list.vue'; | ||
const facetsIds = ['gender', 'brand']; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './components'; | ||
export * from './x-module'; |
33 changes: 33 additions & 0 deletions
33
packages/_vue3-migration-test/src/x-modules/facets/x-module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Facet } from '@empathyco/x-types'; | ||
import { createSimpleFacetStub } from '../../../../x-components/src/__stubs__/facets-stubs.factory'; | ||
import { PrivateXModuleOptions } from '../../../../x-components/src/plugins/x-plugin.types'; | ||
import { arrayToObject } from '../../../../x-components/src/utils/array'; | ||
import { FacetsXModule } from '../../../../x-components/src/x-modules/facets/x-module'; | ||
|
||
const facets: Record<Facet['id'], Facet> = { | ||
gender: createSimpleFacetStub('gender', createFilter => [ | ||
createFilter('Men', false), | ||
createFilter('Women', false) | ||
]), | ||
brand: createSimpleFacetStub('brand', createFilter => [ | ||
createFilter('Audi', true), | ||
createFilter('BMW', false) | ||
]), | ||
color: createSimpleFacetStub('color', createFilter => [ | ||
createFilter('red', true), | ||
createFilter('blue', false) | ||
]) | ||
}; | ||
const filters = arrayToObject( | ||
Object.values(facets).flatMap(facet => facet.filters), | ||
'id' | ||
); | ||
|
||
export const facetsXModule: PrivateXModuleOptions<FacetsXModule> = { | ||
storeModule: { | ||
state: { | ||
facets, | ||
filters | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export * from './facets'; | ||
export * from './next-queries'; | ||
export * from './search'; | ||
export { default as TestElementsList } from './test-elements-list.vue'; | ||
export * from './scroll'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 0 additions & 88 deletions
88
packages/x-components/src/x-modules/facets/components/facets.mixin.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.