summaryrefslogtreecommitdiff
path: root/examples/snowpack/src/components/Subnav.astro
blob: 39ccebdef1197f5a2f4cb54dc2064cdcc50b937b (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
---
export interface Props {
  title: string;
  inputPath: string;
  headers: string;
}
const { title, inputPath, headers } = Astro.props;
---

<style lang="scss">
@use "../../public/styles/var" as *;

.header {
  margin-top: 0;
  margin-bottom: 8px;
  color: rgba($white, 0.6);
  font-weight: 600;
  font-size: 20px;
  font-family: $heading;
  line-height: 1.2;

  @media (min-width: $breakpoint-m) {
    color: $dark-grey;
  }
}

.subnav {
  position: static;
  z-index: 1;

  .header {
    color: $dark-grey;
  }

  hr {
    display: block;
    height: 1px;
    margin: 1rem 0;
    background-color: $light-grey;
    border: none;
    appearance: none;
  }

  ol {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  li {
    line-height: 1.8;
  }

  a {
    color: $grey;
  }
}
</style>

<script type="module" defer src="/js/index.js"></script>
<aside class="subnav">
  {headers.length > 0 && (
    <div>
      <h4 class="header">On this page</h4>
      <nav class="toc">
        <ol>
          {headers.map((heading) => {
          return <li><a href={"#" + heading.slug}>{heading.text}</a></li>
          })}
        </ol>
      </nav>
      <hr />
    </div>
  )}

  <h4 class="header">Suggest a change</h4>
  <a href="https://github.com/snowpackjs/snowpack/blob/main/www/{inputPath}">Edit this page on GitHub</a>
</aside>