-
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(vue3): wip avoid register x store modules dynamically
- Loading branch information
1 parent
8ec5a20
commit 639835a
Showing
8 changed files
with
168 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,13 @@ | ||
import Vue from 'vue'; | ||
import App from './App.vue'; | ||
import { setupDevtools } from './plugins/devtools/devtools.plugin'; | ||
import router from './router'; | ||
import { platformAdapter } from '@empathyco/x-adapter-platform'; | ||
import { baseInstallXOptions, baseSnippetConfig } from './views/base-config'; | ||
import Vue3 from './vue3.vue'; | ||
import { XInstaller } from './x-installer/x-installer/x-installer'; | ||
import { FilterEntityFactory } from './x-modules/facets/entities/filter-entity.factory'; | ||
import { SingleSelectModifier } from './x-modules/facets/entities/single-select.modifier'; | ||
import { StickyModifier } from './x-modules/facets/entities/sticky.modifier'; | ||
import './tailwind/index.css'; | ||
|
||
// Vue.config.productionTip = false; | ||
FilterEntityFactory.instance.registerModifierByFacetId('age_facet', SingleSelectModifier); | ||
FilterEntityFactory.instance.registerModifierByFacetId( | ||
'brand_facet', | ||
StickyModifier, | ||
SingleSelectModifier | ||
); | ||
FilterEntityFactory.instance.registerModifierByFacetId('price', SingleSelectModifier); | ||
FilterEntityFactory.instance.registerModifierByFilterModelName( | ||
'HierarchicalFilter', | ||
SingleSelectModifier | ||
); | ||
window.initX = baseSnippetConfig; | ||
|
||
const installer = new XInstaller({ | ||
new XInstaller({ | ||
...baseInstallXOptions, | ||
app: App, | ||
vueOptions: { | ||
router | ||
}, | ||
domElement: '#app', | ||
onCreateApp: initDevtools | ||
}); | ||
|
||
if (window.initX) { | ||
installer.init(); | ||
} else { | ||
installer.init(baseSnippetConfig).then(({ app }) => { | ||
app.use(router); | ||
}); | ||
} | ||
|
||
/** | ||
* If an app is provided, initialise the devtools. | ||
* | ||
* @param app - The root Vue instance of the application. | ||
*/ | ||
function initDevtools(app: any): void { | ||
if (process.env.NODE_ENV !== 'production') { | ||
setupDevtools(app); | ||
} | ||
} | ||
adapter: platformAdapter, | ||
app: Vue3, | ||
domElement: '#app' | ||
}).init(); |
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
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,54 @@ | ||
<template> | ||
<SnippetConfigExtraParams :values="initialExtraParams" /> | ||
<UrlHandler query="q" store="store" /> | ||
<OpenMainModal>Start</OpenMainModal> | ||
<MainModal> | ||
<SearchInput /> | ||
<ClearSearchInput /> | ||
<SortPickerList :items="sortValues" #default="{ item }"> | ||
{{ item || 'default' }} | ||
</SortPickerList> | ||
|
||
<Facets #default="{ facet }"> | ||
<strong>{{ facet.label }}</strong> | ||
<span v-for="filter in facet.filters" style="font-size: 8px">{{ filter.label }}//</span> | ||
</Facets> | ||
|
||
<ResultsList> | ||
<BaseVariableColumnGrid :columns="12"> | ||
<template #result="{ item: result }"> | ||
<BaseResultImage :result="result" /> | ||
<span>{{ result.name }}</span> | ||
<span>{{ result.price.value }}€</span> | ||
</template> | ||
</BaseVariableColumnGrid> | ||
</ResultsList> | ||
</MainModal> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useStore } from 'vuex'; | ||
import BaseVariableColumnGrid from './components/base-variable-column-grid.vue'; | ||
import MainModal from './components/modals/main-modal.vue'; | ||
import OpenMainModal from './components/modals/open-main-modal.vue'; | ||
import SnippetConfigExtraParams from './x-modules/extra-params/components/snippet-config-extra-params.vue'; | ||
import Facets from './x-modules/facets/components/facets/facets.vue'; | ||
import ClearSearchInput from './x-modules/search-box/components/clear-search-input.vue'; | ||
import SearchInput from './x-modules/search-box/components/search-input.vue'; | ||
import ResultsList from './x-modules/search/components/results-list.vue'; | ||
import BaseResultImage from './components/result/base-result-image.vue'; | ||
import SortPickerList from './x-modules/search/components/sort-picker-list.vue'; | ||
import UrlHandler from './x-modules/url/components/url-handler.vue'; | ||
const initialExtraParams = { store: 'Portugal' }; | ||
const sortValues = ['', 'price asc', 'price desc']; | ||
const store = useStore(); | ||
store.commit('x/increment'); | ||
</script> | ||
|
||
<style> | ||
ul { | ||
padding: 0; | ||
} | ||
</style> |
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
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