BlogHero.vue 2.28 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
<template>
  <div
    v-if="$frontmatter.hero !== false"
    class="blog-hero"
    :class="{ full: $frontmatter.heroFullScreen }"
    :style="{ ...bgImageStyle }"
  >
    <div
      class="mask"
      :style="{
        background: `url(${
          $frontmatter.bgImage
            ? $withBase($frontmatter.bgImage)
            : defaultHeroImage
        }) center/cover no-repeat`,
      }"
    />
    <MyTransition :delay="0.04">
      <img
        v-if="$frontmatter.heroImage"
        class="hero-logo"
        :style="heroImageStyle || {}"
        :src="$withBase($frontmatter.heroImage)"
        alt="hero"
      />
    </MyTransition>
    <MyTransition :delay="0.08">
      <h1 v-if="$frontmatter.showTitle !== false">
        {{ $frontmatter.heroText || $title || "Hope" }}
      </h1>
    </MyTransition>

    <MyTransition :delay="0.12">
      <p v-if="$description" class="description" v-text="$description" />
    </MyTransition>
  </div>
</template>

<script src="./BlogHero" />

<style lang="stylus">
.blog-hero
  position relative
  color #eee
  margin-bottom 16px
  height 450px
  display flex
  flex-direction column
  justify-content center

  @media (max-width $MQMobile)
    height 350px
    margin 0 -1.5rem 16px

  @media (max-width $MQMobileNarrow)
    margin 0 0 16px

  &.full
    height 'calc(100vh - %s)' % $navbarHeight !important

    @media (max-width $MQMobile)
      height 'calc(100vh - %s)' % $navbarMobileHeight !important

    .mask
      background-position-y top !important

  .mask
    position absolute
    top 0
    bottom 0
    left 0
    right 0

    &:after
      display block
      content ' '
      background var(--light-grey)
      position absolute
      top 0
      bottom 0
      left 0
      right 0
      z-index 1
      opacity 0.2

  & > :not(.mask)
    position relative
    z-index 2

  h1
    margin 0.5rem auto
    font-size 36px

    @media (max-width $MQNarrow)
      font-size 30px

    @media (max-width $MQMobile)
      font-size 36px

    @media (max-width $MQMobileNarrow)
      font-size 30px

  .hero-logo + h1
    margin 0 auto

  .description
    margin 1.2rem auto 0
    font-size 20px

    @media (max-width $MQNarrow)
      font-size 18px

    @media (max-width $MQMobile)
      font-size 20px

    @media (max-width $MQMobileNarrow)
      font-size 18px
</style>