Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit dec4804

Browse files
authored
Merge pull request #144 from agile-ts/vue-integration
Vue integration
2 parents d637fab + f0d50c3 commit dec4804

File tree

20 files changed

+9111
-129
lines changed

20 files changed

+9111
-129
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# my-project
2+
3+
## Project setup
4+
```
5+
yarn install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
yarn serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
yarn build
16+
```
17+
18+
### Lints and fixes files
19+
```
20+
yarn lint
21+
```
22+
23+
### Customize configuration
24+
See [Configuration Reference](https://cli.vuejs.org/config/).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/cli-plugin-babel/preset'
4+
]
5+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "my-project",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint",
9+
"install:agile": "yalc add @agile-ts/core @agile-ts/vue & yarn install"
10+
},
11+
"dependencies": {
12+
"@agile-ts/core": "file:.yalc/@agile-ts/core",
13+
"@agile-ts/vue": "file:.yalc/@agile-ts/vue",
14+
"core-js": "^3.6.5",
15+
"vue": "^2.6.11"
16+
},
17+
"devDependencies": {
18+
"@vue/cli-plugin-babel": "~4.5.0",
19+
"@vue/cli-plugin-eslint": "~4.5.0",
20+
"@vue/cli-service": "~4.5.0",
21+
"babel-eslint": "^10.1.0",
22+
"eslint": "^6.7.2",
23+
"eslint-plugin-vue": "^6.2.2",
24+
"vue-template-compiler": "^2.6.11"
25+
},
26+
"eslintConfig": {
27+
"root": true,
28+
"env": {
29+
"node": true
30+
},
31+
"extends": [
32+
"plugin:vue/essential",
33+
"eslint:recommended"
34+
],
35+
"parserOptions": {
36+
"parser": "babel-eslint"
37+
},
38+
"rules": {}
39+
},
40+
"browserslist": [
41+
"> 1%",
42+
"last 2 versions",
43+
"not dead"
44+
]
45+
}
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8+
<title><%= htmlWebpackPlugin.options.title %></title>
9+
</head>
10+
<body>
11+
<noscript>
12+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13+
</noscript>
14+
<div id="app"></div>
15+
<!-- built files will be auto injected -->
16+
</body>
17+
</html>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<template>
2+
<div id="app">
3+
<img alt="Vue logo" src="./assets/logo.png" />
4+
<p>myState: {{ sharedState.myState }}</p>
5+
<button v-on:click="changeMyState">Change State</button>
6+
<HelloWorld msg="Welcome to Your Vue.js App with AgileTs!" />
7+
</div>
8+
</template>
9+
10+
<script>
11+
import HelloWorld from './components/HelloWorld.vue';
12+
import { MY_STATE } from '@/core';
13+
import { generateId } from '@agile-ts/core';
14+
15+
export default {
16+
name: 'App',
17+
components: {
18+
HelloWorld,
19+
},
20+
data: function () {
21+
return {
22+
...this.bindAgileInstances({
23+
myState: MY_STATE,
24+
}),
25+
};
26+
},
27+
methods: {
28+
changeMyState: function () {
29+
MY_STATE.set(generateId());
30+
},
31+
},
32+
};
33+
</script>
34+
35+
<style>
36+
#app {
37+
font-family: Avenir, Helvetica, Arial, sans-serif;
38+
-webkit-font-smoothing: antialiased;
39+
-moz-osx-font-smoothing: grayscale;
40+
text-align: center;
41+
color: #2c3e50;
42+
margin-top: 60px;
43+
}
44+
</style>
Loading
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<template>
2+
<div class="hello">
3+
<h1>{{ msg }}</h1>
4+
<h3>Simple TODO List</h3>
5+
<input type='text' v-model='currentInput'>
6+
<input type='submit' value='Add' @click='addTodo'>
7+
<div v-for='todo in sharedState.todos' v-bind:key='todo.id' class='todoItem'>
8+
<div>{{todo.name}}</div>
9+
<button @click='removeTodo(todo.id)'>Remove</button>
10+
</div>
11+
12+
</div>
13+
</template>
14+
15+
<script>
16+
import { TODOS } from '@/core';
17+
import { generateId } from '@agile-ts/core';
18+
19+
export default {
20+
name: 'HelloWorld',
21+
props: {
22+
msg: String
23+
},
24+
data: function () {
25+
return {
26+
...this.bindAgileInstances({
27+
todos: TODOS
28+
}),
29+
currentInput: ''
30+
};
31+
},
32+
methods: {
33+
addTodo: function(){
34+
if (this.currentInput === "") return;
35+
36+
// Add new Todo to the Collection based on the current Input
37+
TODOS.collect({ id: generateId(), name: this.currentInput }, [], {
38+
method: "unshift" // to add todo at the beginning of the Collection
39+
});
40+
41+
this.currentInput = '';
42+
},
43+
removeTodo: function(id) {
44+
// Remove Todo at specific primary Key
45+
TODOS.remove(id).everywhere();
46+
}
47+
}
48+
}
49+
</script>
50+
51+
<!-- Add "scoped" attribute to limit CSS to this component only -->
52+
<style scoped>
53+
h3 {
54+
margin: 40px 0 10px 0;
55+
}
56+
57+
.todoItem {
58+
margin-bottom: 10px;
59+
}
60+
</style>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Agile, Logger } from '@agile-ts/core';
2+
import vueIntegration from '@agile-ts/vue';
3+
4+
// Create Agile Instance
5+
export const App = new Agile({
6+
logConfig: { level: Logger.level.DEBUG },
7+
}).integrate(vueIntegration);
8+
9+
// Create State
10+
export const MY_STATE = App.createState('Hello World');
11+
12+
// Create Collection
13+
export const TODOS = App.createCollection({
14+
initialData: [{ id: 1, name: 'Clean Bathroom' }],
15+
}).persist('todos');
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Vue from 'vue';
2+
import App from './App.vue';
3+
4+
Vue.config.productionTip = false;
5+
6+
export default new Vue({
7+
render: (h) => h(App),
8+
}).$mount('#app');

0 commit comments

Comments
 (0)