ButtonImage.vue 893 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <b-button
  3. v-on="$listeners"
  4. v-bind="$attrs"
  5. variant="link"
  6. class="btn-image"
  7. >
  8. <span
  9. class="btn-image-wrapper"
  10. :style="`--url: url(${image.url});`"
  11. >
  12. <slot name="default" />
  13. </span>
  14. </b-button>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'ButtonImage',
  19. props: {
  20. image: { type: Object, required: true }
  21. }
  22. }
  23. </script>
  24. <style lang="scss" scoped>
  25. .btn-image {
  26. padding: 0;
  27. width: 135px;
  28. height: 135px;
  29. border: 0;
  30. transition: 100ms;
  31. @media (orientation: landscape) {
  32. width: 250px;
  33. height: 250px;
  34. &:hover,
  35. &.hover,
  36. &:focus,
  37. &.focus {
  38. width: 400px;
  39. height: 400px;
  40. }
  41. }
  42. &-wrapper {
  43. border: $line;
  44. border-radius: inherit;
  45. width: 100%;
  46. height: 100%;
  47. display: inline-block;
  48. background-image: var(--url);
  49. background-size: cover;
  50. }
  51. }
  52. </style>