refactor: 设计系统阴影分层——二层交互件零投影,全站消除影中影 (#61)
Build Tutorial / Build @stack/tutorial (kaniko) (push) Successful in 4m58s

## 背景

全站视觉检查发现大量「影中影」:嵌套在卡片内部的第二层可交互内容(卡内按钮、tab、条目、印章)也带着硬投影。设计哲学上影子是「拿在手里」的信号,只属于第一层——直接放在页面背景上的可交互内容与覆盖页面的浮层;卡片已经把内容托在纸面上,卡内再投影就是影中影。

## 变更内容

**设计系统先行**
- design-shadow 册新增「层级投影」一节:规则文案 + 卡内按钮带投影/零投影的 DoDont 对照,页首 desc 补层级口径
- design-system README 新增「阴影层级」哲学段
- ShadowButton / Button / shadowButtonClasses 增加 `nested` 形态:零投影,描边+底色分层,hover 换底色或调亮度,按压位移 1px 不换影

**全站违规清理(24 页截图目检+代码嵌套层级双重确认)**
- learning 组件:知识卡翻面钮、数据流工位卡、积木条目、验收印章(含装箱单条目小印章)去硬投影,hover 改底色
- 站点 chrome:navbar header 卡与抽屉内的品牌钮、▼/▲、汉堡/×,sidebar 内品牌钮与收起钮,全部换 nested 零投影
- learn 页:浏览器取景框内的待办演示卡、对照板纸页内「查看本地环境准备」按钮
- 组件册:取景框标本内「进入教程」按钮、Dropdown 演示触发器(面板浮层投影保留)
- practice:编辑 sheet 内「运行 ▶」按钮换 nested(ch7 页面级用法保留投影);learn 导览浮层关闭钮去投影

**验证同步**
- e2e:nav-brand / practice-sidebar 断言改为零投影形态;visual.spec 与 page-flip-visual 基线 `--update-snapshots=all` 重建

## 自测结果

- 全量 e2e 134 项通过(含重建后的 10 项视觉基线)
- strip-comments 零残留,biome format 通过
- 前后对照截图(元素级 before/after):

| 区域 | 前后对照 |
| --- | --- |
| 导航栏:品牌钮/▼钮 3px 投影 → 零投影 | ![导航栏](https://gitea.idealjs.com/attachments/2835667d-4ab5-419f-86b3-34dcf696b7e8) |
| 数据流板:工位小卡 → 零投影(外层板投影保留) | ![数据流](https://gitea.idealjs.com/attachments/3ea5c7e4-da32-46c7-8af6-2a304eec223e) |
| learn 页取景框:视口内待办演示卡 → 零投影 | ![待办演示](https://gitea.idealjs.com/attachments/7eb64ef5-6b19-4db4-8cd0-aa04fece99fb) |
| 对照板:纸页内按钮 → 零投影 | ![对照板](https://gitea.idealjs.com/attachments/f99168bc-75f4-4a9c-ae7a-9b985fcc5022) |
| 知识卡:翻面钮 → 零投影 hover 换底色 | ![知识卡](https://gitea.idealjs.com/attachments/18bd2b8f-7b9a-4ace-a594-fc8c10f0ff8e) |
| 印章陈列:5px 投影 → 零投影 | ![印章](https://gitea.idealjs.com/attachments/9e780f74-c36c-4c33-9388-a4965029e0cb) |
| 装箱单:条目小印章 2px → 零投影 | ![装箱单](https://gitea.idealjs.com/attachments/27084691-b52b-4c64-9c5b-900556a63fbc) |
| Dropdown 演示触发器 → 零投影 | ![Dropdown](https://gitea.idealjs.com/attachments/4e893b58-1e33-4b2e-a9d8-61f66b54e763) |
| 取景框标本内按钮 → 零投影 | ![取景框](https://gitea.idealjs.com/attachments/89856ce9-ebc5-4f74-9f88-74af11ad5049) |

新增规范节「层级投影」(design-shadow 册):
![层级投影](https://gitea.idealjs.com/attachments/debd481c-256b-4324-9645-903ffc273ce1)

移动端 390×844(首页导航 / learn 页):
![移动首页](https://gitea.idealjs.com/attachments/58f25f53-0186-46d3-a12d-d985b7a89b26)
![移动learn](https://gitea.idealjs.com/attachments/e192b669-7a9f-4eee-8bc3-1f9b5884b33d)

---------

Co-authored-by: cqh963852 <cqh963852@hotmail.com>
Reviewed-on: #61
This commit was merged in pull request #61.
This commit is contained in:
arnold.cuiandcqh963852 committed 2026-11-19 07:01:49 +00:00
1 parent f928214e9d
commit 7b6797a848
26 files changed
+168 -90

No files matched your search

+8 -11
View File
@@ -3,9 +3,7 @@ import { expect, test } from '@playwright/test'
const PAGES = ['/index.html', '/design/', '/tutorial/ch7.html', '/blog/']
test.describe('navbar 品牌徽章一致性', () => {
test('各页面 brand 徽章:无背景填充、同款 3px 阴影(logo 恒定,不随页面翻转)', async ({
page,
}) => {
test('各页面 brand 徽章:无背景填充、嵌套零投影(logo 恒定,不随页面翻转)', async ({ page }) => {
const shadows: string[] = []
const backgrounds: string[] = []
for (const pagePath of PAGES) {
@@ -16,28 +14,27 @@ test.describe('navbar 品牌徽章一致性', () => {
shadows.push(await brand.evaluate((el) => getComputedStyle(el).boxShadow))
}
expect(new Set(backgrounds)).toEqual(new Set(['rgba(0, 0, 0, 0)']))
expect(new Set(shadows).size).toBe(1)
expect(shadows[0]).toContain('3px')
expect(new Set(shadows)).toEqual(new Set(['none']))
})
test('hover 抬升:阴影从 3px 变 5px', async ({ page }) => {
test('hover 反馈:嵌套钮不升影,换底色', async ({ page }) => {
await page.goto('/index.html', { timeout: 20_000 })
const brand = page.locator('header a').first()
const rest = await brand.evaluate((el) => getComputedStyle(el).boxShadow)
await brand.hover()
expect(rest).toContain('3px')
expect(rest).toBe('none')
await expect
.poll(async () => brand.evaluate((el) => getComputedStyle(el).boxShadow))
.toContain('5px')
.poll(async () => brand.evaluate((el) => getComputedStyle(el).backgroundColor))
.toContain('242, 234, 217')
})
test('移动抽屉 brand 同款阴影', async ({ page }) => {
test('移动抽屉 brand 同款零投影', async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 })
await page.goto('/index.html', { timeout: 20_000 })
await page.locator('label[for="site-nav-toggle"]').first().click()
const drawerBrand = page.locator('#site-nav-drawer a').first()
await expect(drawerBrand).toBeVisible()
const shadow = await drawerBrand.evaluate((el) => getComputedStyle(el).boxShadow)
expect(shadow).toContain('3px')
expect(shadow).toBe('none')
})
})
Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 129 KiB

+6 -5
View File
@@ -17,7 +17,9 @@ test.describe('练习场 · sidebar 导航(唯一导航形态)', () => {
}
})
test('桌面:brand 徽章 ghost 同款(无背景填充+3px 阴影),在线练习组高亮', async ({ page }) => {
test('桌面:brand 徽章 ghost 同款(无背景填充+嵌套零投影),在线练习组高亮', async ({
page,
}) => {
await page.setViewportSize({ width: 1280, height: 900 })
await page.goto('/practice/', { timeout: 20_000 })
const brand = page.locator(`${SIDEBAR} a`).first()
@@ -25,7 +27,7 @@ test.describe('练习场 · sidebar 导航(唯一导航形态)', () => {
const background = await brand.evaluate((el) => getComputedStyle(el).backgroundColor)
expect(background).toBe('rgba(0, 0, 0, 0)')
const shadow = await brand.evaluate((el) => getComputedStyle(el).boxShadow)
expect(shadow).toContain('3px')
expect(shadow).toBe('none')
const rowShadow = await page
.locator(`${SIDEBAR} a`, { hasText: '在线练习' })
.evaluate((el) => getComputedStyle(el).boxShadow)
@@ -53,9 +55,8 @@ test.describe('练习场 · sidebar 导航(唯一导航形态)', () => {
await page.mouse.move(370, 700)
const brand = sidebar.locator('a').first()
await expect(brand).toHaveText('idealjs stack')
await expect
.poll(async () => brand.evaluate((el) => getComputedStyle(el).boxShadow))
.toContain('3px')
const brandShadow = await brand.evaluate((el) => getComputedStyle(el).boxShadow)
expect(brandShadow).toBe('none')
await page.locator(OVERLAY).click({ position: { x: 370, y: 100 } })
await expect(sidebar).toBeHidden()
await page.locator(OPENER).click()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 129 KiB

@@ -4,6 +4,12 @@
教程站内的唯一定义处——特性只改这里,站点直接获得;结构契约与视觉基线的 E2E 在 `apps/tutorial/e2e/`。消费方式:源码直出(stack 构建期 strip TS),调用方按相对路径引 `src/design-system`。
## 阴影层级
影子是「拿在手里」的信号,只属于第一层:直接放在页面背景上的可交互内容(按钮、票券、大卡片)与覆盖页面的浮层(dropdown 面板、modal、sheet、页缘贴签)。嵌套在卡片内部的第二层可交互内容(卡内按钮、tab、条目、印章)一律零投影——卡片已经把内容托在纸面上了,卡内再投影就是影中影。这是设计系统哲学,不是单个组件的约定:任何新组件先问自己在第几层。
二层交互件的形态:描边(2px ink)+底色分层,hover 换底色或调亮度,按压位移 1px 不换影。`ShadowButton` / `Button` / `shadowButtonClasses` 的 `nested` 形态即此;learning 组件里的翻面钮(`.learning-action`)、工位卡(`.learning-flow-step`)、积木条目(`.learning-brick`)、印章(`.learning-stamp`)同样零投影。浮层内部照样分层:浮层本体投影合法,浮层里的按钮是二层。规范演示见 `design/shadow.html` 的「层级投影」一节。
`Ticket` 是独立的通用票券,内容通过 `children` 传入。票面先用 mask 打孔,内层 `.ticket-shadow` 包裹用 `filter: drop-shadow()` 根据挖空轮廓生成阴影;孔缘描边留在包裹之外,不参与投影(filter 不能放在被 mask 的票面上——同元素上 mask 在 filter 之后应用,会把孔位处的阴影一起裁掉)。上下孔的圆心使用同一个横坐标,位置相对于票面左侧计算。
```tsx
@@ -10,12 +10,16 @@ const TONE_BG = {
} as const
const BASE =
'inline-block cursor-pointer rounded-xl border-2 border-ink px-4 py-2 text-small font-bold text-ink no-underline shadow-ink hoverable-shadow transition-[translate,box-shadow] duration-150'
'inline-block cursor-pointer rounded-xl border-2 border-ink px-4 py-2 text-small font-bold text-ink no-underline shadow-ink hoverable-shadow transition-[translate,box-shadow,background-color,filter] duration-150'
const NESTED =
'inline-block cursor-pointer rounded-xl border-2 border-ink px-4 py-2 text-small font-bold text-ink no-underline transition-[background-color,filter] duration-150 hover:brightness-95 active:translate-y-[1px]'
export function Button({
tone = 'clash1a',
href,
disabled = false,
nested = false,
children,
}: {
tone?: keyof typeof TONE_BG
@@ -23,6 +27,8 @@ export function Button({
href?: string
disabled?: boolean
nested?: boolean
children: ReactNode
}) {
if (disabled) {
@@ -35,18 +41,27 @@ export function Button({
</span>
)
}
const cls = `${nested ? NESTED : BASE} ${TONE_BG[tone]}`
if (href) {
return (
return nested ? (
<a href={href} className={cls}>
{children}
</a>
) : (
<span className="hover-host inline-block">
<a href={href} className={`${BASE} ${TONE_BG[tone]}`}>
<a href={href} className={cls}>
{children}
</a>
</span>
)
}
return (
return nested ? (
<button type="button" className={cls}>
{children}
</button>
) : (
<span className="hover-host inline-block">
<button type="button" className={`${BASE} ${TONE_BG[tone]}`}>
<button type="button" className={cls}>
{children}
</button>
</span>
@@ -22,13 +22,15 @@ const TONE_BG: Record<ShadowButtonTone, string> = {
}
export const SHADOW_BUTTON_BASE =
'cursor-pointer items-center justify-center border-2 border-ink text-ink no-underline transition-[translate,box-shadow,background-color] duration-150 focus-visible:outline-[3px] focus-visible:outline-clash3b focus-visible:outline-offset-2'
'cursor-pointer items-center justify-center border-2 border-ink text-ink no-underline transition-[translate,box-shadow,background-color,filter] duration-150 focus-visible:outline-[3px] focus-visible:outline-clash3b focus-visible:outline-offset-2'
export const SHADOW_BUTTON_REST = 'shadow-[3px_3px_0_var(--color-ink)]'
export const SHADOW_BUTTON_ACTIVE =
'active:translate-x-[2px] active:translate-y-[2px] active:shadow-[1px_1px_0_var(--color-ink)]'
export const SHADOW_BUTTON_NESTED = 'hover:brightness-95 active:translate-y-[1px]'
const RING_REST =
'bg-paper-deep shadow-[inset_0_0_0_2px_var(--color-ink),3px_3px_0_var(--color-ink)]'
const RING_ACTIVE =
@@ -47,6 +49,8 @@ export interface ShadowButtonClassesOptions {
active?: boolean
nested?: boolean
size?: keyof typeof SIZE
className?: string
@@ -55,15 +59,18 @@ export interface ShadowButtonClassesOptions {
export function shadowButtonClasses({
tone = 'paper',
active = false,
nested = false,
size = 'md',
className = '',
}: ShadowButtonClassesOptions = {}) {
return [
SHADOW_BUTTON_BASE,
SIZE[size],
active
? `hoverable-shadow shadow-btn-ring ${RING_REST} ${RING_ACTIVE}`
: `hoverable-shadow shadow-btn ${TONE_BG[tone]} ${SHADOW_BUTTON_REST} ${SHADOW_BUTTON_ACTIVE}`,
nested
? `${TONE_BG[tone]} ${SHADOW_BUTTON_NESTED}`
: active
? `hoverable-shadow shadow-btn-ring ${RING_REST} ${RING_ACTIVE}`
: `hoverable-shadow shadow-btn ${TONE_BG[tone]} ${SHADOW_BUTTON_REST} ${SHADOW_BUTTON_ACTIVE}`,
className,
]
.filter(Boolean)
@@ -75,6 +82,8 @@ export interface ShadowButtonProps {
active?: boolean
nested?: boolean
href?: string
disabled?: boolean
@@ -89,6 +98,7 @@ export interface ShadowButtonProps {
export function ShadowButton({
tone = 'paper',
active = false,
nested = false,
href,
disabled = false,
size = 'md',
@@ -96,7 +106,7 @@ export function ShadowButton({
children,
onClick,
}: ShadowButtonProps) {
const cls = `inline-flex ${shadowButtonClasses({ tone, active, size, className })}`
const cls = `inline-flex ${shadowButtonClasses({ tone, active, nested, size, className })}`
if (disabled) {
return (
<span
@@ -108,17 +118,14 @@ export function ShadowButton({
</span>
)
}
return (
<span className="hover-host inline-flex">
{href ? (
<a href={href} data-comp="shadow-button" className={cls}>
{children}
</a>
) : (
<button type="button" data-comp="shadow-button" onClick={onClick} className={cls}>
{children}
</button>
)}
</span>
const inner = href ? (
<a href={href} data-comp="shadow-button" className={cls}>
{children}
</a>
) : (
<button type="button" data-comp="shadow-button" onClick={onClick} className={cls}>
{children}
</button>
)
return nested ? inner : <span className="hover-host inline-flex">{inner}</span>
}
@@ -106,12 +106,13 @@ export function SiteNavbar({
/>
<div className="relative z-40 flex flex-wrap items-center gap-1.5 max-lg:peer-checked/nav-drawer:[&_.nav-drawer-open]:invisible max-lg:peer-checked/nav-drawer:[&_.nav-drawer-close]:visible lg:peer-checked/nav-expand:[&_.nav-expand-open]:invisible lg:peer-checked/nav-expand:[&_.nav-expand-close]:visible">
<span className="hover-host mr-auto inline-flex">
<span className="mr-auto inline-flex">
<ShadowButton
tone="ghost"
href={brand.href}
size="none"
className="px-2.5 py-0.5 font-mono text-t2 font-extrabold"
nested
className="px-2.5 py-0.5 font-mono text-t2 font-extrabold hover:bg-paper-deep"
>
{brand.label}
</ShadowButton>
@@ -121,14 +122,14 @@ export function SiteNavbar({
{activeLabel}
</span>
)}
<span className="hover-host hidden lg:inline-grid">
<span className="hidden lg:inline-grid">
{/* biome-ignore lint/a11y/useAriaPropsSupportedByRole: 纯 CSS checkbox 开合的触发 label,aria 状态为增强语义保留 */}
<label
htmlFor="site-nav-expand"
aria-label="展开导航网格"
aria-expanded="false"
aria-controls="site-nav-drawer"
className={`nav-expand-open hidden lg:col-start-1 lg:row-start-1 lg:grid lg:size-10 lg:place-items-center ${shadowButtonClasses({ size: 'none' })}`}
className={`nav-expand-open hidden lg:col-start-1 lg:row-start-1 lg:grid lg:size-10 lg:place-items-center ${shadowButtonClasses({ size: 'none', nested: true, className: 'hover:bg-paper-deep' })}`}
>
<span aria-hidden="true" className="text-lg font-extrabold leading-none">
▼
@@ -140,21 +141,21 @@ export function SiteNavbar({
aria-label="收起导航网格"
aria-expanded="true"
aria-controls="site-nav-drawer"
className={`nav-expand-close hidden lg:col-start-1 lg:row-start-1 lg:invisible lg:grid lg:size-10 lg:place-items-center ${shadowButtonClasses({ size: 'none' })}`}
className={`nav-expand-close hidden lg:col-start-1 lg:row-start-1 lg:invisible lg:grid lg:size-10 lg:place-items-center ${shadowButtonClasses({ size: 'none', nested: true, className: 'hover:bg-paper-deep' })}`}
>
<span aria-hidden="true" className="text-lg font-extrabold leading-none">
▲
</span>
</label>
</span>
<span className="hover-host hidden max-lg:inline-grid">
<span className="hidden max-lg:inline-grid">
{/* biome-ignore lint/a11y/useAriaPropsSupportedByRole: 纯 CSS checkbox 开合的触发 label,aria 状态为增强语义保留 */}
<label
htmlFor="site-nav-toggle"
aria-label="打开导航菜单"
aria-expanded="false"
aria-controls="site-nav-drawer"
className={`nav-drawer-open hidden max-lg:col-start-1 max-lg:row-start-1 max-lg:grid max-lg:size-10 max-lg:place-items-center ${shadowButtonClasses({ size: 'none' })}`}
className={`nav-drawer-open hidden max-lg:col-start-1 max-lg:row-start-1 max-lg:grid max-lg:size-10 max-lg:place-items-center ${shadowButtonClasses({ size: 'none', nested: true, className: 'hover:bg-paper-deep' })}`}
>
<span aria-hidden="true" className="flex flex-col gap-[5px]">
<i className="block h-[3px] w-5 rounded-sm bg-ink" />
@@ -168,7 +169,7 @@ export function SiteNavbar({
aria-label="收起导航菜单"
aria-expanded="true"
aria-controls="site-nav-drawer"
className={`nav-drawer-close hidden max-lg:col-start-1 max-lg:row-start-1 max-lg:invisible max-lg:grid max-lg:size-10 max-lg:place-items-center ${shadowButtonClasses({ size: 'none' })}`}
className={`nav-drawer-close hidden max-lg:col-start-1 max-lg:row-start-1 max-lg:invisible max-lg:grid max-lg:size-10 max-lg:place-items-center ${shadowButtonClasses({ size: 'none', nested: true, className: 'hover:bg-paper-deep' })}`}
>
<span aria-hidden="true" className="text-lg font-extrabold leading-none">
×
@@ -182,11 +183,15 @@ export function SiteNavbar({
className="max-lg:fixed max-lg:inset-y-0 max-lg:left-0 max-lg:z-50 max-lg:w-72 max-lg:overflow-y-auto max-lg:rounded-none max-lg:border-r-2 max-lg:border-ink max-lg:bg-paper max-lg:px-4 max-lg:py-5 max-lg:shadow-[8px_0_0_0_var(--color-ink)] max-lg:invisible max-lg:opacity-0 max-lg:-translate-x-full max-lg:transition-[transform,visibility,opacity] max-lg:duration-300 max-lg:ease-[cubic-bezier(0.32,0.72,0,1)] max-lg:motion-reduce:transition-none max-lg:peer-checked/nav-drawer:visible max-lg:peer-checked/nav-drawer:translate-x-0 max-lg:peer-checked/nav-drawer:opacity-100 lg:pointer-events-none lg:absolute lg:inset-x-0 lg:top-full lg:z-40 lg:mt-2 lg:rounded-2xl lg:border-2 lg:border-ink lg:bg-paper lg:p-3 lg:shadow-ink-lift lg:invisible lg:opacity-0 lg:-translate-y-1 lg:transition-[transform,visibility,opacity] lg:duration-300 lg:ease-[cubic-bezier(0.32,0.72,0,1)] lg:motion-reduce:transition-none lg:peer-checked/nav-expand:pointer-events-auto lg:peer-checked/nav-expand:visible lg:peer-checked/nav-expand:opacity-100 lg:peer-checked/nav-expand:translate-y-0"
>
<div className="lg:hidden max-lg:mb-5">
<span className="hover-host inline-flex">
<ShadowButton tone="ghost" href={brand.href} size="sm" className="font-mono">
{brand.label}
</ShadowButton>
</span>
<ShadowButton
tone="ghost"
href={brand.href}
size="sm"
nested
className="font-mono hover:bg-paper-deep"
>
{brand.label}
</ShadowButton>
</div>
<div className="grid gap-x-1.5 gap-y-2 max-lg:grid-cols-2 lg:grid-cols-[96px_repeat(6,minmax(0,1fr))]">
{bands.map(({ row, divider, start, span }) => (
@@ -48,19 +48,23 @@ export function SiteSidebar({
className="max-lg:fixed max-lg:inset-y-0 max-lg:left-0 max-lg:z-50 max-lg:w-72 max-lg:overflow-y-auto max-lg:shadow-[8px_0_0_0_var(--color-ink)] max-lg:invisible max-lg:opacity-0 max-lg:-translate-x-full max-lg:transition-[transform,visibility,opacity] max-lg:duration-300 max-lg:ease-[cubic-bezier(0.32,0.72,0,1)] max-lg:motion-reduce:transition-none max-lg:peer-checked:visible max-lg:peer-checked:translate-x-0 max-lg:peer-checked:opacity-100 lg:sticky lg:top-0 lg:h-dvh lg:w-60 lg:shrink-0 overflow-y-auto border-r-2 border-ink bg-paper px-4 py-5"
>
<div className="mb-5 flex items-center justify-between">
<span className="hover-host inline-flex">
<ShadowButton tone="ghost" href={brand.href} size="sm" className="font-mono">
{brand.label}
</ShadowButton>
</span>
<span className="hover-host inline-flex lg:hidden">
<ShadowButton
tone="ghost"
href={brand.href}
size="sm"
nested
className="font-mono hover:bg-paper-deep"
>
{brand.label}
</ShadowButton>
<span className="inline-flex lg:hidden">
{/* biome-ignore lint/a11y/useAriaPropsSupportedByRole: 纯 CSS checkbox 开合的触发 label,aria 状态为增强语义保留 */}
<label
htmlFor="site-sidebar-toggle"
aria-label="收起侧栏导航"
aria-expanded="true"
aria-controls="site-sidebar-drawer"
className={`grid size-8 cursor-pointer place-items-center text-lg font-extrabold leading-none ${shadowButtonClasses({ size: 'none' })}`}
className={`grid size-8 cursor-pointer place-items-center text-lg font-extrabold leading-none ${shadowButtonClasses({ size: 'none', nested: true, className: 'hover:bg-paper-deep' })}`}
>
<span aria-hidden="true">×</span>
</label>
@@ -68,18 +68,15 @@
font-size: 12px;
font-weight: 800;
cursor: pointer;
box-shadow: 3px 3px 0 var(--color-ink);
transition:
transform 150ms,
box-shadow 150ms;
background-color 150ms;
}
.learning-action:hover {
transform: translateY(-2px);
box-shadow: 5px 5px 0 var(--color-ink);
background: var(--color-paper-deep);
}
.learning-action:active {
transform: translate(2px, 2px);
box-shadow: 1px 1px 0 var(--color-ink);
transform: translate(1px, 1px);
}
.learning-clipboard {
@@ -640,7 +637,6 @@
border-radius: 6px;
background: var(--color-clash1b);
color: var(--color-ink);
box-shadow: var(--shadow-ink);
font-family: inherit;
font-size: 12px;
font-weight: 800;
@@ -740,7 +736,6 @@
border: 2px solid var(--color-ink);
border-radius: 5px;
background: var(--color-paper);
box-shadow: 3px 3px 0 var(--color-ink);
}
.learning-brick summary {
position: relative;
@@ -976,7 +971,6 @@
.learning-manifest-stamp {
padding: 2px 8px;
font-size: 10px;
box-shadow: 2px 2px 0 var(--color-ink);
}
.learning-manifest footer > span {
color: var(--color-mute);
@@ -1277,18 +1271,14 @@
border: 2px solid var(--color-ink);
border-radius: 5px;
background: var(--color-paper);
box-shadow: 3px 3px 0 var(--color-ink);
transition:
transform 150ms,
box-shadow 150ms;
transition: background-color 150ms;
}
.learning-flow-step[data-input="true"] {
border-style: dashed;
}
.learning-flow-step:hover {
transform: translateY(-2px);
box-shadow: 5px 5px 0 var(--color-ink);
background: var(--color-clash2a);
}
.learning-flow-step[data-clickable="true"] {
cursor: pointer;
@@ -33,7 +33,7 @@ export function BrowserMockupPreview() {
<p className="m-0 text-small text-[#555]">
设计系统组件可以直接放进视口,比如这句里的<Mark>荧光标记</Mark>。
</p>
<ShadowButton>进入教程</ShadowButton>
<ShadowButton nested>进入教程</ShadowButton>
</div>
</div>
</BrowserMockup>
@@ -23,7 +23,7 @@ export function DropdownPreview() {
label="向下 · tips 形"
open={downOpen}
onOpenChange={setDownOpen}
triggerClassName="flex items-center gap-1.5 rounded-full border-2 border-ink bg-paper px-3 py-1.5 text-[12.5px] font-extrabold text-ink shadow-[3px_3px_0_var(--color-ink)] transition-[translate] duration-150 motion-reduce:transition-none hover:-translate-y-0.5"
triggerClassName="flex items-center gap-1.5 rounded-full border-2 border-ink bg-paper px-3 py-1.5 text-[12.5px] font-extrabold text-ink transition-[background-color] duration-150 motion-reduce:transition-none hover:bg-paper-deep"
trigger={
<>
<span aria-hidden>💡</span>
@@ -63,7 +63,7 @@ export function DropdownPreview() {
onOpenChange={setUpOpen}
placement="top"
panelClassName="w-[min(360px,100vw_-_24px)]"
triggerClassName="flex cursor-pointer items-center gap-2 rounded-t-lg border-2 border-ink bg-clash2a py-2 pr-4 pl-3 text-[12.5px] font-extrabold text-ink shadow-[3px_3px_0_var(--color-ink)]"
triggerClassName="flex cursor-pointer items-center gap-2 rounded-t-lg border-2 border-ink bg-clash2a py-2 pr-4 pl-3 text-[12.5px] font-extrabold text-ink transition-[filter] duration-150 motion-reduce:transition-none hover:brightness-95"
trigger={
<>
<span
+53 -1
View File
@@ -104,12 +104,21 @@ function PaperCard({ hover = false }: { hover?: boolean }) {
)
}
function HostCard({ children }: { children: ReactNode }) {
return (
<div className="w-fit rounded-xl border-2 border-ink bg-paper p-4 shadow-ink">
<b className="text-small">第一层纸卡</b>
<div className="mt-3">{children}</div>
</div>
)
}
export function App() {
return (
<Page
active="design-shadow"
title="阴影 · 硬投影"
desc="全站只有一种影子:实心硬投影,分静置与拿起两档;撕角、打孔这类异形用轮廓投影;覆盖内容的浮层直接用拿起档。"
desc="全站只有一种影子:实心硬投影,分静置与拿起两档;影子只属于第一层——页面直排的票券/按钮/大卡与浮层,嵌套在卡内的二层交互件零投影,改用描边与底色分层。"
>
<Section label="四种影子">
<ShapeGroup name="硬投影" hint="box-shadow">
@@ -245,6 +254,49 @@ export function App() {
</div>
</Section>
<Section
label="层级投影 · 影子只属于第一层"
note="影子是「拿在手里」的信号:直接放在页面背景上的票券、按钮、大卡,以及覆盖页面的浮层,才有资格投影;嵌套在卡片内部的二层交互件(卡内按钮、tab、条目、印章)零投影——卡片已经把内容托在纸面上了,卡内再投影就是影中影"
>
<Rule
demo={
<>
<DoDont bad text="卡内按钮带投影:影中影">
<HostCard>
<button
type="button"
className="cursor-pointer rounded-lg border-2 border-ink bg-paper px-3 py-1.5 text-small font-bold text-ink shadow-[3px_3px_0_var(--color-ink)]"
>
卡内按钮
</button>
</HostCard>
</DoDont>
<DoDont text="卡内按钮零投影:描边+底色分层,hover 换底色">
<HostCard>
<button
type="button"
className="cursor-pointer rounded-lg border-2 border-ink bg-paper px-3 py-1.5 text-small font-bold text-ink transition-[background-color] duration-150 hover:bg-paper-deep active:translate-y-[1px]"
>
卡内按钮
</button>
</HostCard>
</DoDont>
</>
}
/>
<p className="mt-4 mb-0 text-content text-body">
二层交互件的完整形态:
<b className="t-small-strong">
描边(2px ink)+底色,hover 换底色或调亮度,按压位移 1px 不换影
</b>
。ShadowButton / Button 的
<code className="mx-1 rounded bg-paper-deep px-1.5 py-0.5 font-mono text-[12.5px]">
nested
</code>
形态、learning 组件里的翻面钮、工位卡、印章都按此执行。
</p>
</Section>
<Section
label="触发模型 · hover-host"
note="位移的 :hover 挂在不动的宿主上——命中区不跟位移,底边不抖"
+3 -1
View File
@@ -278,7 +278,9 @@ export function App() {
<p className="learn-environment-note">
首次搭建预留 30–60 分钟,从「快速开始」查看环境准备。
</p>
<Button href={relHref('learn', 'ch1')}>查看本地环境准备</Button>
<Button href={relHref('learn', 'ch1')} nested>
查看本地环境准备
</Button>
</>
),
}}
+3 -8
View File
@@ -23,18 +23,13 @@
font-weight: 800;
line-height: 1;
cursor: pointer;
box-shadow: 2px 2px 0 var(--color-ink);
transition:
translate 150ms,
box-shadow 150ms;
transition: background-color 150ms;
}
.learn-tour-close:hover {
translate: -1px -1px;
box-shadow: 3px 3px 0 var(--color-ink);
background: var(--color-paper-deep);
}
.learn-tour-close:active {
translate: 1px 1px;
box-shadow: 1px 1px 0 var(--color-ink);
background: var(--color-paper-deep);
}
.learn-tour-close:focus-visible {
outline: 3px solid var(--color-clash3b);
-1
View File
@@ -36,7 +36,6 @@
border: 2px solid var(--color-ink);
border-radius: 10px;
background: #fff;
box-shadow: var(--shadow-ink);
}
.learn-preview-note {
margin: 8px 0 0;
@@ -71,7 +71,7 @@ function PracticeDock({ open, onToggle }: { open: boolean; onToggle: () => void
<>
<FileTabs />
<CodeEditor className="min-h-[360px] flex-1" />
<RunRow />
<RunRow nested />
</>
}
sandbox={<SandboxPane />}
+7 -2
View File
@@ -122,11 +122,16 @@ export function CodeEditor({ className = '' }: { className?: string }) {
)
}
export function RunRow() {
export function RunRow({ nested = false }: { nested?: boolean }) {
const { active, building, engineReady, run } = usePlayground()
return (
<div className="mt-2.5 flex items-center gap-3">
<ShadowButton tone="clash1a" onClick={run} disabled={building || !engineReady}>
<ShadowButton
tone="clash1a"
onClick={run}
disabled={building || !engineReady}
nested={nested}
>
{engineReady ? '运行 ▶' : '引擎加载中…'}
</ShadowButton>
<span className="t-small-mute">