fix: 票券打孔改 mask 差集——两端 1/4 圆硬停剪切,孔真穿透露底、描边真断开;孔心对齐撕线 172.75px

This commit is contained in:
cqh963852 committed 2026-10-06 13:38:16 +08:00
1 parent e83fde75f9
commit 789c8ac5bc
2 files changed
+25 -23

No files matched your search

+12 -6
View File
@@ -140,13 +140,19 @@ test.describe('票券规格契约', () => {
expect(s.headBg).not.toBe('rgba(0, 0, 0, 0)')
})
test('打孔伪元素在位(完成票 ×2 孔)', async ({ page }) => {
const holes = await page.locator('.ticket-pk').first().evaluate((el) => {
const b = getComputedStyle(el, '::before')
const a = getComputedStyle(el, '::after')
return [b.content, a.content].filter((c) => c !== 'none').length
test('打孔差集在位(mask 两端 1/4 圆,完成票)', async ({ page }) => {
const mask = await page.locator('.ticket-pk').first().evaluate((el) => {
const cs = getComputedStyle(el)
return cs.maskImage || cs.webkitMaskImage || 'none'
})
expect(holes).toBe(2)
expect(mask).toContain('radial-gradient')
expect(mask.split('radial-gradient').length - 1).toBe(2) // 上下各一孔
// 未开始票不带 mask
const plain = await page.evaluate(() => {
const t = [...document.querySelectorAll('div')].filter((d) => String(d.className).includes('w-[216px]') && !String(d.className).includes('ticket-pk'))[0]
return t ? getComputedStyle(t).maskImage : 'none'
})
expect(plain === 'none' || plain === '').toBeTruthy()
})
test('撕线:完成=虚线、未开始=实线', async ({ page }) => {
+13 -17
View File
@@ -32,21 +32,17 @@
filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.9));
}
/* 票券打孔:⌀14 圆跨边,被 overflow-hidden 裁成半圆缺口(完成票专用) */
.ticket-pk::before,
.ticket-pk::after {
content: '';
position: absolute;
left: 160px;
width: 14px;
height: 14px;
border-radius: 50%;
background: var(--color-paper);
border: 2px solid var(--color-ink);
}
.ticket-pk::before {
top: -10px;
}
.ticket-pk::after {
bottom: -10px;
/* 票券打孔:两端各以 1/4 圆做差集(完成票专用)。
* mask 硬停只做形状剪切(非色彩渐变):孔真正穿透票体——露出页面底色,
* 描边与硬投影在孔处真实断开,无需伪元素盖色近似。 */
.ticket-pk {
--hole-x: 172.75px; /* 撕线中心:216 − 右描边 2 − stub 42 + 撕线半宽 */
-webkit-mask-image:
radial-gradient(circle 7px at var(--hole-x) 0, transparent 6.5px, #000 7px),
radial-gradient(circle 7px at var(--hole-x) 100%, transparent 6.5px, #000 7px);
-webkit-mask-composite: source-in;
mask-image:
radial-gradient(circle 7px at var(--hole-x) 0, transparent 6.5px, #000 7px),
radial-gradient(circle 7px at var(--hole-x) 100%, transparent 6.5px, #000 7px);
mask-composite: intersect;
}