@tbox.cn/app-module-promotion 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-DP2XDOBN.js → chunk-HZIEXNVQ.js} +5 -3
- package/dist/client/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{promotion-6L7HLRC2.css → promotion-ESTNS7IL.css} +4 -0
- package/dist/server/index.d.ts +589 -589
- package/package.json +1 -1
- package/src/client/cards/promotion-offer-list/index.tsx +4 -0
- package/src/client/components/CouponSheet.tsx +4 -2
- package/src/client/styles/promotion.css +4 -0
- package/tests/cards-render.test.tsx +32 -0
package/package.json
CHANGED
|
@@ -22,6 +22,9 @@ const couponSubtitleIsTime = (subtitle: string) => {
|
|
|
22
22
|
return /\d{4}\s*[-/.年]\s*\d{1,2}\s*[-/.月]\s*\d{1,2}|\d{1,2}:\d{2}/.test(plainText);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
const sheetImageFit = (offer: PromotionOfferListCardData['items'][number]): 'contain' | 'cover' =>
|
|
26
|
+
offer.offerRef === 'demo:coupon:1001' || offer.offerRef === 'demo:groupon:2001' ? 'cover' : 'contain';
|
|
27
|
+
|
|
25
28
|
export function PromotionOfferListCard(props: {
|
|
26
29
|
data: PromotionOfferListCardData;
|
|
27
30
|
cardId?: string;
|
|
@@ -203,6 +206,7 @@ export function PromotionOfferListCard(props: {
|
|
|
203
206
|
<CouponSheet
|
|
204
207
|
title={target.title}
|
|
205
208
|
imageUrl={target.imageUrl}
|
|
209
|
+
imageFit={sheetImageFit(target)}
|
|
206
210
|
noticeText={target.usageNoticeText}
|
|
207
211
|
guaranteeText={target.guaranteeText}
|
|
208
212
|
subtitle={redirectOnly
|
|
@@ -19,6 +19,8 @@ export interface SheetFact {
|
|
|
19
19
|
export function CouponSheet(props: {
|
|
20
20
|
title: string;
|
|
21
21
|
imageUrl?: string;
|
|
22
|
+
/** 团购图有稳定横幅画幅,可裁切铺满;券图默认完整展示。 */
|
|
23
|
+
imageFit?: 'contain' | 'cover';
|
|
22
24
|
subtitle?: string;
|
|
23
25
|
noticeText?: string;
|
|
24
26
|
guaranteeText?: string;
|
|
@@ -36,7 +38,7 @@ export function CouponSheet(props: {
|
|
|
36
38
|
foot?: React.ReactNode;
|
|
37
39
|
onClose: () => void;
|
|
38
40
|
}) {
|
|
39
|
-
const { title, imageUrl, subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
|
|
41
|
+
const { title, imageUrl, imageFit = 'contain', subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
|
|
40
42
|
const [closing, setClosing] = useState(false);
|
|
41
43
|
const closingRef = useRef(false);
|
|
42
44
|
const closeTimerRef = useRef<number>();
|
|
@@ -83,7 +85,7 @@ export function CouponSheet(props: {
|
|
|
83
85
|
<X size={18} weight="bold" aria-hidden="true" />
|
|
84
86
|
</button>
|
|
85
87
|
<div className="promotion-sheet__scroll">
|
|
86
|
-
<ImageWithFallback src={imageUrl} alt={title} className=
|
|
88
|
+
<ImageWithFallback src={imageUrl} alt={title} className={`promotion-sheet__image${imageFit === 'cover' ? ' promotion-sheet__image--cover' : ''}`} />
|
|
87
89
|
{/* 价格条压在图下沿:与列表行同一组价格语言,浮层里放大一档 */}
|
|
88
90
|
{(priceMain || aside) && (
|
|
89
91
|
<div className="promotion-sheet__price">
|
|
@@ -332,6 +332,38 @@ describe('优惠券链路视觉状态语义', () => {
|
|
|
332
332
|
expect(host.querySelector('.promotion-coupon-row__sub')?.textContent).toBe('商场会员专享');
|
|
333
333
|
});
|
|
334
334
|
|
|
335
|
+
it('演示团购与指定满减券详情图裁切铺满,其他券图保持完整展示', () => {
|
|
336
|
+
const host = render(<PromotionOfferListCard data={{
|
|
337
|
+
mode: 'claimable',
|
|
338
|
+
presentation: 'coupon',
|
|
339
|
+
items: [
|
|
340
|
+
offer,
|
|
341
|
+
{ ...offer, offerRef: 'demo:coupon:1001', title: '满 100 减 20 元券' },
|
|
342
|
+
{ ...offer, offerRef: 'demo:groupon:2001', offerType: 'GROUPON', title: '演示双人套餐' },
|
|
343
|
+
{ ...offer, offerRef: 'vendor:groupon:1', offerType: 'GROUPON', title: '厂商双人套餐' },
|
|
344
|
+
],
|
|
345
|
+
} as never} cardId="coupon-list" />);
|
|
346
|
+
const rows = host.querySelectorAll('.promotion-coupon-row');
|
|
347
|
+
|
|
348
|
+
act(() => (rows[0] as HTMLElement).click());
|
|
349
|
+
expect(document.querySelector('.promotion-sheet__image--cover')).toBeNull();
|
|
350
|
+
act(() => (document.querySelector('.promotion-sheet [aria-label="关闭详情"]') as HTMLElement).click());
|
|
351
|
+
act(() => document.querySelector('.promotion-sheet')?.dispatchEvent(new Event('animationend', { bubbles: true })));
|
|
352
|
+
|
|
353
|
+
act(() => (rows[1] as HTMLElement).click());
|
|
354
|
+
expect(document.querySelector('.promotion-sheet__image--cover')).not.toBeNull();
|
|
355
|
+
act(() => (document.querySelector('.promotion-sheet [aria-label="关闭详情"]') as HTMLElement).click());
|
|
356
|
+
act(() => document.querySelector('.promotion-sheet')?.dispatchEvent(new Event('animationend', { bubbles: true })));
|
|
357
|
+
|
|
358
|
+
act(() => (rows[2] as HTMLElement).click());
|
|
359
|
+
expect(document.querySelector('.promotion-sheet__image--cover')).not.toBeNull();
|
|
360
|
+
act(() => (document.querySelector('.promotion-sheet [aria-label="关闭详情"]') as HTMLElement).click());
|
|
361
|
+
act(() => document.querySelector('.promotion-sheet')?.dispatchEvent(new Event('animationend', { bubbles: true })));
|
|
362
|
+
|
|
363
|
+
act(() => (rows[3] as HTMLElement).click());
|
|
364
|
+
expect(document.querySelector('.promotion-sheet__image--cover')).toBeNull();
|
|
365
|
+
});
|
|
366
|
+
|
|
335
367
|
it('商场券和我的券缺图时共用居中的缩略图兜底', () => {
|
|
336
368
|
const offerHost = render(<PromotionOfferListCard data={{
|
|
337
369
|
mode: 'claimable',
|