ArtistItem.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <script setup lang="ts">
  2. import { computed } from "vue";
  3. const props = defineProps({
  4. type: { type: String, required: true },
  5. data: {
  6. type: Object,
  7. required: true
  8. }
  9. });
  10. const imageUrl = computed(() => {
  11. if (props.type === "youtube")
  12. return props.data.rawData.snippet.thumbnails.default.url;
  13. if (props.type === "soundcloud") return props.data.avatarUrl;
  14. if (props.type === "spotify") return props.data.rawData.images[0].url;
  15. return null;
  16. });
  17. const artistUrl = computed(() => {
  18. if (props.type === "youtube")
  19. return `https://youtube.com/channel/${props.data.channelId}`;
  20. if (props.type === "soundcloud")
  21. return `https://soundcloud.com/${props.data.permalink}`;
  22. if (props.type === "spotify")
  23. return `https://open.spotify.com/artist/${props.data.artistId}`;
  24. return null;
  25. });
  26. const artistName = computed(() => {
  27. if (props.type === "youtube") return props.data.title;
  28. if (props.type === "soundcloud") return props.data.username;
  29. if (props.type === "spotify") return props.data.rawData.name;
  30. return null;
  31. });
  32. </script>
  33. <template>
  34. <div class="artist-item">
  35. <img v-if="imageUrl" :src="imageUrl" alt="Artist image" />
  36. <a :href="artistUrl" target="_blank"
  37. ><div :class="`${type}-icon`"></div
  38. ></a>
  39. <span>
  40. {{ artistName }}
  41. </span>
  42. </div>
  43. </template>
  44. <style lang="less">
  45. .artist-item {
  46. display: flex;
  47. flex-direction: row;
  48. gap: 8px;
  49. align-items: center;
  50. outline: 1px solid white;
  51. border-radius: 4px;
  52. img {
  53. max-height: 88px;
  54. max-width: 88px;
  55. }
  56. .youtube-icon,
  57. .soundcloud-icon,
  58. .spotify-icon {
  59. width: 30px;
  60. max-width: 30px;
  61. height: 30px;
  62. max-height: 30px;
  63. }
  64. }
  65. </style>