Header.vue 2.7 KB
Newer Older
L
LeoKu 已提交
1 2 3 4 5 6 7 8 9 10 11 12
<template>
  <header class="header">
    <Logo />

    <h2 class="site-title">Color Avatar</h2>

    <div class="header-right">
      <a
        href="https://github.com/Codennnn/vue-color-avatar"
        target="_blank"
        rel="nofollow noopener noreferrer"
      >
L
LeoKu 已提交
13
        <button
L
LeoKu 已提交
14
          type="button"
L
LeoKu 已提交
15 16 17 18 19 20 21
          class="github-button"
          @click="
            recordEvent('click_github', {
              event_category: 'click',
            })
          "
        >
L
LeoKu 已提交
22
          <img :src="IconGitHub" alt="GitHub" />
L
LeoKu 已提交
23 24 25 26 27 28 29 30 31 32
          <span class="text">GitHub</span>
        </button>
      </a>
    </div>
  </header>
</template>

<script lang="ts" setup>
import IconGitHub from '@/assets/icons/icon-github.svg'
import Logo from '@/components/Logo.vue'
L
LeoKu 已提交
33
import { recordEvent } from '@/utils/ga'
L
LeoKu 已提交
34 35 36
</script>

<style lang="scss" scoped>
37 38
@use 'src/styles/var';

L
LeoKu 已提交
39 40 41
.header {
  display: flex;
  align-items: center;
42
  height: var.$layout-header-height;
L
LeoKu 已提交
43 44 45 46 47 48
  padding: 1rem 2rem;

  .site-title {
    margin-left: 1rem;
    font-weight: bold;
    font-size: 1.9rem;
L
LeoKu 已提交
49
    cursor: default;
L
LeoKu 已提交
50

51
    @media screen and (max-width: var.$screen-sm) {
L
LeoKu 已提交
52 53 54 55 56 57 58 59
      display: none;
    }
  }

  .header-right {
    margin-left: auto;

    .github-button {
L
LeoKu 已提交
60 61
      position: relative;
      z-index: 0;
L
LeoKu 已提交
62 63 64
      display: flex;
      align-items: center;
      justify-content: center;
L
LeoKu 已提交
65 66 67
      width: 9rem;
      height: 2.6rem;
      overflow: hidden;
68
      color: var.$color-text;
L
LeoKu 已提交
69 70
      font-weight: bold;
      font-size: 1.05rem;
71
      background-color: var.$color-dark;
L
LeoKu 已提交
72 73 74 75
      border-radius: 0.6rem;
      cursor: pointer;
      user-select: none;

L
LeoKu 已提交
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
      @media (prefers-reduced-motion: no-preference) {
        transition: background-color 0.2s;

        &::before,
        &::after {
          position: absolute;
          right: 0;
          bottom: 0;
          z-index: -1;
          width: 5rem;
          height: 5rem;
          background: var.$color-text;
          border-radius: 50%;
          transform: translate(100%, -25%) translate3d(0, 0, 0);
          opacity: 0;
          transition: transform 0.15s cubic-bezier(0.02, 0.01, 0.47, 1),
            opacity 0.15s cubic-bezier(0.02, 0.01, 0.47, 1);
          content: '';
        }

        &:hover {
          background-color: darken(var.$color-dark, 3);

          &::before,
          &::after {
            opacity: 0.15;
            transition: transform 0.2s cubic-bezier(0.02, 0.01, 0.47, 1),
              opacity 0.2s cubic-bezier(0.02, 0.01, 0.47, 1);
          }

          &::before {
            transform: translate3d(50%, 0, 0) scale(0.9);
          }

          &::after {
            transform: translate(50%, 0) scale(1.1);
          }
        }
L
LeoKu 已提交
114 115 116 117
      }

      .text {
        margin-left: 0.5rem;
L
LeoKu 已提交
118
        letter-spacing: 0.03rem;
L
LeoKu 已提交
119 120 121 122 123
      }
    }
  }
}
</style>