create-nodality-vue 1.0.0-beta.11 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +1 -1
- package/package.json +1 -1
- package/templates/src/App.vue +15 -33
- package/templates/src/components/HelloWorld.vue +39 -36
package/bin/index.js
CHANGED
package/package.json
CHANGED
package/templates/src/App.vue
CHANGED
@@ -1,43 +1,25 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
2
|
+
<div id="app">
|
3
|
+
<HelloWorld :text="textInstance" v-model:msg="welcomeMessage" />
|
4
|
+
</div>
|
3
5
|
</template>
|
4
6
|
|
5
7
|
<script>
|
6
|
-
import HelloWorld from
|
7
|
-
import {Text} from "nodality";
|
8
|
+
import HelloWorld from "./components/HelloWorld.vue";
|
9
|
+
import { Text } from "nodality";
|
10
|
+
|
8
11
|
export default {
|
9
|
-
name: 'App',
|
10
|
-
components: {
|
11
|
-
HelloWorld
|
12
|
-
},
|
13
|
-
|
14
|
-
watch: {
|
15
|
-
// Watch for changes to welcomeMessage and recreate the instance
|
16
|
-
welcomeMessage() {
|
17
|
-
console.log(this.welcomeMessage) // THIS WORKS
|
18
|
-
this.textInstance = new Text(this.welcomeMessage).set({ size: "S1", color: "#1abc9c" });
|
19
|
-
},
|
20
|
-
},
|
21
12
|
data() {
|
22
13
|
return {
|
23
|
-
welcomeMessage: "Welcome to
|
24
|
-
|
25
|
-
}
|
14
|
+
welcomeMessage: "Welcome to Nodality + Vue.js",
|
15
|
+
textInstance: null,
|
16
|
+
};
|
26
17
|
},
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
created() {
|
19
|
+
this.textInstance = new Text(this.welcomeMessage).set({
|
20
|
+
size: "S1",
|
21
|
+
color: "#1abc9c",
|
22
|
+
});
|
30
23
|
},
|
31
|
-
}
|
24
|
+
};
|
32
25
|
</script>
|
33
|
-
|
34
|
-
<style>
|
35
|
-
#app {
|
36
|
-
font-family: Avenir, Helvetica, Arial, sans-serif;
|
37
|
-
-webkit-font-smoothing: antialiased;
|
38
|
-
-moz-osx-font-smoothing: grayscale;
|
39
|
-
text-align: center;
|
40
|
-
color: #2c3e50;
|
41
|
-
margin-top: 60px;
|
42
|
-
}
|
43
|
-
</style>
|
@@ -1,37 +1,40 @@
|
|
1
|
-
<script setup>
|
2
|
-
import { useTemplateRef, onMounted, defineProps, defineEmits, watch } from 'vue'
|
3
|
-
|
4
|
-
// Define props to accept the msg value
|
5
|
-
const props = defineProps({
|
6
|
-
msg: String,
|
7
|
-
text: Object
|
8
|
-
})
|
9
|
-
|
10
|
-
const emit = defineEmits(['update:msg'])
|
11
|
-
|
12
|
-
// the first argument must match the ref value in the template
|
13
|
-
const input = useTemplateRef('my-input')
|
14
|
-
let mycomp = useTemplateRef('my-comp')
|
15
|
-
|
16
|
-
onMounted(() => {
|
17
|
-
input.value.focus()
|
18
|
-
let ela = props.text.render();//document.createElement("h1");
|
19
|
-
mycomp.value.appendChild(ela);
|
20
|
-
})
|
21
|
-
|
22
|
-
watch(() => props.msg, () => { // 12:21:57 Wow!!!
|
23
|
-
|
24
|
-
mycomp.value.innerHTML = ""; // Clear existing content
|
25
|
-
const element = props.text.render(); // Call the render method
|
26
|
-
mycomp.value.appendChild(element);
|
27
|
-
})
|
28
|
-
|
29
|
-
function updateMessage(event) {
|
30
|
-
emit('update:msg', event.target.value)
|
31
|
-
}
|
32
|
-
</script>
|
33
|
-
|
34
1
|
<template>
|
35
|
-
<
|
36
|
-
<
|
37
|
-
|
2
|
+
<div>
|
3
|
+
<input v-model="message" @input="updateText" placeholder="Edit me" />
|
4
|
+
<div ref="renderedText" />
|
5
|
+
</div>
|
6
|
+
</template>
|
7
|
+
|
8
|
+
<script>
|
9
|
+
export default {
|
10
|
+
props: {
|
11
|
+
text: Object,
|
12
|
+
msg: String,
|
13
|
+
},
|
14
|
+
data() {
|
15
|
+
return {
|
16
|
+
message: this.msg || "",
|
17
|
+
};
|
18
|
+
},
|
19
|
+
watch: {
|
20
|
+
message(newValue) {
|
21
|
+
this.$emit("update:msg", newValue);
|
22
|
+
},
|
23
|
+
},
|
24
|
+
mounted() {
|
25
|
+
this.renderText();
|
26
|
+
},
|
27
|
+
updated() {
|
28
|
+
this.renderText();
|
29
|
+
},
|
30
|
+
methods: {
|
31
|
+
updateText(event) {
|
32
|
+
this.text.set({ text: event.target.value }).render(this.$refs.renderedText);
|
33
|
+
},
|
34
|
+
renderText() {
|
35
|
+
this.$refs.renderedText.innerHTML = "";
|
36
|
+
this.text.render(this.$refs.renderedText);
|
37
|
+
},
|
38
|
+
},
|
39
|
+
};
|
40
|
+
</script>
|