mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-01 09:30:48 +08:00
Compare commits
1 Commits
codex/impr
...
codex/impr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
229439aa05 |
@@ -1,18 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<component
|
<NuxtLink
|
||||||
:is="wrapperTag"
|
:to="resolvedLink"
|
||||||
:to="isLink ? resolvedLink : undefined"
|
|
||||||
class="base-user-avatar"
|
class="base-user-avatar"
|
||||||
:class="wrapperClass"
|
:class="wrapperClass"
|
||||||
:style="wrapperStyle"
|
:style="wrapperStyle"
|
||||||
v-bind="wrapperAttrs"
|
v-bind="wrapperAttrs"
|
||||||
:role="isLink ? undefined : 'img'"
|
|
||||||
:aria-label="altText"
|
|
||||||
:title="altText"
|
|
||||||
>
|
>
|
||||||
<span class="base-user-avatar-backdrop" aria-hidden="true" />
|
|
||||||
<BaseImage :src="currentSrc" :alt="altText" class="base-user-avatar-img" @error="onError" />
|
<BaseImage :src="currentSrc" :alt="altText" class="base-user-avatar-img" @error="onError" />
|
||||||
</component>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -81,45 +76,15 @@ const sizeStyle = computed(() => {
|
|||||||
return { width: value, height: value }
|
return { width: value, height: value }
|
||||||
})
|
})
|
||||||
|
|
||||||
const accentHue = computed(() => {
|
|
||||||
const seed = props.userId ?? props.alt
|
|
||||||
const source = seed !== undefined && seed !== null ? String(seed) : ''
|
|
||||||
if (!source) return 198
|
|
||||||
let hash = 0
|
|
||||||
for (let index = 0; index < source.length; index += 1) {
|
|
||||||
hash = (hash << 5) - hash + source.charCodeAt(index)
|
|
||||||
hash |= 0
|
|
||||||
}
|
|
||||||
return Math.abs(hash) % 360
|
|
||||||
})
|
|
||||||
|
|
||||||
const accentStyles = computed(() => {
|
|
||||||
const hue = accentHue.value
|
|
||||||
return {
|
|
||||||
'--avatar-accent': `hsl(${hue}, 74%, 54%)`,
|
|
||||||
'--avatar-accent-light': `hsl(${hue}, 95%, 82%)`,
|
|
||||||
'--avatar-accent-soft': `hsl(${hue}, 96%, 95%)`,
|
|
||||||
'--avatar-accent-border': `hsla(${hue}, 70%, 48%, 0.28)`,
|
|
||||||
'--avatar-accent-shadow': `hsla(${hue}, 68%, 36%, 0.2)`,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const wrapperStyle = computed(() => {
|
const wrapperStyle = computed(() => {
|
||||||
const attrStyle = attrs.style
|
const attrStyle = attrs.style
|
||||||
return [accentStyles.value, sizeStyle.value, attrStyle]
|
return [sizeStyle.value, attrStyle]
|
||||||
})
|
})
|
||||||
|
|
||||||
const isLink = computed(() => !props.disableLink && !!resolvedLink.value)
|
const wrapperClass = computed(() => [attrs.class, { 'is-rounded': props.rounded }])
|
||||||
|
|
||||||
const wrapperTag = computed(() => (isLink.value ? 'NuxtLink' : 'div'))
|
|
||||||
|
|
||||||
const wrapperClass = computed(() => [
|
|
||||||
attrs.class,
|
|
||||||
{ 'is-rounded': props.rounded, 'is-interactive': isLink.value },
|
|
||||||
])
|
|
||||||
|
|
||||||
const wrapperAttrs = computed(() => {
|
const wrapperAttrs = computed(() => {
|
||||||
const { class: _class, style: _style, to: _to, href: _href, ...rest } = attrs
|
const { class: _class, style: _style, ...rest } = attrs
|
||||||
return rest
|
return rest
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -132,26 +97,33 @@ function onError() {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.base-user-avatar {
|
.base-user-avatar {
|
||||||
position: relative;
|
--base-avatar-ring-width: var(--avatar-ring-width, 1.5px);
|
||||||
|
--base-avatar-ring: var(--avatar-ring, linear-gradient(135deg, #6366f1, #ec4899));
|
||||||
|
--base-avatar-surface: var(
|
||||||
|
--avatar-surface,
|
||||||
|
var(--avatar-placeholder-color, rgba(255, 255, 255, 0.88))
|
||||||
|
);
|
||||||
|
--base-avatar-shadow: var(--avatar-shadow, 0 12px 30px -18px rgba(15, 23, 42, 0.55));
|
||||||
|
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: 16px;
|
position: relative;
|
||||||
background: linear-gradient(
|
box-sizing: border-box;
|
||||||
140deg,
|
color: inherit;
|
||||||
var(--avatar-accent-soft, rgba(17, 182, 197, 0.12)) 0%,
|
border-radius: 50%;
|
||||||
var(--avatar-accent-light, rgba(17, 182, 197, 0.22)) 100%
|
border: var(--base-avatar-ring-width) solid transparent;
|
||||||
);
|
background:
|
||||||
border: 1px solid var(--avatar-accent-border, rgba(17, 182, 197, 0.2));
|
var(--base-avatar-surface) padding-box,
|
||||||
box-shadow:
|
var(--base-avatar-ring) border-box;
|
||||||
0 1px 2px rgba(15, 52, 67, 0.08),
|
background-clip: padding-box, border-box;
|
||||||
0 3px 8px var(--avatar-accent-shadow, rgba(17, 182, 197, 0.18));
|
background-origin: border-box;
|
||||||
|
box-shadow: var(--base-avatar-shadow);
|
||||||
transition:
|
transition:
|
||||||
transform 0.3s ease,
|
transform 0.25s ease,
|
||||||
box-shadow 0.3s ease,
|
box-shadow 0.25s ease,
|
||||||
border-color 0.3s ease,
|
filter 0.25s ease;
|
||||||
background 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.base-user-avatar.is-rounded {
|
.base-user-avatar.is-rounded {
|
||||||
@@ -159,57 +131,59 @@ function onError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.base-user-avatar:not(.is-rounded) {
|
.base-user-avatar:not(.is-rounded) {
|
||||||
border-radius: 0;
|
border-radius: var(--avatar-square-radius, 0);
|
||||||
}
|
|
||||||
|
|
||||||
.base-user-avatar-backdrop {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
background:
|
|
||||||
radial-gradient(circle at 28% 28%, rgba(255, 255, 255, 0.72), transparent 62%),
|
|
||||||
linear-gradient(150deg, rgba(255, 255, 255, 0.08), transparent),
|
|
||||||
linear-gradient(
|
|
||||||
140deg,
|
|
||||||
var(--avatar-accent-soft, rgba(17, 182, 197, 0.08)) 0%,
|
|
||||||
var(--avatar-accent-light, rgba(17, 182, 197, 0.18)) 100%
|
|
||||||
);
|
|
||||||
opacity: 0.75;
|
|
||||||
transition:
|
|
||||||
opacity 0.35s ease,
|
|
||||||
transform 0.35s ease;
|
|
||||||
z-index: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.base-user-avatar-img {
|
.base-user-avatar-img {
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
display: block;
|
display: block;
|
||||||
z-index: 1;
|
|
||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
transition: transform 0.35s ease;
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
transition:
|
||||||
|
transform 0.25s ease,
|
||||||
|
filter 0.25s ease;
|
||||||
|
backface-visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.base-user-avatar.is-interactive:hover,
|
.base-user-avatar:hover,
|
||||||
.base-user-avatar.is-interactive:focus-visible {
|
.base-user-avatar:focus-visible {
|
||||||
transform: translateY(-1px) scale(1.02);
|
transform: translateY(-1px) scale(1.02);
|
||||||
border-color: var(--avatar-accent, var(--primary-color, #0a6e78));
|
box-shadow: 0 18px 35px -20px rgba(15, 23, 42, 0.65);
|
||||||
box-shadow:
|
|
||||||
0 6px 16px var(--avatar-accent-shadow, rgba(17, 182, 197, 0.24)),
|
|
||||||
0 3px 6px rgba(15, 52, 67, 0.18);
|
|
||||||
outline: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.base-user-avatar.is-interactive:hover .base-user-avatar-backdrop,
|
.base-user-avatar:focus-visible {
|
||||||
.base-user-avatar.is-interactive:focus-visible .base-user-avatar-backdrop {
|
outline: 2px solid rgba(96, 165, 250, 0.6);
|
||||||
opacity: 1;
|
outline-offset: 3px;
|
||||||
transform: scale(1.05);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.base-user-avatar.is-interactive:hover .base-user-avatar-img,
|
.base-user-avatar:active {
|
||||||
.base-user-avatar.is-interactive:focus-visible .base-user-avatar-img {
|
transform: translateY(0) scale(0.99);
|
||||||
transform: scale(1.02);
|
}
|
||||||
|
|
||||||
|
.base-user-avatar:hover .base-user-avatar-img,
|
||||||
|
.base-user-avatar:focus-visible .base-user-avatar-img {
|
||||||
|
transform: scale(1.03);
|
||||||
|
filter: saturate(1.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.base-user-avatar,
|
||||||
|
.base-user-avatar-img {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.base-user-avatar:hover,
|
||||||
|
.base-user-avatar:focus-visible,
|
||||||
|
.base-user-avatar:active {
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.base-user-avatar:hover .base-user-avatar-img,
|
||||||
|
.base-user-avatar:focus-visible .base-user-avatar-img {
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user