Skip to content

Commit

Permalink
test: orchestration test
Browse files Browse the repository at this point in the history
  • Loading branch information
CachedaCodes committed Nov 14, 2023
1 parent 3f20aed commit 3adb058
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 67 deletions.
75 changes: 8 additions & 67 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,86 +1,27 @@
<template>
<div class="x" data-test="x" :dir="documentDirection">
<SnippetConfigExtraParams />
<SnippetCallbacks />
<Tagging />
<UrlHandler />
<ExperienceControls />
<MainModal v-if="isOpen" />
</div>
<Orchestrator v-if="start" />
</template>

<script lang="ts">
import { SnippetCallbacks, SnippetConfig, XOn, XProvide } from '@empathyco/x-components';
import { ExperienceControls } from '@empathyco/x-components/experience-controls';
import { Tagging } from '@empathyco/x-components/tagging';
import { QueryPreviewInfo } from '@empathyco/x-components/queries-preview';
import { UrlHandler } from '@empathyco/x-components/url';
import { SnippetConfigExtraParams } from '@empathyco/x-components/extra-params';
import { Component, Inject, Provide, Vue, Watch } from 'vue-property-decorator';
import { useDevice } from './composables/use-device.composable';
import currencies from './i18n/currencies';
import { Component, Vue } from 'vue-property-decorator';
import './tailwind/index.css';
@Component({
components: {
SnippetCallbacks,
SnippetConfigExtraParams,
Tagging,
UrlHandler,
ExperienceControls,
MainModal: () => import('./components/custom-main-modal.vue').then(m => m.default)
Orchestrator: () => import('./components/orchestrator.vue').then(m => m.default)
}
})
export default class App extends Vue {
protected isOpen = false;
protected start = false;
@XOn(['UserOpenXProgrammatically', 'UserClickedOpenX'])
open(): void {
this.isOpen = true;
}
@Inject('snippetConfig')
protected snippetConfig!: SnippetConfig;
protected device = useDevice();
protected get documentDirection(): string {
return (
document.documentElement.dir ||
document.body.dir ||
(this.snippetConfig.documentDirection ?? 'ltr')
);
}
@Provide('currencyFormat')
public get currencyFormat(): string {
return currencies[this.snippetConfig.currency!];
}
@XProvide('queriesPreviewInfo')
public get queriesPreviewInfo(): QueryPreviewInfo[] | undefined {
return this.snippetConfig.queriesPreview;
}
@Watch('snippetConfig.uiLang')
syncLang(uiLang: string): void {
this.$setLocale(uiLang);
}
@Watch('device.deviceName')
syncDevice(deviceName: string): void {
this.$setLocaleDevice(deviceName);
protected mounted(): void {
setTimeout(() => {
this.start = true;
}, 0);
}
}
</script>

<style scoped>
.x-modal::v-deep .x-modal__content {
width: 100%;
height: 100%;
background-color: white;
overflow: auto;
}
</style>
<style lang="scss">
*:not(.x-keyboard-navigation *) {
outline: none;
Expand Down
82 changes: 82 additions & 0 deletions src/components/orchestrator.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<template>
<div class="x" data-test="x" :dir="documentDirection">
<SnippetConfigExtraParams />
<SnippetCallbacks />
<Tagging />
<UrlHandler />
<ExperienceControls />
<MainModal v-if="isOpen" />
</div>
</template>

<script lang="ts">
import { SnippetCallbacks, SnippetConfig, XOn, XProvide } from '@empathyco/x-components';
import { ExperienceControls } from '@empathyco/x-components/experience-controls';
import { Tagging } from '@empathyco/x-components/tagging';
import { QueryPreviewInfo } from '@empathyco/x-components/queries-preview';
import { UrlHandler } from '@empathyco/x-components/url';
import { SnippetConfigExtraParams } from '@empathyco/x-components/extra-params';
import { Component, Inject, Provide, Vue, Watch } from 'vue-property-decorator';
import { useDevice } from '../composables/use-device.composable';
import currencies from '../i18n/currencies';
@Component({
components: {
SnippetCallbacks,
SnippetConfigExtraParams,
Tagging,
UrlHandler,
ExperienceControls,
MainModal: () => import('./custom-main-modal.vue').then(m => m.default)
}
})
export default class Orchestrator extends Vue {
protected isOpen = false;
@XOn(['UserOpenXProgrammatically', 'UserClickedOpenX'])
open(): void {
this.isOpen = true;
}
@Inject('snippetConfig')
protected snippetConfig!: SnippetConfig;
protected device = useDevice();
protected get documentDirection(): string {
return (
document.documentElement.dir ||
document.body.dir ||
(this.snippetConfig.documentDirection ?? 'ltr')
);
}
@Provide('currencyFormat')
public get currencyFormat(): string {
return currencies[this.snippetConfig.currency!];
}
@XProvide('queriesPreviewInfo')
public get queriesPreviewInfo(): QueryPreviewInfo[] | undefined {
return this.snippetConfig.queriesPreview;
}
@Watch('snippetConfig.uiLang')
syncLang(uiLang: string): void {
this.$setLocale(uiLang);
}
@Watch('device.deviceName')
syncDevice(deviceName: string): void {
this.$setLocaleDevice(deviceName);
}
}
</script>

<style scoped>
.x-modal::v-deep .x-modal__content {
width: 100%;
height: 100%;
background-color: white;
overflow: auto;
}
</style>

0 comments on commit 3adb058

Please sign in to comment.