Skip to content

Commit 1dbcf77

Browse files
author
Dino Fancellu
committed
Upgraded to vue 2.6.10, scala 2.12.8, scala.js 0.6.28
1 parent da22e66 commit 1dbcf77

File tree

10 files changed

+72
-87
lines changed

10 files changed

+72
-87
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ Network Trash Folder
4242
Temporary Items
4343
.apdisk
4444
/bin/
45+
target/
46+
/.idea/

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ language: scala
22
script:
33
- sbt fullOptJS
44
scala:
5-
- 2.11.8
5+
- 2.12.8

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This should
2222
download dependencies and prepare the relevant javascript files. It then kicks off a web server to serve the html and JS files.
2323

2424
If you open
25-
[localhost:12345/target/scala-2.11/classes/index-dev.html](http://localhost:12345/target/scala-2.11/classes/index-dev.html) in your browser, it will show you a sample app, doing various bindings and Scala code. Its not meant to be pretty, simply instructive. Do open the Console to see debug messages.
25+
[localhost:12345/target/scala-2.12/classes/index-dev.html](http://localhost:12345/target/scala-2.12/classes/index-dev.html) in your browser, it will show you a sample app, doing various bindings and Scala code. Its not meant to be pretty, simply instructive. Do open the Console to see debug messages.
2626

2727
## Demo
2828

@@ -40,10 +40,6 @@ of the final application, useful for final publication. You may well need to cop
4040

4141
<script type="text/javascript" src="../scala-js-vue-js-example-opt.js"></script>
4242

43-
## Eclipse integration
44-
45-
If you want to edit in Eclipse (can't compile yet, but still very useful having full IDE with code completion), just run `sbt eclipse` the open the generated .project file inside eclipse. Keep sbt running in order to do the JS Compile. [https://github.com/typesafehub/sbteclipse/wiki](https://github.com/typesafehub/sbteclipse/wiki)
46-
4743
## Status
4844

4945
This is just a quick proof of concept and some bindings for those wanting to use Vue.js from Scala.js. Feel free to get in contact with any issues etc.

build.sbt

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
import com.lihaoyi.workbench.Plugin._
2-
3-
enablePlugins(ScalaJSPlugin)
4-
5-
workbenchSettings
1+
enablePlugins(ScalaJSPlugin, WorkbenchPlugin)
62

73
name := "Scala.js+Vue.js example"
84

9-
version := "2.2.4"
5+
version := "2.6.10"
106

11-
scalaVersion := "2.11.8"
7+
scalaVersion := "2.12.8"
128

139
libraryDependencies ++= Seq(
14-
"org.scala-js" %%% "scalajs-dom" % "0.9.1"
10+
"org.scala-js" %%% "scalajs-dom" % "0.9.7"
1511
)
1612

17-
bootSnippet := ""
18-
19-
updateBrowsers <<= updateBrowsers.triggeredBy(fastOptJS in Compile)
20-

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.7
1+
sbt.version=1.2.8

project/plugins.sbt

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
1+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.28")
22

3-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.14")
4-
5-
addSbtPlugin("com.lihaoyi" % "workbench" % "0.2.3")
3+
addSbtPlugin("com.lihaoyi" % "workbench" % "0.4.1")

src/main/resources/index-dev.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,19 @@
8282
</div>
8383

8484

85-
<script src='https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.4/vue.min.js'></script>
85+
<script src='https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js'></script>
8686
<div id="mydiv"></div>
8787

8888
<script type="text/javascript" src="../scala-js-vue-js-example-fastopt.js"></script>
89-
<script>
9089

9190
<!-- vue end -->
91+
<script>
92+
9293
// custom filter to pull out field
9394
// Now done in Scala.
9495

9596
// we get DemoVue back from Scala, then use it
96-
var demo=example.Todo().main();
97+
var demo=example.Todo.main();
9798

9899
demo.todos.push({done:false,content:"Extra task"})
99100

src/main/resources/index-opt.html

+49-57
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,22 @@
1818
color: #7f8c8d;
1919
text-decoration: line-through;
2020
}
21-
22-
.bounce-enter {
23-
animation: bounce-in .5s;
24-
}
25-
.bounce-leave {
26-
animation: bounce-out .5s;
27-
}
28-
@keyframes bounce-in {
29-
0% {
30-
transform: scale(0);
31-
}
32-
50% {
33-
transform: scale(1.2);
34-
}
35-
100% {
36-
transform: scale(1);
21+
.bar {
22+
transition: width 0.5s;
23+
-webkit-transition: width 0.5s;
24+
-moz-transition: width 0.5s;
25+
-o-transition: width 0.5s;
26+
height: 20px;
27+
background: black;
28+
}
29+
30+
.fade-enter-active, .fade-leave-active {
31+
transition: opacity .5s
3732
}
38-
}
39-
@keyframes bounce-out {
40-
0% {
41-
transform: scale(1);
42-
}
43-
100% {
44-
transform: scale(0);
33+
.fade-enter, .fade-leave-to /* .fade-leave-active in <2.1.8 */ {
34+
opacity: 0
4535
}
46-
}
36+
4737
</style>
4838
</head>
4939
<body>
@@ -52,60 +42,62 @@
5242
<div id="demo">
5343
<div style="float:left;height:400px;overflow: auto;">
5444
Title=<input v-model="title"/>
55-
<ol>
56-
<li v-transition="bounce" v-repeat="todos">
57-
<span v-on="click: done = !done" class="{{done ? 'done' : ''}}">
58-
{{content}}
59-
</span>
60-
<button v-on="click:remove($index)">Remove</button>
61-
</li>
62-
</ol>
45+
46+
<transition-group name="fade" tag="ol">
47+
<li v-for="(todo,index) in todos" :key="todo">
48+
<span @click="todo.done = !todo.done" :class="{done: todo.done}">
49+
{{todo.content}}
50+
<button @click="remove(index)">Remove</button>
51+
</span>
52+
</li>
53+
</transition-group>
54+
6355
Tasks# {{todos.length}}<BR/>
6456
N={{n}}<BR/>
6557
</div>
6658
<div style="padding-left:30px;height:400px;overflow: auto;width:30%"><pre>data JSON: {{$data | json 2}}</pre></div>
6759

6860
<div style="clear:left">
6961
Using a v-text directive title=<span v-text="title"></span>
62+
<div>Smooth CSS animation:
63+
<input type="button" value="+" @click="barValue += 50"/>
64+
<input type="button" value="-" @click="barValue -= 50">
65+
</div>
66+
<div class="bar" :style="{ width: barValue + 'px' }"></div>
7067
<div v-text="'Using a v-text directive with inline expression, title='+title"></div>
7168
<div>Title reversed={{title | reverse}}</div>
72-
<div>Title wrapper={{title | wrap '<<' '>>'}}</div>
73-
<div v-my-directive="myarg:title">xx</div>
74-
<my-component my-msg="hello">Special content</my-component>
75-
76-
<button v-on="click:clickHandler">Call clickHandler in Scala</button>
77-
<button v-on="click:n++">Increment N</button>
78-
79-
<button v-on="click:addTask">Add Task</button>
80-
<button v-on="click:change1st">Change 1st</button>
81-
<button v-on="click:remove(0,$event)">Remove 1st</button>
82-
<button v-on="click:flipAll">Flip All</button><BR/><BR/>
83-
Via custom filter <select v-model="selected" options="todos | extract 'content'"></select>
84-
Via computed property<select v-model="selected" options="todosFiltered"></select>
69+
<div>Title wrapper={{title | wrap('<<','>>')}}</div>
70+
<div v-mydirective="title">xx</div>
71+
<my-component my-msg="hello">Special content</my-component>
72+
<!---->
73+
<button @click="clickHandler">Call clickHandler in Scala</button>
74+
<button @click="n++">Increment N</button>
75+
<!---->
76+
<button @click="addTask">Add Task</button>
77+
<button @click="change1st">Change 1st</button>
78+
<button @click="remove(0)">Remove 1st</button>
79+
<button @click="flipAll">Flip All</button><BR/><BR/>
80+
Todos computed: {{ todosComputed }}
8581
</div>
8682
</div>
8783

8884

89-
<script src='http://cdnjs.cloudflare.com/ajax/libs/vue/0.12.14/vue.min.js'></script>
85+
<script src='https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js'></script>
9086
<div id="mydiv"></div>
9187

9288
<script type="text/javascript" src="../scala-js-vue-js-example-fastopt.js"></script>
93-
<script>
9489

9590
<!-- vue end -->
91+
<script>
92+
9693
// custom filter to pull out field
97-
// should see if I can do this on Scala side TODO
98-
Vue.filter('extract', function (value, keyToExtract) {
99-
return value.map(function (item) {
100-
return item[keyToExtract]
101-
})
102-
})
94+
// Now done in Scala.
95+
10396
// we get DemoVue back from Scala, then use it
104-
var demo=example.Todo().main();
105-
demo.title="Todo Todo Todo"
97+
var demo=example.Todo.main();
98+
10699
demo.todos.push({done:false,content:"Extra task"})
107-
//demo.todos[0]=({done:false,content:"!!!!"})
108-
//demo.todos.$set(0, {done:false,content:"!!!!"})
100+
109101
</script>
110102

111103
</body>

src/main/scala/com/felstar/scalajs/vue/Vue.scala

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import scala.scalajs.js
44
import org.scalajs.dom
55
import org.scalajs.dom._
66

7-
import js.annotation.JSName
7+
import js.annotation._
88

99
@js.native
10+
@JSGlobal
1011
class Vue extends js.Object {
1112
def this(obj: js.Any) = this()
1213
// instance properties
@@ -65,11 +66,13 @@ import js.annotation.JSName
6566
}
6667

6768
@js.native
69+
@JSGlobal
6870
class Unwatch extends js.Object {
6971
def unwatch:Unit =js.native
7072
}
7173

7274
@js.native
75+
@JSGlobal
7376
object Vue extends js.Object{
7477
def config:js.Dynamic=js.native
7578
def extend(obj:js.Any):Vue=js.native
@@ -94,6 +97,7 @@ import js.annotation.JSName
9497
}
9598

9699
@js.native
100+
@JSGlobal
97101
class Directive extends js.Object {
98102
val name:String =js.native
99103
val rawName:String =js.native

src/main/scala/example/Todo.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import js.Dynamic.literal
1010
import com.felstar.scalajs.vue._
1111
import org.scalajs.dom.raw.HTMLElement
1212

13-
import js.annotation.JSName
13+
import js.annotation._
1414

15-
@JSExport
15+
@JSExportTopLevel("example.Todo")
1616
object Todo extends {
1717

1818
@js.native
19-
trait DemoVue extends Vue{
19+
trait DemoVue extends Vue{
2020
var title:String=js.native
2121
var n:Double=js.native
2222
var todos:js.Array[DemoVueTodo]=js.native

0 commit comments

Comments
 (0)