feat(brand): rebrand to Hedena Gold and bring main user-app chrome
Rename the brand, ship Hedena logos, persist login OTP text in the SMS list, and port home/nav/auth/theme polish from main while keeping expert customers intact. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,507 @@
|
||||
<!--
|
||||
Spring-physics card carousel for the home screen (see
|
||||
docs/plans/2026-10-16-home-carousel-design.md).
|
||||
|
||||
Center card large, side cards scaled down; drag / flick settle with a
|
||||
damped spring. Internal layout is an isolated `direction: ltr` subtree
|
||||
(same rationale as GallerySlider) so translate/scale maths stay coherent
|
||||
under the app's RTL chrome. Gestures are still screen-space.
|
||||
-->
|
||||
<template>
|
||||
<section class="carousel" v-if="slides.length">
|
||||
<div
|
||||
ref="viewport"
|
||||
class="carousel__viewport"
|
||||
:class="{ 'is-dragging': dragging }"
|
||||
:style="{ '--carousel-radius': `${borderRadius}px` }"
|
||||
@pointerdown="onPointerDown"
|
||||
@pointermove="onPointerMove"
|
||||
@pointerup="onPointerUp"
|
||||
@pointercancel="onPointerUp"
|
||||
>
|
||||
<div ref="stage" class="carousel__stage">
|
||||
<article
|
||||
v-for="(card, i) in cards"
|
||||
:key="card.key"
|
||||
class="carousel__card"
|
||||
:data-index="i"
|
||||
:style="cardStyles[i]"
|
||||
>
|
||||
<img
|
||||
v-if="card.image"
|
||||
:src="card.image"
|
||||
alt=""
|
||||
class="carousel__art"
|
||||
draggable="false"
|
||||
/>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="carousel__dots" v-if="slides.length > 1" dir="ltr">
|
||||
<button
|
||||
v-for="(slide, i) in slides"
|
||||
:key="slide.key"
|
||||
type="button"
|
||||
class="carousel__dot"
|
||||
:class="{ 'is-active': i === activeIndex }"
|
||||
:aria-label="`اسلاید ${i + 1}`"
|
||||
@click="goTo(i)"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
computed,
|
||||
onActivated,
|
||||
onBeforeUnmount,
|
||||
onDeactivated,
|
||||
onMounted,
|
||||
ref,
|
||||
shallowRef,
|
||||
watch,
|
||||
} from 'vue'
|
||||
import type { ShowcaseSlide } from './ShowcaseSlider.vue'
|
||||
import { useAppearanceStore } from '../../stores/appearanceStore'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
slides: ShowcaseSlide[]
|
||||
sideScale?: number
|
||||
gap?: number
|
||||
borderRadius?: number
|
||||
stiffness?: number
|
||||
damping?: number
|
||||
autoplay?: boolean
|
||||
autoplayInterval?: number
|
||||
}>(),
|
||||
{
|
||||
// Slightly larger neighbours so peeks read as cards, not hairlines.
|
||||
sideScale: 0.72,
|
||||
gap: 3,
|
||||
// Match ShowcaseSlider frame radius so the active card reads the same.
|
||||
borderRadius: 22,
|
||||
// Premium settle: low stiffness + higher damping = slow, heavy, almost no bounce.
|
||||
stiffness: 70,
|
||||
damping: 28,
|
||||
autoplay: true,
|
||||
autoplayInterval: 7500,
|
||||
},
|
||||
)
|
||||
|
||||
/** Fraction of stage width for each card — wider center, tighter side peeks. */
|
||||
const CARD_WIDTH_RATIO = 0.92
|
||||
|
||||
const appearance = useAppearanceStore()
|
||||
|
||||
/** Pad copies so wrap never shows empty slots on either side. */
|
||||
const cards = computed(() => {
|
||||
const base = props.slides.filter((s) => s.image)
|
||||
if (!base.length) return [] as { key: string; image: string }[]
|
||||
const out: { key: string; image: string }[] = []
|
||||
let n = 0
|
||||
while (out.length < Math.max(6, base.length * 2)) {
|
||||
for (const s of base) {
|
||||
out.push({ key: `${s.key}#${n++}`, image: s.image as string })
|
||||
}
|
||||
}
|
||||
return out
|
||||
})
|
||||
|
||||
const viewport = ref<HTMLElement | null>(null)
|
||||
const stage = ref<HTMLElement | null>(null)
|
||||
const dragging = ref(false)
|
||||
const activeIndex = ref(0)
|
||||
|
||||
type CardStyle = {
|
||||
opacity: string
|
||||
pointerEvents: 'auto' | 'none'
|
||||
zIndex: string
|
||||
transform: string
|
||||
}
|
||||
|
||||
const cardStyles = shallowRef<CardStyle[]>([])
|
||||
|
||||
let position = 0
|
||||
let target = 0
|
||||
let velocity = 0
|
||||
let isDragging = false
|
||||
let startX = 0
|
||||
let startPosition = 0
|
||||
let lastX = 0
|
||||
let lastTime = 0
|
||||
let dragVelocity = 0
|
||||
let totalDragDistance = 0
|
||||
let pointerId: number | null = null
|
||||
let rafId: number | null = null
|
||||
let lastFrameTime = 0
|
||||
let autoplayTimer: ReturnType<typeof setInterval> | undefined
|
||||
let resizeObserver: ResizeObserver | null = null
|
||||
|
||||
function getWrappedOffset(index: number, pos: number, length: number) {
|
||||
let diff = (index - pos) % length
|
||||
if (diff < -length / 2) diff += length
|
||||
if (diff >= length / 2) diff -= length
|
||||
return diff
|
||||
}
|
||||
|
||||
function getActiveIndex() {
|
||||
const len = props.slides.filter((s) => s.image).length || 1
|
||||
return ((Math.round(target) % len) + len) % len
|
||||
}
|
||||
|
||||
function notifyChange() {
|
||||
activeIndex.value = getActiveIndex()
|
||||
}
|
||||
|
||||
function render() {
|
||||
const list = cards.value
|
||||
const total = list.length
|
||||
if (!total) {
|
||||
cardStyles.value = []
|
||||
return
|
||||
}
|
||||
|
||||
// Center card is CARD_WIDTH_RATIO of stage; scaled neighbours peek beside it.
|
||||
const stageWidth = stage.value?.clientWidth || 380
|
||||
const baseCardWidth = stageWidth * CARD_WIDTH_RATIO
|
||||
const sideScale = props.sideScale
|
||||
const gap = props.gap
|
||||
const stepDistance = baseCardWidth * 0.5 + baseCardWidth * sideScale * 0.5 + gap
|
||||
|
||||
const next: CardStyle[] = new Array(total)
|
||||
for (let i = 0; i < total; i++) {
|
||||
const offset = getWrappedOffset(i, position, total)
|
||||
const absOffset = Math.abs(offset)
|
||||
const clamped = Math.min(absOffset, 1)
|
||||
const scale = 1 - clamped * (1 - sideScale)
|
||||
const translateX = offset * stepDistance
|
||||
const isVisible = absOffset < 2.1
|
||||
|
||||
next[i] = {
|
||||
opacity: isVisible ? '1' : '0',
|
||||
pointerEvents: isVisible ? 'auto' : 'none',
|
||||
zIndex: String(100 - Math.round(absOffset * 20)),
|
||||
transform: `translate3d(calc(-50% + ${translateX.toFixed(2)}px), 0, 0) scale(${scale.toFixed(4)})`,
|
||||
}
|
||||
}
|
||||
cardStyles.value = next
|
||||
}
|
||||
|
||||
function startSpringLoop() {
|
||||
if (appearance.isReducedMotion) {
|
||||
position = target
|
||||
velocity = 0
|
||||
render()
|
||||
rafId = null
|
||||
return
|
||||
}
|
||||
|
||||
if (rafId != null) cancelAnimationFrame(rafId)
|
||||
lastFrameTime = performance.now()
|
||||
|
||||
const tick = (now: number) => {
|
||||
const dt = Math.min((now - lastFrameTime) / 1000, 0.064)
|
||||
lastFrameTime = now
|
||||
|
||||
const displacement = position - target
|
||||
const springForce = -props.stiffness * displacement
|
||||
const dampingForce = -props.damping * velocity
|
||||
const acceleration = springForce + dampingForce
|
||||
|
||||
velocity += acceleration * dt
|
||||
position += velocity * dt
|
||||
render()
|
||||
|
||||
if (Math.abs(velocity) < 0.002 && Math.abs(target - position) < 0.001) {
|
||||
position = target
|
||||
velocity = 0
|
||||
render()
|
||||
rafId = null
|
||||
return
|
||||
}
|
||||
|
||||
rafId = requestAnimationFrame(tick)
|
||||
}
|
||||
|
||||
rafId = requestAnimationFrame(tick)
|
||||
}
|
||||
|
||||
function onPointerDown(e: PointerEvent) {
|
||||
if (cards.value.length < 2 || pointerId !== null) return
|
||||
if (e.button !== undefined && e.button !== 0) return
|
||||
const el = viewport.value
|
||||
if (!el) return
|
||||
|
||||
pointerId = e.pointerId
|
||||
isDragging = true
|
||||
dragging.value = true
|
||||
stopAutoplay()
|
||||
|
||||
if (rafId != null) {
|
||||
cancelAnimationFrame(rafId)
|
||||
rafId = null
|
||||
}
|
||||
|
||||
startX = e.clientX
|
||||
lastX = e.clientX
|
||||
startPosition = position
|
||||
velocity = 0
|
||||
dragVelocity = 0
|
||||
totalDragDistance = 0
|
||||
lastTime = performance.now()
|
||||
el.setPointerCapture?.(e.pointerId)
|
||||
}
|
||||
|
||||
function onPointerMove(e: PointerEvent) {
|
||||
if (!isDragging || e.pointerId !== pointerId) return
|
||||
|
||||
const now = performance.now()
|
||||
const dt = Math.max(1, now - lastTime)
|
||||
const dx = e.clientX - startX
|
||||
const stepDx = e.clientX - lastX
|
||||
|
||||
totalDragDistance = Math.abs(dx)
|
||||
|
||||
const cardWidth = (stage.value?.clientWidth ?? 0) * CARD_WIDTH_RATIO || 320
|
||||
position = startPosition - dx / cardWidth
|
||||
dragVelocity = -(stepDx / cardWidth) / (dt / 1000)
|
||||
|
||||
lastX = e.clientX
|
||||
lastTime = now
|
||||
render()
|
||||
}
|
||||
|
||||
function onPointerUp(e: PointerEvent) {
|
||||
if (!isDragging || e.pointerId !== pointerId) return
|
||||
isDragging = false
|
||||
dragging.value = false
|
||||
pointerId = null
|
||||
|
||||
const total = cards.value.length
|
||||
|
||||
// Tap a side card → spring to it
|
||||
if (totalDragDistance < 6 && e.target instanceof Element) {
|
||||
const clicked = e.target.closest('.carousel__card') as HTMLElement | null
|
||||
if (clicked) {
|
||||
const cardIdx = Number(clicked.dataset.index)
|
||||
if (!Number.isNaN(cardIdx)) {
|
||||
const offset = getWrappedOffset(cardIdx, position, total)
|
||||
if (Math.abs(offset) > 0.25) {
|
||||
target = Math.round(position + offset)
|
||||
startSpringLoop()
|
||||
notifyChange()
|
||||
if (props.autoplay) startAutoplay()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
velocity = dragVelocity
|
||||
const projected = position + velocity * 0.16
|
||||
target = Math.round(projected)
|
||||
startSpringLoop()
|
||||
notifyChange()
|
||||
if (props.autoplay) startAutoplay()
|
||||
}
|
||||
|
||||
function goTo(baseIndex: number) {
|
||||
const len = props.slides.filter((s) => s.image).length
|
||||
if (len < 2) return
|
||||
const currentBase = getActiveIndex()
|
||||
let diff = baseIndex - currentBase
|
||||
if (diff > len / 2) diff -= len
|
||||
if (diff < -len / 2) diff += len
|
||||
target = Math.round(target) + diff
|
||||
startSpringLoop()
|
||||
notifyChange()
|
||||
}
|
||||
|
||||
/** False while the home tab is keep-alive-cached off-screen. */
|
||||
let pageActive = true
|
||||
|
||||
function startAutoplay() {
|
||||
stopAutoplay()
|
||||
if (!pageActive) return
|
||||
if (!props.autoplay || appearance.isReducedMotion || props.slides.length < 2) return
|
||||
autoplayTimer = setInterval(() => {
|
||||
if (!isDragging && pageActive) {
|
||||
target = Math.round(target) + 1
|
||||
startSpringLoop()
|
||||
notifyChange()
|
||||
}
|
||||
}, props.autoplayInterval)
|
||||
}
|
||||
|
||||
function stopAutoplay() {
|
||||
if (autoplayTimer) {
|
||||
clearInterval(autoplayTimer)
|
||||
autoplayTimer = undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** Pause motion while cached off-screen so return doesn't catch up many slides. */
|
||||
function pauseForLeave() {
|
||||
pageActive = false
|
||||
stopAutoplay()
|
||||
if (rafId != null) {
|
||||
cancelAnimationFrame(rafId)
|
||||
rafId = null
|
||||
}
|
||||
position = target
|
||||
velocity = 0
|
||||
isDragging = false
|
||||
dragging.value = false
|
||||
render()
|
||||
notifyChange()
|
||||
}
|
||||
|
||||
function resumeOnEnter() {
|
||||
pageActive = true
|
||||
render()
|
||||
if (props.autoplay) startAutoplay()
|
||||
}
|
||||
|
||||
function resetToStart() {
|
||||
position = 0
|
||||
target = 0
|
||||
velocity = 0
|
||||
notifyChange()
|
||||
render()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
pageActive = true
|
||||
resetToStart()
|
||||
if (stage.value && typeof ResizeObserver !== 'undefined') {
|
||||
resizeObserver = new ResizeObserver(() => render())
|
||||
resizeObserver.observe(stage.value)
|
||||
}
|
||||
if (props.autoplay) startAutoplay()
|
||||
})
|
||||
|
||||
// HomeView is keep-alive'd — without these, setInterval keeps advancing
|
||||
// target while the user is on another tab, then the spring "catches up"
|
||||
// through several slides the moment they return.
|
||||
onDeactivated(pauseForLeave)
|
||||
onActivated(resumeOnEnter)
|
||||
|
||||
watch(
|
||||
() => props.slides,
|
||||
() => {
|
||||
resetToStart()
|
||||
},
|
||||
)
|
||||
|
||||
watch(
|
||||
() => [props.sideScale, props.gap, props.stiffness, props.damping] as const,
|
||||
() => render(),
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.autoplay,
|
||||
(on) => {
|
||||
if (on) startAutoplay()
|
||||
else stopAutoplay()
|
||||
},
|
||||
)
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
pauseForLeave()
|
||||
resizeObserver?.disconnect()
|
||||
if (pointerId !== null && viewport.value) {
|
||||
try {
|
||||
viewport.value.releasePointerCapture(pointerId)
|
||||
} catch {
|
||||
/* detached */
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
// Break out of Container `px-[16px]` so side peeks sit at the screen edge
|
||||
// instead of leaving empty gutters inside the padded column.
|
||||
.carousel {
|
||||
width: calc(100% + 32px);
|
||||
margin-inline: -16px;
|
||||
}
|
||||
|
||||
.carousel__viewport {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
touch-action: pan-y;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
cursor: grab;
|
||||
// Top: room for bottom-anchored scale. Bottom: room for card drop-shadow
|
||||
// so overflow:hidden does not shear the soft edge.
|
||||
padding: 10px 0 28px;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
.carousel__viewport.is-dragging {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
// Same aspect as ShowcaseSlider; cards ~92% wide so neighbours hug the center.
|
||||
.carousel__stage {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
aspect-ratio: 320 / 208;
|
||||
}
|
||||
|
||||
.carousel__card {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
width: 92%;
|
||||
height: 100%;
|
||||
transform-origin: center bottom;
|
||||
will-change: transform;
|
||||
border-radius: var(--carousel-radius, 22px);
|
||||
overflow: hidden;
|
||||
background: @hairlineSoft;
|
||||
box-shadow: 0 14px 28px -12px rgba(20, 22, 26, 0.28);
|
||||
}
|
||||
|
||||
.carousel__art {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
pointer-events: none;
|
||||
-webkit-user-drag: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.carousel__dots {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
// Re-align with the padded column after the bleed; extra air under the stage.
|
||||
padding: 4px 16px 8px;
|
||||
}
|
||||
|
||||
.carousel__dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
border-radius: 999px;
|
||||
background: @hairline;
|
||||
transition:
|
||||
width 0.42s cubic-bezier(0.16, 0.86, 0.3, 1),
|
||||
background 0.3s ease;
|
||||
}
|
||||
|
||||
.carousel__dot.is-active {
|
||||
width: 20px;
|
||||
background: @wine;
|
||||
}
|
||||
</style>
|
||||
@@ -49,7 +49,7 @@ const perGram = computed(() => (props.quote ? props.quote.pricePerGramRial.split
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
color: rgba(255, 255, 255, 0.68);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -82,13 +82,12 @@ const perGram = computed(() => (props.quote ? props.quote.pricePerGramRial.split
|
||||
|
||||
.rate-strip__unit {
|
||||
font-size: 10.5px;
|
||||
/* Tailwind gray-100 */
|
||||
color: #f3f4f6;
|
||||
color: rgba(255, 255, 255, 0.55);
|
||||
}
|
||||
|
||||
.rate-strip__time {
|
||||
font-size: 10.5px;
|
||||
color: #fff;
|
||||
color: rgba(255, 255, 255, 0.42);
|
||||
padding-inline-start: 10px;
|
||||
border-inline-start: 1px solid rgba(255, 255, 255, 0.14);
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</div>
|
||||
<button v-if="actionLabel" type="button" class="sec__action" @click="emit('action')">
|
||||
{{ actionLabel }}
|
||||
<Icon icon="vuesax-linear:arrow-left-1" size="15" />
|
||||
<Icon icon="vuesax-linear:arrow-left-2" size="15" />
|
||||
</button>
|
||||
</header>
|
||||
</template>
|
||||
@@ -30,8 +30,8 @@ const emit = defineEmits<{ (e: 'action'): void }>()
|
||||
|
||||
.sec__title {
|
||||
margin: 0;
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
font-weight: 800;
|
||||
color: @ink;
|
||||
letter-spacing: -0.1px;
|
||||
}
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
<!--
|
||||
Product card for the redesigned home screen.
|
||||
|
||||
Shows only fields that genuinely exist on ProductSummary today: title, the
|
||||
cheapest variant's rash weight, its making-charge (اجرت) percent, and the
|
||||
catalogue image. No price is printed on the card, because a finished piece's
|
||||
rial price is a function of the live gold rate plus wage and is computed at
|
||||
order time, not stored on the product — printing one here would be invented.
|
||||
-->
|
||||
<template>
|
||||
<article class="card" :class="{ 'card--wide': wide }" data-product-origin @click="emit('open', value)">
|
||||
<div class="card__art">
|
||||
<img v-lazy="image" :alt="title" />
|
||||
<button type="button" class="card__fav" :class="{ 'is-on': favorites.isFavorite(id) }" @click.stop="favorites.toggle(id)">
|
||||
<Icon :icon="favorites.isFavorite(id) ? 'vuesax-linear:heart-fill' : 'vuesax-linear:heart'" size="17" />
|
||||
</button>
|
||||
<span v-if="badge" class="card__badge">{{ badge }}</span>
|
||||
</div>
|
||||
|
||||
<div class="card__body">
|
||||
<h3 class="card__title">{{ title }}</h3>
|
||||
<div class="card__meta">
|
||||
<span class="card__weight">{{ min_gram }} گرم</span>
|
||||
<span v-if="wage != null" class="card__wage">اجرت {{ wageLabel }}٪</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import Icon from '../icon/Icon.vue'
|
||||
import { useProduct } from '../../composables/useProduct'
|
||||
import { useFavoritesStore } from '../../stores/favoritesStore'
|
||||
import type { ProductSummary } from '../../api/client'
|
||||
|
||||
const props = defineProps<{ value: ProductSummary; wide?: boolean; badge?: string }>()
|
||||
const emit = defineEmits<{ (e: 'open', value: ProductSummary): void }>()
|
||||
|
||||
const favorites = useFavoritesStore()
|
||||
const { image, id, title, min_gram, wage } = useProduct(props.value)
|
||||
|
||||
const wageLabel = computed(() => {
|
||||
const w = wage.value
|
||||
if (w == null) return ''
|
||||
return w % 1 === 0 ? String(w) : w.toFixed(2)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.card {
|
||||
cursor: pointer;
|
||||
background: @canvas;
|
||||
border: 1px solid @hairline;
|
||||
border-radius: 18px;
|
||||
overflow: hidden;
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
|
||||
}
|
||||
|
||||
.card:active {
|
||||
transform: scale(0.985);
|
||||
}
|
||||
|
||||
.card__art {
|
||||
position: relative;
|
||||
aspect-ratio: 1 / 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: @hairlineSoft;
|
||||
}
|
||||
|
||||
.card--wide .card__art {
|
||||
aspect-ratio: 4 / 3;
|
||||
}
|
||||
|
||||
.card__art img {
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
height: 100%;
|
||||
max-height: 200px;
|
||||
object-fit: contain;
|
||||
object-position: center;
|
||||
display: block;
|
||||
}
|
||||
|
||||
// Dark mode: product photos are shot on white, so they sit on a light mat
|
||||
// instead of showing as white boxes on a dark card (@photoMat — transparent,
|
||||
// i.e. no change, in light mode).
|
||||
html.theme-dark .card__art img {
|
||||
background: @photoMat;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.card__fav {
|
||||
position: absolute;
|
||||
top: 9px;
|
||||
left: 9px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
color: @inkMuted;
|
||||
background: alpha(@canvas, 90%);
|
||||
backdrop-filter: blur(6px);
|
||||
transition: color 0.18s ease, transform 0.18s ease;
|
||||
}
|
||||
.card__fav.is-on {
|
||||
color: @wine;
|
||||
}
|
||||
.card__fav:active {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
.card__badge {
|
||||
position: absolute;
|
||||
top: 9px;
|
||||
right: 9px;
|
||||
padding: 4px 9px;
|
||||
border-radius: 999px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
background: @wine;
|
||||
}
|
||||
|
||||
.card__body {
|
||||
padding: 11px 12px 13px;
|
||||
}
|
||||
|
||||
.card__title {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: @ink;
|
||||
line-height: 1.6;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.card__meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
padding-top: 7px;
|
||||
}
|
||||
|
||||
.card__weight {
|
||||
font-size: 11.5px;
|
||||
font-weight: 700;
|
||||
color: @inkSoft;
|
||||
}
|
||||
|
||||
.card__wage {
|
||||
font-size: 10.5px;
|
||||
color: @inkFaint;
|
||||
padding-inline-start: 7px;
|
||||
border-inline-start: 1px solid @hairline;
|
||||
}
|
||||
</style>
|
||||
@@ -1,33 +1,29 @@
|
||||
<!--
|
||||
Editorial hero for the home screen. Self-contained, dependency-free slider:
|
||||
no swiper CSS to fight, no autoplay jitter, and it keeps working when a
|
||||
slide has no artwork.
|
||||
Editorial hero for the home screen — luxury soft crossfade between stacked
|
||||
slides (see docs/plans/2026-10-15-showcase-crossfade-design.md).
|
||||
|
||||
Swipe support: the app sets `direction: rtl !important` on #app (see
|
||||
src/App.vue), so — same fix as GallerySlider.vue — the track is an isolated
|
||||
`direction: ltr` subtree (.showcase__track). Inside it, index 0 is first and
|
||||
a positive translateX moves right, plain LTR arithmetic, regardless of the
|
||||
page's own direction. The drag gesture itself is still read in screen space
|
||||
(dragging left = next slide) so it feels natural to an RTL user; only the
|
||||
track's internal layout/maths is pinned to LTR.
|
||||
Self-contained, no Swiper. Swipe is still read in screen space (drag left =
|
||||
next) so it feels natural under the app's RTL chrome; the track itself is no
|
||||
longer a translated strip — slides sit on top of each other and fade.
|
||||
-->
|
||||
<template>
|
||||
<section class="showcase" v-if="slides.length">
|
||||
<div
|
||||
ref="root"
|
||||
class="showcase__frame"
|
||||
:class="{ 'is-dragging': dragging }"
|
||||
:class="{ 'is-dragging': dragging, 'is-reduced': appearance.isReducedMotion }"
|
||||
@pointerdown="onPointerDown"
|
||||
@pointermove="onPointerMove"
|
||||
@pointerup="onPointerUp"
|
||||
@pointercancel="onPointerCancel"
|
||||
>
|
||||
<div class="showcase__track" :style="trackStyle">
|
||||
<div class="showcase__track">
|
||||
<article
|
||||
v-for="(slide, i) in slides"
|
||||
:key="slide.key"
|
||||
class="showcase__slide"
|
||||
:class="{ 'is-active': i === index }"
|
||||
:class="{ 'is-active': i === index && !dragging }"
|
||||
:style="slideStyle(i)"
|
||||
>
|
||||
<img v-if="slide.image" :src="slide.image" alt="" class="showcase__art" draggable="false" />
|
||||
</article>
|
||||
@@ -49,7 +45,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { useAppearanceStore } from '../../stores/appearanceStore'
|
||||
|
||||
/** A slide from the admin slider section. Display-only — it has no destination. */
|
||||
@@ -128,8 +124,7 @@ function endDrag() {
|
||||
pointerId = null
|
||||
dragX.value = 0
|
||||
|
||||
// Screen-space drag direction: dragging left (negative dx) is "next slide",
|
||||
// matching what the gesture means to the person doing it.
|
||||
// Screen-space: drag left (negative) → next; drag right → previous.
|
||||
if (ratio <= -DRAG_COMMIT_RATIO && index.value < props.slides.length - 1) index.value++
|
||||
else if (ratio >= DRAG_COMMIT_RATIO && index.value > 0) index.value--
|
||||
|
||||
@@ -150,14 +145,43 @@ function onPointerCancel(e: PointerEvent) {
|
||||
isSwipe = false
|
||||
}
|
||||
|
||||
const trackStyle = computed(() => {
|
||||
const base = -index.value * 100
|
||||
const dragPercent = trackWidth ? (dragX.value / trackWidth) * 100 : 0
|
||||
return {
|
||||
transform: `translate3d(${base + dragPercent}%, 0, 0)`,
|
||||
transition: dragging.value ? 'none' : undefined,
|
||||
/**
|
||||
* Stacked crossfade: only the active slide is fully opaque unless the user is
|
||||
* mid-swipe, in which case we preview the neighbour by drag progress.
|
||||
*/
|
||||
function slideStyle(i: number) {
|
||||
const active = index.value
|
||||
const reduced = appearance.isReducedMotion
|
||||
|
||||
if (!dragging.value || !isSwipe || !trackWidth) {
|
||||
const on = i === active
|
||||
return {
|
||||
opacity: on ? 1 : 0,
|
||||
zIndex: on ? 2 : 0,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const progress = Math.min(1, Math.abs(dragX.value) / trackWidth)
|
||||
const towardNext = dragX.value < 0
|
||||
const neighbor = towardNext ? active + 1 : active - 1
|
||||
const neighborOk = neighbor >= 0 && neighbor < props.slides.length
|
||||
|
||||
if (i === active) {
|
||||
return {
|
||||
opacity: neighborOk ? 1 - progress * 0.92 : 1,
|
||||
zIndex: 2,
|
||||
transition: reduced ? 'none' : undefined,
|
||||
}
|
||||
}
|
||||
if (neighborOk && i === neighbor) {
|
||||
return {
|
||||
opacity: progress,
|
||||
zIndex: 3,
|
||||
transition: 'none',
|
||||
}
|
||||
}
|
||||
return { opacity: 0, zIndex: 0 }
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (pointerId !== null && root.value) {
|
||||
@@ -183,71 +207,60 @@ onBeforeUnmount(() => {
|
||||
touch-action: pan-y;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
// Forces its own compositing layer so `overflow: hidden` actually clips the
|
||||
// translated track on Safari/iOS — without this, a sliver of the next
|
||||
// slide peeks past the rounded edge because the browser composites the
|
||||
// transformed child (.showcase__track) on a layer that ignores the
|
||||
// parent's clip until it's promoted the same way.
|
||||
transform: translateZ(0);
|
||||
-webkit-transform: translateZ(0);
|
||||
}
|
||||
|
||||
// Isolated from the page's `direction: rtl` — see the file header. Everything
|
||||
// under this node uses plain LTR layout and LTR-signed transforms.
|
||||
.showcase__track {
|
||||
direction: ltr;
|
||||
display: flex;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
// A gentle, slightly-overshooting ease — softer settle than a linear/
|
||||
// ease-out curve, which is what makes the swipe feel "alive" rather than
|
||||
// mechanical. Slowed down a touch from the old 0.42s so the motion reads
|
||||
// as a deliberate glide instead of a snap.
|
||||
transition: transform 0.56s cubic-bezier(0.16, 0.86, 0.3, 1);
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.showcase__frame.is-dragging .showcase__track {
|
||||
transition: none;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.showcase__slide {
|
||||
position: relative;
|
||||
flex: 0 0 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
// Clips its own image's scale-in (.showcase__art below) to this slide's own
|
||||
// box, so the 1.06x zoom never bleeds into the neighbouring slide.
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
// Soft luxury crossfade — slower settle so the change never feels like a jump.
|
||||
transition: opacity 1.15s cubic-bezier(0.22, 0.61, 0.36, 1);
|
||||
will-change: opacity;
|
||||
}
|
||||
|
||||
.showcase__slide.is-active {
|
||||
opacity: 1;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.showcase__frame.is-dragging .showcase__slide {
|
||||
// Live drag preview is driven by inline opacity; avoid fighting it.
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.showcase__frame.is-reduced .showcase__slide {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.showcase__art {
|
||||
// A plain block filling the slide, NOT an absolutely-positioned box.
|
||||
// `position: absolute` + `inset` made the image's own box a second,
|
||||
// independently-rounded measurement of the same area the frame already
|
||||
// sizes via `aspect-ratio`; on real devices the two disagreed by a
|
||||
// fraction of a pixel and the frame's dark background showed through as a
|
||||
// hairline border around the artwork. Sizing it as ordinary in-flow
|
||||
// content removes that second measurement entirely.
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
-webkit-user-drag: none;
|
||||
user-select: none;
|
||||
// Never settles below 1x: the "breathe in" flourish now runs from a larger
|
||||
// scale down to exactly 1, so the image is always at least as big as the
|
||||
// slide and can never reveal what sits behind it.
|
||||
transform: scale(1.06);
|
||||
transition: transform 0.56s cubic-bezier(0.16, 0.86, 0.3, 1);
|
||||
// Incoming settle: slightly overscale → exact fit, then rests at 1.
|
||||
transform: scale(1.03);
|
||||
transition: transform 1.15s cubic-bezier(0.22, 0.61, 0.36, 1);
|
||||
}
|
||||
|
||||
.showcase__slide.is-active .showcase__art {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.showcase__frame.is-dragging .showcase__art {
|
||||
.showcase__frame.is-dragging .showcase__art,
|
||||
.showcase__frame.is-reduced .showcase__art {
|
||||
transition: none;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.showcase__dots {
|
||||
|
||||
Reference in New Issue
Block a user