Skip to content

Commit

Permalink
chore: add related-tags to the playground
Browse files Browse the repository at this point in the history
  • Loading branch information
lauramargar committed Jun 12, 2024
1 parent b4647cf commit d730f6f
Show file tree
Hide file tree
Showing 9 changed files with 2,998 additions and 8,378 deletions.
2 changes: 1 addition & 1 deletion packages/_vue3-migration-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@vueuse/core": "~10.7.1",
"vue": "^3.4.22",
"vue-router": "^4.3.0",
"vuex": "^4.1.0"
"vuex": "4.0.2"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
Expand Down
19 changes: 16 additions & 3 deletions packages/_vue3-migration-test/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ import { XComponentsAdapter } from '@empathyco/x-types';
import { Component, configureCompat, createApp } from 'vue';
import { createStore } from 'vuex';
import { xPlugin } from '../../x-components/src/plugins/x-plugin';
import { getRelatedTagsStub } from '../../x-components/src/__stubs__/related-tags-stubs.factory';
import App from './App.vue';
import router from './router';
import { facetsXModule, nextQueriesXModule, scrollXModule, searchXModule } from './';
import {
facetsXModule,
nextQueriesXModule,
scrollXModule,
searchXModule,
relatedTagsXModule
} from './';

// Warnings that cannot be solved in Vue 2 (a.k.a. breaking changes) are suppressed
const VUE_COMPAT_MODE = Number(import.meta.env.VITE_VUE_COMPAT_MODE);
Expand All @@ -26,7 +33,12 @@ if (VUE_COMPAT_MODE === 2) {
});
}

const adapter = {} as XComponentsAdapter;
const adapter = {
relatedTags: () =>
new Promise(resolve => {
resolve({ relatedTags: getRelatedTagsStub(10) });
})
} as unknown as XComponentsAdapter;

const store = createStore({});

Expand All @@ -40,7 +52,8 @@ createApp(App as Component)
facets: facetsXModule,
nextQueries: nextQueriesXModule,
scroll: scrollXModule,
search: searchXModule
search: searchXModule,
relatedTags: relatedTagsXModule
}
})
.mount('#app');
8 changes: 7 additions & 1 deletion packages/_vue3-migration-test/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
TestHighlight,
TestBaseResultImages,
TestBasePanel,
TestBaseKeyboardNavigation
TestBaseKeyboardNavigation,
TestRelatedTags
} from './';

const routes = [
Expand Down Expand Up @@ -164,6 +165,11 @@ const routes = [
path: '/base-keyboard-navigation',
name: 'TestBaseKeyboardNavigation',
component: TestBaseKeyboardNavigation
},
{
path: '/related-tags',
name: 'RelatedTags',
component: TestRelatedTags
}
];

Expand Down
1 change: 1 addition & 0 deletions packages/_vue3-migration-test/src/x-modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './search';
export * from './search-box';
export { default as TestElementsList } from './test-elements-list.vue';
export * from './scroll';
export * from './related-tags';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as TestRelatedTags } from './test-related-tags.vue';
export * from './x-module';
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<span>
Query:
<b>{{ query }}</b>
</span>
<RelatedTags />
</template>

<script setup>
import RelatedTags from '../../../../x-components/src/x-modules/related-tags/components/related-tags.vue';
import { useGetter } from '../../../../x-components/src/composables/use-getter';
const { query } = useGetter('relatedTags', ['query']);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { RelatedTagsXModule } from '../../../../x-components/src/x-modules/related-tags/x-module';
import { PrivateXModuleOptions } from '../../../../x-components/src/plugins/x-plugin.types';
export const relatedTagsXModule: PrivateXModuleOptions<RelatedTagsXModule> = {
storeModule: {
state: {
query: 'pistacho'
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('testing plugin alias', () => {
popularSearches: undefined,
querySuggestions: undefined,
recommendations: undefined,
relatedTags: undefined,
relatedTags: 'initial', // It is already registered by the `relatedTagsXModule` import itself
search: undefined
},
device: null,
Expand Down
Loading

0 comments on commit d730f6f

Please sign in to comment.