-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f20aed
commit 3adb058
Showing
2 changed files
with
90 additions
and
67 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
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> |