-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add: feature setup on script tag #33
Conversation
Hey @echb! As I also use Vue, I switched to the composition API as well with the script setup. It would be a great inspiration for sure to get the idea of flat variables and functions and use them in the components. Does your PR work for you? I can't get a working component out. Anyways, let's get a step further. Example of input/output in current LegoOnce compiling an HTML input component the lego compiler creates a JS output into a file. Input HTML brick in current Lego <template>
<h1>Hello ${ state.planet }</h1>
</template>
<script>
init() {
this.state = { planet: "world" }
}
</script> Ouput JS component in current Lego // Lego version 1.8.3
import { h, Component } from 'https://cdn.jsdelivr.net/gh/Polight/lego@master/dist/lego.min.js'
class Lego extends Component {
get vdom() {
return () => [
h("h1", {}, `${ state.planet }`)
]
}
}
export default class extends Lego {
init() {
this.state = { planet: "world" }
}
} Thinking a a Script SetupNow considering that simple example, here's an example of what we could have as input: <script setup>
const state = { planet: "world" }
</script>
<template>
<section>
<h1>Hello ${ state.planet }</h1>
</section>
</template> Where should we output the js script from the // Lego version 1.8.3
import { h, Component } from 'https://cdn.jsdelivr.net/gh/Polight/lego@master/dist/lego.min.js'
export default class extends Component {
get vdom() {
return () => [
h("h1", {}, `${ state.planet }`)
]
}
} |
Writing in the Exemple goal
This would work and would be easy and clean to implement. My thought would be to have yet another <script import>
import yell from '../utils.js'
</script>
<script setup>
const state = { name: "world" }
function clicked(event) {
alert(`clicked on `, event.target.nodeName)
}
</script>
… That would be a clean solution but not a big fan as a Lego user. Any thoughts? |
The discussion was moved to #34 |
Closing to merge into the v2 branch |
with the
setup
prop inside script tag now you can add script outside class like so and it is not a breaking change 😃Also i was thinking on allow
.vue
files alogside with{{ }}
syntax and get autcomplete help from editor but I think for now it's ok