aboutsummaryrefslogtreecommitdiff
path: root/src/components/Sidebar.svelte
blob: 39c005ed967565761af1d154e2f652064d32a436 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<script lang="ts">
  import DarkModeSwitch from "./helpers/DarkModeSwitch.svelte";
  import AssignLabs from "./AssignLabs.svelte";
  import FileUploads from "./FileUploads.svelte";
  import PeerTeachers from "./PeerTeachers.svelte";
  import Labs from "./Labs.svelte";
  import TamuOutput from "./TamuOutput.svelte";
  import { onMount } from "svelte";
  import { parseDatabaseLocalStorage } from "../util/parser";

  let sections = [
    { name: "File Uploads", component: FileUploads },
    { name: "Peer Teachers", component: PeerTeachers },
    { name: "Assign Labs", component: AssignLabs },
    { name: "Labs", component: Labs },
    { name: "Active Peer Teachers", component: null }, // TODO
    { name: "Stats", component: null }, // TODO
    { name: "TAMU HTML Output", component: TamuOutput },
  ];

  let selected = sections[0];

  // Load from local storage. FOR TESTING PURPOSES ONLY. REMOVE THIS FROM PRODUCTION
  onMount(() => {
    const db = localStorage.getItem("db");
    if (db) {
      console.log("Using database found in local storage");
      parseDatabaseLocalStorage(db);
    } else {
      console.log("No database found in local storage");
    }
  });
</script>

<!-- Entire Page -->
<div class="flex flex-row h-screen">
  <!-- SIDEBAR -->
  <div class="flex-none w-2/12 flex-col border-r">
    <!-- Header for sidebar sections -->
    <div
      class="font-serif flex-none text-center text-3xl p-1 border-b font-black overflow-hidden"
    >
      <!-- Text -->
      <div
        class="bg-clip-text text-transparent bg-gradient-to-r from-primary to-secondary"
      >
        Peer Teacher Manager
      </div>
      <div>
        <DarkModeSwitch />
      </div>
    </div>

    <!-- Sidebar sections -->
    <div class="flex-col overflow-y-auto">
      <ul class="menu bg-base-100 w-full text-xl">
        {#each sections as sec}
          <li>
            <div
              class={selected == sec ? "active" : ""}
              on:click={() => {
                selected = sec;
              }}
            >
              {sec.name}
            </div>
          </li>
        {/each}
      </ul>
    </div>
  </div>

  <!-- Chosen Section / Component -->
  <div class="flex-auto h-full overflow-y-hidden">
    <svelte:component this={selected.component} />
  </div>
</div>