Files
tehran_taj/apps/user-app/src/components/home/RateStrip.vue
T
s.esmaeiliandClaude Opus 5 f2d83c53df user-app: redesigned home screen and product detail
Design language introduced here and reused across both screens:
  - LESS colour tokens (@ink/@inkSoft/@inkMuted/@inkFaint, @wine/@wineSoft,
    @canvas/@canvasSoft, @hairline/@hairlineSoft) added to
    themeConfig/colors.json and injected globally via vite's modifyVars, so
    scoped <style lang="less"> blocks resolve them with no import
  - BEM-ish scoped class names, hairline-bordered cards at 14-18px radii,
    ink surfaces with a wine accent, dashed-border empty states
  - components/home/: SectionHead, ShowcaseCard, ShowcaseSlider, CategoryRail,
    RateStrip, AccountStrip

Data honesty is deliberate throughout: no rial price is printed for a piece,
because a finished item's price is the live gold rate x weight plus wage,
computed at order time and never stored on the product. Only genuinely
present fields are shown (weight, making-charge percent, stock, category,
brand). Categories and the hero are derived from the real catalogue, so an
empty catalogue renders an empty state rather than placeholder tiles.

Also fixes a real bug in the product detail view: it ran, at module scope,
history.pushState + window.onpopstate = () => history.go(1). Because the
drawer mounts its slot eagerly, that fired for every product card on the
home screen and permanently hijacked the back button for the session.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 23:05:29 +03:30

108 lines
2.6 KiB
Vue

<!--
Live 18k gold rate strip. Real data: GET /pricing/latest (PricingController).
The strip degrades to a quiet placeholder when the quote endpoint has no
data yet, rather than rendering a fabricated number.
-->
<template>
<div class="rate-strip" :class="{ 'is-empty': !quote }">
<div class="rate-strip__label">
<span class="rate-strip__dot" aria-hidden="true"></span>
نرخ طلای ۱۸ عیار
</div>
<div v-if="quote" class="rate-strip__value">
<span class="rate-strip__num">{{ price(perGram) }}</span>
<span class="rate-strip__unit">ریال / گرم</span>
</div>
<div v-else class="rate-strip__value rate-strip__value--muted">در انتظار اعلام نرخ</div>
<div v-if="quote" class="rate-strip__time">{{ jdate(quote.quotedAt) }}</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { price, jdate } from '../../utils/filters'
import type { GoldPriceQuote } from '../../api/client'
const props = defineProps<{ quote: GoldPriceQuote | null }>()
// pricePerGramRial is a decimal string from the ledger — never parsed into a
// float for display, only trimmed of any fractional tail.
const perGram = computed(() => (props.quote ? props.quote.pricePerGramRial.split('.')[0] : ''))
</script>
<style scoped lang="less">
.rate-strip {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 14px;
border-radius: 14px;
background: @ink;
color: #fff;
box-shadow: 0 10px 24px -18px rgba(20, 22, 26, 0.9);
}
.rate-strip__label {
display: flex;
align-items: center;
gap: 7px;
font-size: 12px;
color: rgba(255, 255, 255, 0.68);
white-space: nowrap;
}
.rate-strip__dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: @wineSoft;
box-shadow: 0 0 0 0 rgba(163, 60, 85, 0.65);
animation: ratePulse 2.4s ease-out infinite;
}
.rate-strip__value {
margin-inline-start: auto;
display: flex;
align-items: baseline;
gap: 5px;
}
.rate-strip__value--muted {
font-size: 12px;
color: rgba(255, 255, 255, 0.55);
}
.rate-strip__num {
font-size: 16px;
font-weight: 700;
letter-spacing: 0.2px;
}
.rate-strip__unit {
font-size: 10.5px;
color: rgba(255, 255, 255, 0.55);
}
.rate-strip__time {
font-size: 10.5px;
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;
}
@keyframes ratePulse {
0% {
box-shadow: 0 0 0 0 rgba(163, 60, 85, 0.6);
}
70% {
box-shadow: 0 0 0 7px rgba(163, 60, 85, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(163, 60, 85, 0);
}
}
</style>