GameCard.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <script setup lang="ts">
  2. type Game = {
  3. name: string
  4. icon: string
  5. }
  6. interface Props {
  7. game: Game
  8. }
  9. const props = defineProps<Props>()
  10. const emit = defineEmits<{
  11. click: [game: Game]
  12. }>()
  13. const handleClick = () => {
  14. emit('click', props.game)
  15. }
  16. </script>
  17. <template>
  18. <button
  19. class="game-card"
  20. @click="handleClick"
  21. >
  22. <div class="game-icon">
  23. <img
  24. :src="game.icon"
  25. :alt="game.name"
  26. >
  27. </div>
  28. <span class="game-name truncate">{{ game.name }}</span>
  29. </button>
  30. </template>
  31. <style lang="scss" scoped>
  32. .game-card {
  33. @include size(75px, 61px);
  34. display: flex;
  35. flex-direction: column;
  36. align-items: center;
  37. justify-content: space-between;
  38. cursor: pointer;
  39. }
  40. .game-icon {
  41. @include size(45px);
  42. border-radius: 50%;
  43. overflow: hidden;
  44. display: flex;
  45. align-items: center;
  46. justify-content: center;
  47. flex-shrink: 0;
  48. img {
  49. width: 100%;
  50. height: 100%;
  51. object-fit: cover;
  52. }
  53. }
  54. .game-name {
  55. font-size: 11px;
  56. font-weight: 400;
  57. color: #1B1919;
  58. text-align: center;
  59. line-height: 14px;
  60. max-width: 100%;
  61. }
  62. </style>