Skip to content

Commit c3df7f0

Browse files
committed
add readme and license
1 parent 28129b2 commit c3df7f0

File tree

2 files changed

+233
-9
lines changed

2 files changed

+233
-9
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Maurizio Bonani
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+212-9
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,230 @@
1-
# vue-blocks
1+
## Vue-Blocks
22

3-
> Vue2
3+
### Basic usage
4+
5+
``` html
6+
<template>
7+
<div id="app">
8+
<VueBlocksContainer
9+
ref="container"
10+
:blocksContent="blocks"
11+
:scene.sync="scene"
12+
class="container"/>
13+
</div>
14+
</template>
15+
16+
<script>
17+
import VueBlocksContainer from '...path.../vue-blocks/src'
18+
19+
export default {
20+
name: 'App',
21+
components: {
22+
VueBlocksContainer
23+
},
24+
data: function () {
25+
return {
26+
blocks: [
27+
{
28+
name: 'test',
29+
title: 'Test block',
30+
family: 'Test',
31+
description: 'Description text',
32+
fields: [
33+
{
34+
name: 'in1',
35+
type: 'event',
36+
attr: 'input'
37+
},
38+
{
39+
name: 'in2',
40+
type: 'event',
41+
attr: 'input'
42+
},
43+
{
44+
name: 'out1',
45+
type: 'event',
46+
attr: 'output'
47+
},
48+
{
49+
name: 'out2',
50+
type: 'event',
51+
attr: 'output'
52+
}
53+
]
54+
}
55+
],
56+
scene: {
57+
blocks: [
58+
{
59+
id: 1,
60+
x: 0,
61+
y: 0,
62+
name: 'test',
63+
title: 'Test block',
64+
values: {
65+
property: [
66+
{
67+
name: 'message',
68+
type: 'string'
69+
}
70+
]
71+
}
72+
},
73+
{
74+
id: 2,
75+
x: 0,
76+
y: 50,
77+
name: 'test',
78+
title: 'Test block 2',
79+
values: {
80+
property: [
81+
{
82+
name: 'message',
83+
type: 'string'
84+
}
85+
]
86+
}
87+
}
88+
],
89+
links: [],
90+
container: {
91+
centerX: 0,
92+
centerY: 0,
93+
scale: 1
94+
}
95+
}
96+
}
97+
}
98+
}
99+
</script>
100+
101+
102+
<style>
103+
html, body {
104+
margin: 0;
105+
padding: 0;
106+
}
107+
108+
html {
109+
width: 100vw;
110+
height: 100vh;
111+
}
112+
113+
body,
114+
#app,
115+
.container {
116+
width: 100%;
117+
height: 100%;
118+
}
119+
</style>
120+
```
121+
122+
### Props
123+
124+
#### blocksContent
125+
126+
Type: `Array.<Node>`<br>
127+
Required: `true`<br>
128+
Default: `[]`
129+
130+
Object `Node`:
131+
```
132+
{
133+
name: 'name-node',
134+
title: 'Title node',
135+
family: 'family - just for grouping',
136+
description: 'Description text',
137+
fields: Array.<NodeField>
138+
}
139+
```
140+
141+
Object `NodeField`:
142+
```
143+
{
144+
name: 'name',
145+
type: 'type-name', // not used
146+
attr: 'attribute' // input/output or custom
147+
'other': - for custom
148+
}
149+
```
150+
151+
Custom attributes are available in `scene.blocks[index].values.YourAttrName`
152+
153+
#### scene
154+
155+
Type: `Object`<br>
156+
Required: `false`<br>
157+
Default:
158+
```
159+
{
160+
blocks: [],
161+
links: [],
162+
container: {}
163+
}
164+
```
165+
166+
Object `Scene`:
167+
```
168+
{
169+
blocks: Array.<Block>,
170+
links: Array.<BlockLinks>,
171+
container: {
172+
centerX: number
173+
centerY: number
174+
scale: number
175+
}
176+
}
177+
```
178+
179+
Object `Block`:
180+
```
181+
{
182+
id: number,
183+
x: number,
184+
y: number,
185+
name: string,
186+
title: string,
187+
values: {
188+
customAttribute: [ // show "NodeField"
189+
name: NodeField (without name and attr fields)
190+
]
191+
}
192+
}
193+
```
194+
195+
Object `BlockLinks`:
196+
```
197+
{
198+
id: number, // ID
199+
originID: number, // Origin block ID
200+
originSlot: number, // Origin block slot number
201+
targetID: number, // Target block ID
202+
targetSlot: number // Target block slot number
203+
}
204+
```
4205

5206
## Build Setup
6207

7208
``` bash
8209
# install dependencies
9-
npm install
210+
yarn
10211

11212
# serve with hot reload at localhost:8080
12-
npm run dev
213+
yarn dev
13214

14215
# build for production with minification
15-
npm run build
216+
yarn run build
16217

17218
# build for production and view the bundle analyzer report
18-
npm run build --report
219+
yarn run build --report
19220

20221
# run unit tests
21-
npm run unit
222+
yarn run unit
22223

23224
# run all tests
24-
npm test
225+
yarn test
25226
```
26227

27-
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
228+
## License
229+
230+
[MIT license](LICENSE)

0 commit comments

Comments
 (0)