aboutsummaryrefslogtreecommitdiff
path: root/src/components/user_avatar/user_avatar.vue
blob: 91c176118d9be6a29e7855254742ebf8259b2047 (plain)
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
<template>
  <span
    class="Avatar"
    :class="{ '-compact': compact }"
  >
    <StillImage
      v-if="user"
      class="avatar"
      :alt="user.screen_name_ui"
      :title="user.screen_name_ui"
      :src="imgSrc(user.profile_image_url_original)"
      :image-load-error="imageLoadError"
      :class="{ '-compact': compact, '-better-shadow': betterShadow }"
    />
    <div
      v-else
      class="avatar -placeholder"
      :class="{ '-compact': compact }"
    />
    <FAIcon
      v-if="bot"
      icon="robot"
      class="bot-indicator"
    />
  </span>
</template>

<script src="./user_avatar.js"></script>
<style lang="scss">
@import "../../variables";

.Avatar {
  --_avatarShadowBox: var(--avatarStatusShadow);
  --_avatarShadowFilter: var(--avatarStatusShadowFilter);
  --_avatarShadowInset: var(--avatarStatusShadowInset);
  --_still-image-label-visibility: hidden;

  display: inline-block;
  position: relative;
  width: 48px;
  height: 48px;

  &.-compact {
    width: 32px;
    height: 32px;
    border-radius: $fallback--avatarAltRadius;
    border-radius: var(--avatarAltRadius, $fallback--avatarAltRadius);
  }

  .avatar {
    width: 100%;
    height: 100%;
    box-shadow: var(--_avatarShadowBox);
    border-radius: $fallback--avatarRadius;
    border-radius: var(--avatarRadius, $fallback--avatarRadius);

    &.-better-shadow {
      box-shadow: var(--_avatarShadowInset);
      filter: var(--_avatarShadowFilter);
    }

    &.-animated::before {
      display: none;
    }

    &.-compact {
      border-radius: $fallback--avatarAltRadius;
      border-radius: var(--avatarAltRadius, $fallback--avatarAltRadius);
    }

    &.-placeholder {
      background-color: $fallback--fg;
      background-color: var(--fg, $fallback--fg);
    }
  }

  img {
    width: 100%;
    height: 100%;
  }

  .bot-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    margin: -0.2em;
    padding: 0.2em;
    background: rgb(127 127 127 / 50%);
    color: #fff;
    border-radius: var(--tooltipRadius);
  }
}
</style>