ProjectList.vue 2.04 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
<template>
  <div class="project-list">
    <div
      v-for="(project, index) in $frontmatter.project || []"
      :key="project.name"
      class="project"
      :class="`project${index % 9}`"
      @click="navigate(project.link)"
    >
      <div
        v-if="project.cover"
        class="cover"
        :style="`background: url(${$withBase(
          project.cover
        )}) center/cover no-repeat;`"
      />
      <component :is="`${project.type}-icon`" />
      <div class="name">{{ project.name }}</div>
      <div class="desc">{{ project.desc }}</div>
    </div>
  </div>
</template>

<script src="./ProjectList" />

<style lang="stylus">
.project-list
  position relative
  display flex
  justify-content flex-start
  align-content stretch
  align-items stretch
  flex-wrap wrap
  font-family sans-serif
  margin-bottom 12px
  z-index 2

  .project
    position relative
    width calc(50% - 40px)
    background-color var(--grey14)
    border-radius 8px
    margin 6px 8px
    padding 12px
    transition background-color 0.3s, transform 0.3s

    @media (min-width $MQNarrow)
      width calc(33% - 40px)

    @media (min-width $MQWide)
      width calc(25% - 40px)

    &:hover
      cursor pointer
      transform scale(0.98, 0.98)

    .cover
      content ''
      opacity 0.5
      top 0
      left 0
      bottom 0
      right 0
      position absolute
      z-index 1

    .icon
      position relative
      z-index 2
      float right
      width 20px
      height 20px

    .name
      position relative
      z-index 2
      color var(--grey3)
      font-size 16px
      font-weight 500

    .desc
      position relative
      z-index 2
      margin 6px 0
      color var(--dark-grey)
      font-size 13px

@require '~@mr-hope/vuepress-shared/styles/colors.styl'

for $color, $index in $colors
  .project-list .project{$index}
    &, .theme-light &
      background lighten($color, 90%)

      &:hover
        background lighten($color, 75%)

    .theme-dark &
      background darken($color, 75%)

      &:hover
        background darken($color, 60%)
</style>