index.svelte 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <script>
  2. import ContestTable from "./_components/ContestTable.svelte";
  3. import AddContestForm from "./_components/AddContestForm.svelte";
  4. let contests = [
  5. {
  6. id: 1,
  7. channel: "#channel1",
  8. started: new Date(),
  9. entryDuration: "1d",
  10. voteDuration: "1d",
  11. winners: ["link1", "link2", "link3"]
  12. },
  13. {
  14. id: 2,
  15. channel: "#channel1",
  16. started: new Date(),
  17. entryDuration: "1d",
  18. voteDuration: "1d",
  19. winners: ["link1", "link2", "link3"]
  20. },
  21. {
  22. id: 3,
  23. channel: "#channel1",
  24. started: new Date(),
  25. entryDuration: "1d",
  26. voteDuration: "1d",
  27. winners: ["link1", "link2", "link3"]
  28. }
  29. ];
  30. let showAddContest = false;
  31. function toggleAddContest() {
  32. showAddContest = !showAddContest;
  33. }
  34. function contestAdded(newContest) {
  35. contests = [newContest, ...contests];
  36. }
  37. </script>
  38. <style lang="css">
  39. h2 {
  40. @apply .text-xl .font-bold;
  41. }
  42. </style>
  43. <svelte:head>
  44. <title>Contest control</title>
  45. </svelte:head>
  46. <div class="nav-content">
  47. <h2>Actions</h2>
  48. <div class="pb-5">
  49. <button on:click={toggleAddContest} class="btn">Add contest</button>
  50. {#if showAddContest}
  51. <AddContestForm on:contestAdded={contestAdded} />
  52. {/if}
  53. </div>
  54. <h2>Current contests</h2>
  55. <ContestTable {contests}/>
  56. </div>