Skip to content

Instantly share code, notes, and snippets.

@zorca
Created January 20, 2021 13:54
Show Gist options
  • Save zorca/8862e14e3c975d36b46ebcb1e28d41da to your computer and use it in GitHub Desktop.
Save zorca/8862e14e3c975d36b46ebcb1e28d41da to your computer and use it in GitHub Desktop.
require("./bootstrap");
// Import modules...
import Vue from "vue";
import {
App as InertiaApp,
plugin as InertiaPlugin,
} from "@inertiajs/inertia-vue";
import { InertiaProgress } from "@inertiajs/progress";
import PortalVue from "portal-vue";
import VueTailwind from 'vue-tailwind'
import {
TInput,
TTextarea,
TSelect,
TRadio,
TCheckbox,
TButton,
TInputGroup,
TCard,
TAlert,
TModal,
TDropdown,
TRichSelect,
TPagination,
TTag,
TRadioGroup,
TCheckboxGroup,
TTable,
TDatepicker,
TToggle,
TDialog,
} from 'vue-tailwind/dist/components';
const settings = {
// Use the following syntax
// {component-name}: {
// component: {importedComponentObject},
// props: {
// {propToOverride}: {newDefaultValue}
// {propToOverride2}: {newDefaultValue2}
// }
// }
't-input': {
component: TInput,
props: {
classes: 'border-2 block w-full rounded text-gray-800'
// ...More settings
}
},
't-textarea': {
component: TTextarea,
props: {
classes: 'border-2 block w-full rounded text-gray-800'
// ...More settings
}
},
't-button': {
component: TButton,
props: {
fixedClasses: 'block px-4 py-2 transition duration-100 ease-in-out focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed',
classes: 'text-white bg-blue-500 border border-transparent shadow-sm rounded hover:bg-blue-600',
variants: {
secondary: 'text-gray-800 bg-white border border-gray-300 shadow-sm hover:text-gray-600',
error: 'text-white bg-red-500 border border-transparent rounded shadow-sm hover:bg-red-600',
success: 'text-white bg-green-500 border border-transparent rounded shadow-sm hover:bg-green-600',
link: 'text-blue-500 underline hover:text-blue-600'
}
}
},
// ...Rest of the components
}
Vue.use(VueTailwind, settings)
Vue.mixin({ methods: { route } });
Vue.use(InertiaPlugin);
Vue.use(PortalVue);
InertiaProgress.init();
const app = document.getElementById("app");
new Vue({
render: (h) =>
h(InertiaApp, {
props: {
initialPage: JSON.parse(app.dataset.page),
resolveComponent: (component) => {
let componentParts = component.split(':')
let componentType = componentParts[0]
let componentVendor = componentParts[1]
let componentName = componentParts[2]
if (componentType === 'Package') {
return require(`./Packages/${componentVendor}`).default
}
return require(`./Pages/${component}`).default
},
},
}),
}).$mount(app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment