From e3a4f34b05a59006c454e6f4800a02be7075d521 Mon Sep 17 00:00:00 2001 From: Eran Grinberg Date: Thu, 25 Jan 2024 00:41:55 +0100 Subject: [PATCH] REFACTOR | Refactor component structure and update slots with provide/inject --- demo-app-vite/index.html | 10 +- demo-app-webpack/public/index.html | 10 +- demo-app-webpack/src/App.vue | 204 +++++++++++++++-------------- demo-app-webpack/src/AppChild.vue | 64 +++++++++ demo-app-webpack/src/main.js | 14 +- 5 files changed, 192 insertions(+), 110 deletions(-) create mode 100644 demo-app-webpack/src/AppChild.vue diff --git a/demo-app-vite/index.html b/demo-app-vite/index.html index b30adb7..683edfa 100644 --- a/demo-app-vite/index.html +++ b/demo-app-vite/index.html @@ -51,11 +51,11 @@

Custom Event

model-value="v-model-value" > - +
I am a custom named slot
diff --git a/demo-app-webpack/public/index.html b/demo-app-webpack/public/index.html index 89fd1fe..3101a8a 100644 --- a/demo-app-webpack/public/index.html +++ b/demo-app-webpack/public/index.html @@ -78,13 +78,17 @@

Custom Event

model-value="v-model-value" > -

I am a default slot

+ -
I am a custom slot
+
I am a custom named slot
- + - \ No newline at end of file + }), + + methods: { + testEmit() { + this.$emit('customEventTest', + { + testEvent: '123456789', + } + ) + } + }, +} + + diff --git a/demo-app-webpack/src/AppChild.vue b/demo-app-webpack/src/AppChild.vue new file mode 100644 index 0000000..fa738d8 --- /dev/null +++ b/demo-app-webpack/src/AppChild.vue @@ -0,0 +1,64 @@ + + + + diff --git a/demo-app-webpack/src/main.js b/demo-app-webpack/src/main.js index 001dc88..6d9e53a 100644 --- a/demo-app-webpack/src/main.js +++ b/demo-app-webpack/src/main.js @@ -1,4 +1,5 @@ import App from './App.vue'; +import AppChild from './AppChild.vue'; import tailwindStyles from './assets/tailwind.css?raw'; import { createWebHashHistory, createRouter } from "vue-router"; import { createI18n } from 'vue-i18n'; @@ -6,7 +7,7 @@ import { createStore } from 'vuex' import { defaultRoutes} from './main.routes.js' import { store } from './store/index.js' import { defineCustomElement as VueDefineCustomElement, h, createApp, getCurrentInstance } from 'vue'; -import { createWebComponent } from 'vue-web-component-wrapper'; +import { createWebComponent } from '../../package/index.js'; const pluginsWrapper = { install(GivenVue) { @@ -39,3 +40,14 @@ createWebComponent({ disableRemoveStylesOnUnmount: true, }); +createWebComponent({ + rootComponent: AppChild, + elementName: 'my-child-component', + plugins: pluginsWrapper, + cssFrameworkStyles: tailwindStyles, + VueDefineCustomElement, + h, + createApp, + getCurrentInstance, + disableRemoveStylesOnUnmount: true, +});