Timeline.vue 3.87 KB
Newer Older
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
<template>
  <div class="timeline-wrapper">
    <ul class="timeline-content">
      <MyTransition>
        <li class="desc">{{ hint }}</li>
      </MyTransition>
      <Anchor :items="anchorConfig" />
      <MyTransition
        v-for="(item, index) in $timeline"
        :key="index"
        :delay="0.08 * (index + 1)"
      >
        <li>
          <h3 :id="item.year" class="year">
            <span>{{ item.year }}</span>
          </h3>
          <ul class="year-wrapper">
            <li
              v-for="(article, articleIndex) in item.articles"
              :key="articleIndex"
            >
              <span class="date">{{ article.frontmatter.parsedDate }}</span>
              <span class="title" @click="navigate(article.path)">
                {{ article.title }}
              </span>
            </li>
          </ul>
        </li>
      </MyTransition>
    </ul>
  </div>
</template>

<script src="./Timeline" />

<style lang="stylus">
.timeline-wrapper
  max-width 740px
  margin 0 auto
  padding 40px 0
  --dot-color #fff
  --dot-bar-color #eaecef
  --dot-border-color #ddd

  .theme-dark &
    --dot-color #444
    --dot-bar-color #333
    --dot-border-color #555

  #anchor
    left unset
    right 0
    min-width 0

  .anchor-wrapper
    position relative
    z-index 10

  .timeline-content
    box-sizing border-box
    position relative
    padding-left 76px
    list-style none

    &::after
      content ' '
      position absolute
      top 14px
      left 64px
      z-index -1
      width 4px
      height calc(100% - 38px)
      margin-left -2px
      background var(--dot-bar-color)

    .desc
      position relative
      color var(--text-color)
      font-size 18px

      @media (min-width $MQNormal)
        font-size 20px

      &:before
        content ' '
        position absolute
        z-index 2
        left -12px
        top 50%
        width 8px
        height 8px
        margin-left -6px
        margin-top -6px
        background var(--dot-color)
        border 2px solid var(--dot-border-color)
        border-radius 50%

    .year
      margin-top 0.5rem - $navbarHeight
      margin-bottom 0.5rem
      padding-top: ($navbarHeight + 3rem)
      color var(--text-color)
      font-size 26px
      font-weight 700

      span
        position relative

        &:before
          content ' '
          position absolute
          z-index 2
          left -12px
          top 50%
          width 8px
          height 8px
          margin-left -6px
          margin-top -6px
          background var(--dot-color)
          border 2px solid var(--dot-border-color)
          border-radius 50%

    .year-wrapper
      padding-left 0 !important

      li
        position relative
        display flex
        padding 30px 0 10px
        border-bottom 1px dashed var(--border-color)
        list-style none

        &:hover
          cursor pointer

          .date
            font-size 16px
            transition font-size 0.3s ease-out

            &::before
              background-color var(--bgcolor)
              border-color var(--accent-color)

          .title
            color var(--accent-color)
            font-size 18px
            transition font-size 0.3s ease-out

        .date
          position absolute
          right calc(100% + 24px)
          text-align right
          width 40px
          font-size 14px
          line-height 30px

          &::before
            content ' '
            position absolute
            z-index 2
            right -16px
            top 50%
            width 6px
            height 6px
            margin-left -6px
            margin-top -6px
            background var(--dot-color)
            border 2px solid var(--dot-border-color)
            border-radius 50%

        .title
          position relative
          font-size 16px
          line-height 30px

@media (max-width $MQMobile)
  .timeline-wrapper
    margin 0 1.2rem
</style>
D