This repository has been archived on 2021-09-06. You can view files and clone it, but cannot push or open issues or pull requests.
vuejs_course/2021-02-08 prj-cmp-01-start.../src/components/resources/AddResource.vue

79 lines
1.5 KiB
Vue

<template>
<base-card>
<form @submit.prevent="returnNewResource">
<div class="form-control">
<label for="title">Title</label>
<input type="text" name="title" id="title" v-model="title" />
</div>
<div class="form-control">
<label for="description">Description</label>
<textarea
name="description"
id="description"
rows="3"
v-model="description"
></textarea>
</div>
<div class="form-control">
<label for="link">Link</label>
<input type="text" name="link" id="link" v-model="link" />
</div>
<div>
<base-button type="submit">Add Resource</base-button>
</div>
</form>
</base-card>
</template>
<script>
export default {
emits: ['new-resource'],
data() {
return {
title: '',
description: '',
link: ''
};
},
methods: {
returnNewResource() {
const resource = {
id: this.title,
title: this.title,
description: this.description,
link: this.link
};
this.$emit('new-resource', resource);
}
}
};
</script>
<style scoped>
label {
font-weight: bold;
display: block;
margin-bottom: 0.5rem;
}
input,
textarea {
display: block;
width: 100%;
font: inherit;
padding: 0.15rem;
border: 1px solid #ccc;
}
input:focus,
textarea:focus {
outline: none;
border-color: #3a0061;
background-color: #f7ebff;
}
.form-control {
margin: 1rem 0;
}
</style>