summaryrefslogtreecommitdiff
path: root/examples/snowpack/public/css/components/_toc.scss
blob: 8e23b358f5d57cd84e914bb589e163c54239dff5 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
@use '../var' as *;

/**
 * Table of Contents (toc)
 * The left-hand sidebar
 */

$top-padding: 24px;

%toc-link {
  position: relative;
  display: block;
  color: $white;
  text-decoration: none;
  border: none;
  transition: color 0.3s;

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

  &::before {
      position: absolute;
      top: -2px;
      left: -19px;
      font-weight: 400;
      font-size: 26px;
      line-height: 1;
      opacity: 0;
      transition: left .14s ease-out;
      content: "▸";
  }


  &:hover {
    text-decoration: underline;
  }

  &.active {
    color: #0c8cec;
    text-decoration: underline;

    &::before {
      left: -17px;
      opacity: 1;
  }
  }
}

.snow-toc {
  transition: padding 0.2s ease-out, opacity 0.2s ease-in-out;

  // -----------
  //  Components
  // -----------

  &-contents {
    margin: 0;
    padding: 0;
    line-height: 1.8;
    list-style: none;
  }

  &-link {
    @extend %toc-link;
  }

  &-section {
    + .snow-toc-section {
      margin-top: 1.5rem;
    }

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

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

    &-items {
      margin: 0;
      padding: 0;
      list-style: none;
    }
  }

  // ----------
  //  Modifiers
  // ----------

  &__subnav {
    position: static;
    z-index: 1;
    padding-top: 2rem;
    
    .snow-toc-section-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 {
      @extend %toc-link;

      color: $grey;
    }
  }
}