From 2253034febe1fd66794307f003916f01b03dbdde Mon Sep 17 00:00:00 2001 From: Samantha Kraft Date: Thu, 9 May 2024 13:55:37 -0400 Subject: [PATCH] npm changes and readme updates. npm is now prefered import for this libarary --- README.md | 44 +++++++++---------------------- package.json | 17 ++++-------- src/DashboardPlugin.js | 27 +++++-------------- src/components/SparcDashboard.vue | 4 +-- vite.config.ts | 3 ++- 5 files changed, 29 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 2a3639d..047fc74 100644 --- a/README.md +++ b/README.md @@ -59,47 +59,29 @@ yarn add vue yarn add mitt yarn add sparc-design-system-components-2 ``` -### Adding dependencies to your project +### Importing Dashboard into your project ```js -import { createApp, defineAsyncComponent } from 'vue' -import mitt from 'mitt' -import DesignSystemComponentsPlugin from 'sparc-design-system-components-2' + +import { createApp } from 'vue' import App from './App.vue' -//this allows for dynamically importing components -import { useGlobalVarsStore } from '../node_modules/sparc-dashboard-beta/src/stores/globalVars' -import { createPinia } from 'pinia' +import { createPinia } from 'pinia'; +import 'sparc-dashboard-beta/dist/style.css' +import sparcDesignSystemComponents2Umd from 'sparc-design-system-components-2'; +import {default as SparcDashboard, install as install} from 'sparc-dashboard-beta/dist/index.js' const app = createApp(App); +let piniaInstance = createPinia(); +app.use(piniaInstance); -//import mitt and set as emitter -const emitter = mitt(); -app.provide('emitter', emitter); +install(app, piniaInstance); //call the install method and pass in the app and pinia instance +app.component("SparcDashboard",SparcDashboard) // add the dashboard component to your vue app -//list whichever components you want available and import them dynamically -const componentMap = [ - 'SubjectNav', - 'ImageSelector', - 'ImageViewer', - 'LocationNav', - 'FlatmapViewer', - 'BiolucidaViewer' -] -componentMap.forEach(comp=>{ - const asyncComponent = defineAsyncComponent(() => import(`../node_modules/sparc-dashboard-beta/src/components/${comp}.vue`)); - app.component(comp, asyncComponent); -}) - -app.use(createPinia()); -//add list of components to add componet drop down -const globalVars = useGlobalVarsStore(); -globalVars.componentList = componentMap; - - -app.use(DesignSystemComponentsPlugin); +app.use(sparcDesignSystemComponents2Umd); app.mount('#app'); + ``` # DOCUMENTATION diff --git a/package.json b/package.json index f11e15f..4f365c1 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,15 @@ { "name": "sparc-dashboard-beta", - "version": "0.1.95", + "version": "0.2.0", "author": "Sam Kraft (https://Sparc.Science)", "private": false, "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", - "exports": { - ".": "./dist/index.js", - "./styles.css": "./dist/style.css" - }, - "browser": { - "./styles.css": "./dist/style.css" - }, - "types": "dist/SparcDashboard.d.ts", + "main": "./dist/index.js", "license": "Apache-2.0", "files": [ - "dist" + "dist", + "src/stores", + "tailwind" ], "scripts": { "dev": "vite & yarn tailwindcss -i ./src/assets/base.css -o ./dist/output.css --watch", diff --git a/src/DashboardPlugin.js b/src/DashboardPlugin.js index 7bcb685..ddd61ee 100644 --- a/src/DashboardPlugin.js +++ b/src/DashboardPlugin.js @@ -1,7 +1,6 @@ -import { SparcDashboard } from './components/Index' +import SparcDashboard from './components/SparcDashboard.vue' import "../tailwind/output.css" -import { createPinia } from 'pinia' import { defineAsyncComponent } from 'vue' import mitt from 'mitt' import { useGlobalVarsStore } from './stores/globalVars' @@ -10,13 +9,12 @@ import '../node_modules/sparc-design-system-components-2/dist/style.css'; //for auto install ----------------------------------------------------------------------------------------------------------------- -export default { - install: (app) => { +export function install(app, pinia){ const emitter = mitt(); app.provide('emitter', emitter); //app.config.globalProperties.$emitter = emitter; - app.use(createPinia()); + //app.use(createPinia()); const componentMap = [ 'ImageSelector', @@ -30,23 +28,12 @@ export default { }) //add list of components to add componet drop down - const globalVars = useGlobalVarsStore(); + const globalVars = useGlobalVarsStore(pinia); globalVars.componentList = componentMap; app.component("SparcDashboard", SparcDashboard); - }, -}; -export {SparcDashboard}; -// Auto-install when vue is found (eg. in browser via