Skip to content

Commit

Permalink
fix: minor housekeeping
Browse files Browse the repository at this point in the history
Signed-off-by: Vinayak Kulkarni <[email protected]>
  • Loading branch information
vinayakkulkarni committed Nov 3, 2022
1 parent 74e8048 commit 34fc857
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
### Installation

```sh
npm i tweakpane v-tweakpane
npm i tweakpane v-tweakpane @tweakpane/plugin-essentials
```

### Build Setup
Expand Down
1 change: 1 addition & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>V-Tweakpane Demo</title>
</head>
Expand Down
15 changes: 15 additions & 0 deletions example/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
"release:auto": "shipjs prepare --yes"
},
"dependencies": {
"@tweakpane/plugin-essentials": "^0.1.5",
"tweakpane": "^3.1.0"
},
"peerDependencies": {
"tweakpane": "^3.1.0",
"@tweakpane/plugin-essentials": "^0.1.5",
"vue": "^3.2.41"
},
"devDependencies": {
Expand Down
37 changes: 6 additions & 31 deletions src/components/VTweakpane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@
<script lang="ts">
import { defineComponent, ref, onMounted, nextTick } from 'vue';
import { Pane } from 'tweakpane';
import * as EssentialsPlugin from '@tweakpane/plugin-essentials';
import type { Ref, PropType } from 'vue';
import type { ButtonProps, TabParams } from '@tweakpane/core';
import type { FolderParams } from 'tweakpane';
import type { PaneConfig } from 'tweakpane/dist/types/pane/pane-config';
type PaneProps = {
title: string;
folders?: FolderParams[];
buttons?: ButtonProps[];
tabs?: TabParams[];
inputs?: { factor?: number; title?: string; color?: string }[];
} & PaneConfig;
export default defineComponent({
name: 'VTweakpane',
props: {
pane: {
type: Object as PropType<PaneProps>,
type: Object as PropType<PaneConfig>,
default: () => {},
required: true,
},
},
setup(props) {
emits: ['on-pane-created'],
setup(props, { emit }) {
// Number of elements to bind the panes
const el: Ref<HTMLElement | null> = ref(null);
Expand All @@ -44,27 +38,8 @@
title: props.pane.title,
expanded: props.pane.expanded,
});
if (props.pane?.inputs && props.pane.inputs.length > 0) {
props.pane.inputs.forEach((input) => {
for (const [key] of Object.entries(input)) {
// @ts-ignore
pane.value?.addInput(input, key);
}
});
}
if (
props.pane?.folders &&
Object.keys(props.pane.folders).length > 0
) {
props.pane.folders.forEach((folder) => {
pane.value?.addFolder(folder);
});
}
if (props.pane?.tabs && Object.keys(props.pane.tabs).length > 0) {
props.pane.tabs.forEach((tab) => {
pane.value?.addTab(tab);
});
}
pane.value.registerPlugin(EssentialsPlugin);
emit('on-pane-created', pane.value);
}
});
});
Expand Down
4 changes: 3 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ export default defineConfig({
include: 'node_modules/**',
},
rollupOptions: {
external: ['vue'],
external: ['vue', 'tweakpane', '@tweakpane/plugin-essentials'],
output: {
exports: 'named',
banner,
strict: true,
sourcemap: true,
globals: {
vue: 'vue',
tweakpane: 'Tweakpane',
'@tweakpane/plugin-essentials': 'TweakpanePluginEssentials',
},
assetFileNames: (assetInfo) => {
if (assetInfo.name === 'style.css') return 'v-tweakpane.css';
Expand Down

0 comments on commit 34fc857

Please sign in to comment.