RightPanel.svelte 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <script lang="js">
  2. import CardThumb from './CardThumb.svelte';
  3. import { changeInput, showingCards, onPrevPage, onNextPage } from '../control/search'
  4. import { deckOps } from '../control/deck';
  5. function onChange(event) {
  6. changeInput(event.target.value);
  7. }
  8. function onDrop(event) {
  9. event.preventDefault();
  10. const data = JSON.parse(event.dataTransfer.getData('text'));
  11. if (data.area === 'main' || data.area === 'side' || data.area === 'extra') {
  12. deckOps.deleteCard(data.area, data.idx);
  13. }
  14. }
  15. </script>
  16. <div class="right-panel" role="region" ondragover={(e)=>e.preventDefault()} ondrop={onDrop}>
  17. <div class="search-bar">
  18. <input type="text" placeholder="搜索卡牌..." oninput={onChange}>
  19. </div>
  20. <div class="card-list">
  21. {#each $showingCards as card}
  22. <div class="card-item">
  23. <div class="card-thumbnail">
  24. <CardThumb id={card.id} idx={-1} area="search" />
  25. </div>
  26. <span>{card.name}</span>
  27. </div>
  28. {/each}
  29. </div>
  30. <div class="pagination">
  31. <button class="page-btn" onclick={onPrevPage}>上一页</button>
  32. <button class="page-btn" onclick={onNextPage}>下一页</button>
  33. </div>
  34. </div>
  35. <style>
  36. .right-panel {
  37. width: 20%;
  38. padding: 20px;
  39. background-color: #f8f8f8;
  40. display: flex;
  41. flex-direction: column;
  42. }
  43. .search-bar input {
  44. width: 100%;
  45. padding: 8px;
  46. margin-bottom: 15px;
  47. border: 1px solid #ddd;
  48. border-radius: 4px;
  49. }
  50. .card-list {
  51. flex-grow: 1;
  52. overflow-y: auto;
  53. margin-bottom: 15px;
  54. }
  55. .card-item {
  56. display: flex;
  57. align-items: center;
  58. padding: 8px;
  59. margin-bottom: 5px;
  60. background-color: white;
  61. border-radius: 4px;
  62. cursor: pointer;
  63. }
  64. .pagination {
  65. display: flex;
  66. gap: 10px;
  67. }
  68. .page-btn {
  69. flex: 1;
  70. padding: 8px;
  71. background-color: #007bff;
  72. color: white;
  73. border: none;
  74. border-radius: 4px;
  75. cursor: pointer;
  76. }
  77. .card-thumbnail {
  78. width: 50px;
  79. height: 70px;
  80. background-color: #eee;
  81. margin-right: 10px;
  82. border-radius: 3px;
  83. }
  84. </style>