<template>
  <div>
    <div class="row">
      <div class="file-upload">
        <div class="image-upload-wrap">
          <input
            class="file-upload-input"
            type="file"
            @change="$emit('onFileSlected', $event)"
            accept="image/*"
          />
          <div class="drag-text" v-if="imageUrl == ''">
            <span>Please Select Image</span>
          </div>
          <div v-else>
            <img
              class="file-upload-image"
              :src="imageUrl"
              alt="your image"
              style="max-width: 100%; max-height: 92px"
            />
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <div class="input-group mb-3">
          <div class="input-group-prepend">
            <span class="input-group-text" id="basic-addon1">URL</span>
          </div>
          <input
            type="text"
            v-model="imageUrl"
            class="form-control"
            aria-label="Username"
            aria-describedby="basic-addon1"
          />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "ImageSelection",
  props: {
    imageUrl: String,
  },
};
</script>
<style>
.file-upload {
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.file-upload-input {
  position: absolute;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  outline: none;
  opacity: 0;
  cursor: pointer;
}

.image-upload-wrap {
  border: 4px dashed #6c9229;
  position: relative;
  height: 100px;
}

.drag-text {
  text-align: center;
}

.drag-text > span {
  font-weight: 100;
  text-transform: uppercase;
  color: #6c9229;
  line-height: 90px;
  font-size: 20px;
}

.file-upload-image {
  max-height: 200px;
  max-width: 200px;
  margin: auto;
  padding: 20px;
}
</style>
