Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the Vue 3 plugin and component loading syntax #994

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions app/javascript/entrypoints/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,33 @@
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)

import Vue from "vue";
import system from "lux-design-system";
import {createApp} from "vue";
import lux from "lux-design-system";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

import "lux-design-system/dist/style.css";
import eventDateModal from "../components/eventDateModal.vue";
import eventTitleInputWrapper from "../components/eventTitleInputWrapper.vue";
import hoursCalculator from "../components/hoursCalculator.vue";
import travelEstimateForm from "../components/travelEstimateForm.vue";
import travelRequestButton from "../components/travelRequestButton.vue";
import travelRequestDatePickers from "../components/travelRequestDatePickers.vue";
import Rails from '@rails/ujs';
import '../../assets/stylesheets/application.scss';

Vue.use(system);


// create the LUX app and mount it to wrappers with class="lux"
document.addEventListener("DOMContentLoaded", () => {
const elements = document.getElementsByClassName("lux");
for (let i = 0; i < elements.length; i++) {
new Vue({
el: elements[i],
components: {
'event-date-modal': eventDateModal,
'event-title-input-wrapper': eventTitleInputWrapper,
'hours-calculator': hoursCalculator,
'travel-estimate-form': travelEstimateForm,
'travel-request-button': travelRequestButton,
'travel-request-date-pickers': travelRequestDatePickers,
}
});
const app = createApp({});
app.use(lux);
app.component('event-date-modal', eventDateModal)
.component('event-title-input-wrapper', eventTitleInputWrapper)
.component('hours-calculator', hoursCalculator)
.component('travel-estimate-form', travelEstimateForm)
.component('travel-request-button', travelRequestButton)
.component('travel-request-date-pickers', travelRequestDatePickers)
console.log(app);
app.mount(elements[i]);
}
});

Rails.start();
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ export default defineConfig({
RubyPlugin(),
vue()
],
resolve: {
alias: {
'vue': 'vue/dist/vue.esm-bundler',
},
}
})