about summary refs log tree commit diff stats
path: root/src/Navbar.svelte
blob: 5b70e53820d1a46fac77509d2a0000fae60a3c64 (plain) (blame)
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
78
<script>
  import { createEventDispatcher } from 'svelte';

  import Home from './Home.svelte';
  import DDA from './algorithms/line-drawing/DDA.svelte';
  import Bresenham from './algorithms/line-drawing/Bresenham.svelte';

  const dispatch = createEventDispatcher();

  const changePage = (p) => dispatch('message', { page: p });
</script>

<nav class="ddmenu">
  <button on:click={() => changePage(Home)}>Home</button>

  <div class="ddgroup">
    Line Drawing Algorithms
    <div class="ddsub">
      <button on:click={() => changePage(DDA)}>
        Digital differential analyzer
      </button>
      <button on:click={() => changePage(Bresenham)}>
        Bresenham
      </button>
    </div>
  </div>
</nav>

<style>
  .ddmenu {
    display: flex;
    padding: 0.2em;
    border-bottom: 1px solid var(--bg-alt);
  }

  .ddmenu button, .ddmenu .ddgroup {
    text-align: left;
    width: 100%;
    padding: 8px;
    color: var(--fg-main);
    text-decoration: none;
    background: var(--bg-alt);
    border: 2px solid var(--bg-main);
  }
  .ddmenu button:hover, .ddmenu .ddgroup:hover {
    color: var(--fg-special-cold);
    background: var(--bg-dim);
    cursor: pointer;
  }
  .ddmenu .ddgroup { position: relative; }
  .ddsub {
    width: 100%;
    position: absolute;
    top: 100%; left: 0;
    display: none;
  }
  .ddsub button {
    display: block;
    box-sizing: border-box;
  }
  .ddgroup:hover .ddsub { display: block; }
  .ddgroup::after {
    content: "\27A4";
    position: absolute;
    top: 8px; right: 8px;
    transition: transform 0.2s;
  }
  .ddgroup:hover::after {
    transform: rotate(90deg);
  }
  @media screen and (max-width: 640px) {
    .ddmenu { flex-wrap: wrap; }
    .ddsub {
      position: static;
      margin-top: 10px;
    }
  }
</style>