-
Notifications
You must be signed in to change notification settings - Fork 0
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
Armin Jazi
committed
May 7, 2024
1 parent
631437c
commit bb9cb9a
Showing
1 changed file
with
37 additions
and
4 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,5 +1,38 @@ | ||
import { createApp } from 'vue' | ||
import './style.css' | ||
import App from './App.vue' | ||
import "@openreply/pattern-library/styles"; | ||
import "@obi-dbs/customer-ui-components/styles"; | ||
|
||
createApp(App).mount('#app') | ||
import { App as VueApp, createApp } from "vue"; | ||
|
||
import App from "./App.vue"; | ||
const elementName = "page-module-share-vue"; | ||
class PageModuleShareVue extends HTMLElement { | ||
private app: VueApp | null = null; | ||
private mountPoint: HTMLElement | null = null; | ||
|
||
static get observedAttributes() { | ||
return ["user-type"]; | ||
} | ||
|
||
connectedCallback() { | ||
this.mountPoint = document.querySelector(elementName); | ||
this.setup(); | ||
} | ||
|
||
setup() { | ||
if (this.app) this.app.unmount(); | ||
|
||
if (this.mountPoint) { | ||
this.app = createApp(App); | ||
this.app.mount(this.mountPoint); | ||
console.log("page-module-share-vue: Mounted"); | ||
} else { | ||
console.log("page-module-share-vue: Mount point not found"); | ||
} | ||
} | ||
} | ||
|
||
if (!window.customElements.get(elementName)) { | ||
window.customElements.define(elementName, PageModuleShareVue); | ||
} else { | ||
console.warn(`${elementName}: Custom element already defined`); | ||
} |