<template>
  <figure :class="[{ float: imgPos }, imgPos]">
    <img :src="imgSrc" :alt="caption" />
    <figcaption>{{ caption }}</figcaption>
  </figure>
</template>

<script>
export default {
  name: "rich-figure",
  props: {
    imgSrc: {
      type: String,
      required: true
    },
    caption: {
      type: String,
      required: true
    },
    imgPos: String,
    imgW: String
  }
};
</script>

<style lang="scss" scoped>
figure {
  position: relative;
  overflow: hidden;
  margin: 0;
  line-height: 1;

  figcaption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;

    line-height: 1.5;
    background: rgba(#000, 0.5);
    color: #fff;
    text-align: center;
  }

  img {
    display: block;
    width: 100%;
  }
}

.float {
  width: 100%;

  @media (min-width: 35em) {
    width: 20em;

    &.left {
      float: left;
      margin: 0 0.75em 0.375em 0;
    }

    &.right {
      float: right;
      margin: 0 0 0.375em 0.75em;
    }
  }
}
</style>
