-
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.
Add migrated facets components into vue3-migration-test
- Loading branch information
Showing
12 changed files
with
124 additions
and
1 deletion.
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/facets/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'; |
16 changes: 16 additions & 0 deletions
16
packages/_vue3-migration-test/src/x-modules/facets/components/facets/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,16 @@ | ||
<template> | ||
<Facets renderableFacets="gender, brand"> | ||
<template #default="{ facet }"> | ||
<h1>{{ facet.label }}</h1> | ||
<ul> | ||
<li v-for="filter in facet.filters" :key="filter.id"> | ||
{{ filter.label }} | ||
</li> | ||
</ul> | ||
</template> | ||
</Facets> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import Facets from '../../../../../../x-components/src/x-modules/facets/components/facets/facets.vue'; | ||
</script> |
3 changes: 3 additions & 0 deletions
3
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,3 @@ | ||
export * from './facets'; | ||
export * from './lists'; | ||
export { default as TestClearFilters } from './test-clear-filters.vue'; |
2 changes: 2 additions & 0 deletions
2
packages/_vue3-migration-test/src/x-modules/facets/components/lists/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,2 @@ | ||
export { default as TestSelectedFilters } from './test-selected-filters.vue'; | ||
export { default as TestSelectedFiltersList } from './test-selected-filters-list.vue'; |
9 changes: 9 additions & 0 deletions
9
..._vue3-migration-test/src/x-modules/facets/components/lists/test-selected-filters-list.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,9 @@ | ||
<template> | ||
<SelectedFiltersList :facetsIds="['gender', 'brand']" alwaysVisible> | ||
<template #default="{ filter }">{{ filter.facetId }}: {{ filter.label }}</template> | ||
</SelectedFiltersList> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import SelectedFiltersList from '../../../../../../x-components/src/x-modules/facets/components/lists/selected-filters-list.vue'; | ||
</script> |
11 changes: 11 additions & 0 deletions
11
...ages/_vue3-migration-test/src/x-modules/facets/components/lists/test-selected-filters.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,11 @@ | ||
<template> | ||
<SelectedFilters :facetsIds="['gender', 'brand']" alwaysVisible> | ||
<template #default="{ selectedFilters }"> | ||
Selected filters: {{ selectedFilters.length }} | ||
</template> | ||
</SelectedFilters> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import SelectedFilters from '../../../../../../x-components/src/x-modules/facets/components/lists/selected-filters.vue'; | ||
</script> |
11 changes: 11 additions & 0 deletions
11
packages/_vue3-migration-test/src/x-modules/facets/components/test-clear-filters.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,11 @@ | ||
<template> | ||
<ClearFilters :facetsIds="['gender', 'brand']" alwaysVisible> | ||
<template #default="{ selectedFilters }"> | ||
Clear filters ({{ selectedFilters.length }} selected) | ||
</template> | ||
</ClearFilters> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import ClearFilters from '../../../../../x-components/src/x-modules/facets/components/clear-filters.vue'; | ||
</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'; |
38 changes: 38 additions & 0 deletions
38
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,38 @@ | ||
import { Facet } from '@empathyco/x-types'; | ||
import { createSimpleFacetStub } from '../../../../x-components/src/__stubs__/facets-stubs.factory'; | ||
import { arrayToObject } from '../../../../x-components/src/utils/array'; | ||
import { | ||
facetsXModule, | ||
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', true) | ||
]), | ||
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 testFacetsXModule: FacetsXModule = { | ||
...facetsXModule, | ||
storeModule: { | ||
...facetsXModule.storeModule, | ||
state: () => ({ | ||
...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 +1,2 @@ | ||
export * from './facets'; | ||
export * from './search'; |