迁移A04为自适应文档流

This commit is contained in:
rain
2026-07-21 11:49:46 +08:00
parent 5a86803f9b
commit a28678ca0b
3 changed files with 70 additions and 76 deletions
+27 -1
View File
@@ -87,10 +87,36 @@ foreach ($required in @(
$contentRule = [regex]::Match($register, '(?ms)^\.register-content\s*\{(?<Body>.*?)^\}')
if (-not $contentRule.Success) { throw 'A04 register content rule is missing.' }
foreach ($required in @('display: flex;', 'flex: 1;', 'flex-direction: column;', 'max-width: 480px;', 'margin: 0 auto;')) {
foreach ($required in @('display: flex;', 'flex: 1;', 'flex-direction: column;', 'justify-content: flex-start;', 'max-width: 480px;', 'margin: 0 auto;')) {
Assert-Contains -Content $contentRule.Groups['Body'].Value -Expected $required -Message "A04 register content must use document flow: $required"
}
$headingRule = [regex]::Match($register, '(?ms)^\.page-heading\s*\{(?<Body>.*?)^\}')
if (-not $headingRule.Success) { throw 'A04 page heading rule is missing.' }
Assert-Contains -Content $headingRule.Groups['Body'].Value -Expected 'grid-template-columns: minmax(0, 1fr);' -Message 'A04 heading must center against the full content width.'
foreach ($selector in @('page-title', 'page-subtitle', 'register-divider')) {
$rule = [regex]::Match($register, "(?ms)^\.$selector\s*\{(?<Body>.*?)^\}")
if (-not $rule.Success) { throw "A04 heading child rule is missing: $selector" }
Assert-Contains -Content $rule.Groups['Body'].Value -Expected 'grid-column: 1;' -Message "A04 heading child must remain in the full-width grid column: $selector"
}
foreach ($ruleContract in @(
@{ Selector = 'register-submit__content'; Expected = 'font-size: 36rpx;' },
@{ Selector = 'agreement-row'; Expected = 'font-size: 24rpx;' },
@{ Selector = 'agreement-row'; Expected = 'color: #493323;' },
@{ Selector = 'input-label'; Expected = 'font-size: 30rpx;' },
@{ Selector = 'auth-input'; Expected = 'font-size: 30rpx;' },
@{ Selector = 'auth-input'; Expected = 'color: #493323;' },
@{ Selector = 'placeholder'; Expected = 'color: #9f968d;' },
@{ Selector = 'login-entry'; Expected = 'font-size: 28rpx;' },
@{ Selector = 'login-entry'; Expected = 'color: #493323;' },
@{ Selector = 'login-entry'; Expected = 'margin-top: auto;' }
)) {
$rule = [regex]::Match($register, "(?ms)^\.$($ruleContract.Selector)\s*\{(?<Body>.*?)^\}")
if (-not $rule.Success) { throw "A04 style rule is missing: $($ruleContract.Selector)" }
Assert-Contains -Content $rule.Groups['Body'].Value -Expected $ruleContract.Expected -Message "A04 typography must match A01: $($ruleContract.Selector) $($ruleContract.Expected)"
}
foreach ($forbidden in @(
'(?s)\.register-panel\s*\{[^}]*\bborder\s*:',
'(?s)\.register-panel\s*\{[^}]*\bbackground\s*:',
+3
View File
@@ -83,6 +83,7 @@ const run = async () => {
const header = document.querySelector('.auth-shell__header')
const headerImage = document.querySelector('.auth-shell__header-image img')
const paper = document.querySelector('.auth-shell__paper')
const title = document.querySelector('.page-title')
const loginEntry = document.querySelector('.login-entry')
return {
width: document.documentElement.scrollWidth,
@@ -93,6 +94,7 @@ const run = async () => {
headerNaturalWidth: headerImage?.naturalWidth,
headerNaturalHeight: headerImage?.naturalHeight,
paperTop: paper?.getBoundingClientRect().top,
titleCenter: title ? title.getBoundingClientRect().left + title.getBoundingClientRect().width / 2 : null,
loginEntryBottom: loginEntry?.getBoundingClientRect().bottom + window.scrollY
}
})()`)
@@ -100,6 +102,7 @@ const run = async () => {
assert.deepStrictEqual([metrics.headerNaturalWidth, metrics.headerNaturalHeight], [824, 340], `A04 header asset changed at ${size.width}x${size.height}`)
assert(Math.abs(metrics.headerImageHeight / metrics.headerImageWidth - 340 / 824) < 0.01, `A04 header is distorted at ${size.width}x${size.height}`)
assert(metrics.paperTop >= metrics.headerBottom - 1, `A04 paper overlaps its header at ${size.width}x${size.height}`)
assert(Math.abs(metrics.titleCenter - size.width / 2) <= 1, `A04 title is not centered at ${size.width}x${size.height}: ${metrics.titleCenter}`)
assert(metrics.loginEntryBottom <= metrics.documentScrollHeight + 1, `A04 last action is unreachable at ${size.width}x${size.height}`)
}