Skip to content

Commit

Permalink
Vue: Add Form/Html template components
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Sep 14, 2022
1 parent 2dc7254 commit 48e3af9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
44 changes: 44 additions & 0 deletions code/renderers/vue/template/components/Form.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<form id="interaction-test-form" @submit.prevent="onSubmit">
<label>
Enter Value
<input type="text" data-testid="value" :value="value" required @click="setValue" />
</label>
<button type="submit">Submit</button>
<p v-if="complete">Completed!!</p>
</form>
</template>

<script>
export default {
name: 'my-form',
props: {
onSuccess: {
type: Function,
},
},
data() {
return {
value: '',
complete: false,
};
},
methods: {
setValue(event) {
this.value = event.target.value;
},
onSubmit() {
this.onSuccess(this.value);
setTimeout(() => {
this.complete = true;
}, 500);
setTimeout(() => {
this.complete = false;
}, 1500);
},
},
};
</script>
17 changes: 17 additions & 0 deletions code/renderers/vue/template/components/Html.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div v-html="content"></div>
</template>

<script>
export default {
name: 'my-html',
props: {
content: {
type: String,
required: true,
},
},
};
</script>
4 changes: 3 additions & 1 deletion code/renderers/vue/template/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import globalThis from 'global';

import Button from './Button.vue';
import Pre from './Pre.vue';
import Form from './Form.vue';
import Html from './Html.vue';

globalThis.Components = { Button, Pre };
globalThis.Components = { Button, Pre, Form, Html };

0 comments on commit 48e3af9

Please sign in to comment.