style: refine CHRNX canvas and hero

This commit is contained in:
chrnx committed 2026-08-12 14:40:06 -05:00
1 parent c95d8ffa9a
commit f56ea601d2
3 files changed
+111 -19

No files matched your search

+54
View File
@@ -35,6 +35,60 @@ test( 'home remains coherent at all approved review viewports', async ( { page }
}
} );
test( 'explicit themes use an atmospheric canvas and a compact home introduction', async ( {
page,
} ) => {
const canvases = new Map();
for ( const theme of [ 'Dark', 'Light' ] ) {
await page.setViewportSize( { width: 1440, height: 900 } );
await page.goto( '/' );
await page.getByRole( 'radio', { name: theme, exact: true } ).check();
await expect( page.locator( 'html' ) ).toHaveAttribute( 'data-theme', theme.toLowerCase() );
const desktop = await page.evaluate( () => {
const hero = document.querySelector( '.chrnx-home-intro' );
const bodyStyle = window.getComputedStyle( document.body );
const heroRect = hero.getBoundingClientRect();
return {
backgroundColor: bodyStyle.backgroundColor,
backgroundImage: bodyStyle.backgroundImage,
backgroundRepeat: bodyStyle.backgroundRepeat,
backgroundSize: bodyStyle.backgroundSize,
heroHeight: heroRect.height,
};
} );
expect( desktop.backgroundImage ).toMatch( /(?:radial|linear)-gradient/ );
expect( desktop.backgroundImage ).not.toBe( 'none' );
expect(
desktop.backgroundRepeat.split( ', ' ).every( ( value ) => value === 'no-repeat' ),
).toBeTruthy();
expect( desktop.backgroundSize ).not.toMatch( /(?:32|48)px\s+(?:32|48)px/ );
expect( desktop.heroHeight ).toBeGreaterThanOrEqual( 900 * 0.6 - 1 );
expect( desktop.heroHeight ).toBeLessThanOrEqual( 900 * 0.68 + 1 );
expect( desktop.heroHeight ).toBeLessThanOrEqual( 42 * 16 + 1 );
canvases.set( theme, `${ desktop.backgroundColor } ${ desktop.backgroundImage }` );
await page.setViewportSize( { width: 375, height: 812 } );
const mobile = await page.locator( '.chrnx-home-intro' ).evaluate( ( hero ) => {
const heroRect = hero.getBoundingClientRect();
const paragraphRect = hero.querySelector( 'p' ).getBoundingClientRect();
const style = window.getComputedStyle( hero );
return {
height: heroRect.height,
trailingSpace: heroRect.bottom - paragraphRect.bottom,
sectionSpacing: Number.parseFloat( style.paddingBottom ),
};
} );
expect( mobile.height ).toBeLessThanOrEqual( 34 * 16 + 1 );
expect( mobile.trailingSpace ).toBeLessThanOrEqual( mobile.sectionSpacing + 1 );
}
expect( canvases.get( 'Dark' ) ).not.toBe( canvases.get( 'Light' ) );
} );
test( 'seeded post permalink resolves its single template', async ( { page } ) => {
const title = 'The save file remembers what the hero pretends to forget';
const expectedPath = '/the-save-file-remembers-what-the-hero-pretends-to-forget/';
+28
View File
@@ -76,6 +76,34 @@ test( 'the visual layer is separately enqueued and covers responsive accessible
assert.match( components, /html\[data-theme="light"\]/ );
} );
test( 'the page canvas is atmospheric rather than a repeating grid', () => {
const components = read( 'assets/css/components.css' );
const bodyRule = components.match( /body,[\s\S]*?:root:not\(\[data-theme\]\) body\s*\{(?<declarations>[\s\S]*?)\n\}/ )?.groups?.declarations ?? '';
assert.match( bodyRule, /background-repeat:\s*no-repeat(?:,\s*no-repeat)*;/ );
assert.doesNotMatch(
bodyRule,
/linear-gradient\([^)]*1px,\s*transparent\s+1px\)[\s\S]*linear-gradient\(90deg,[^)]*1px,\s*transparent\s+1px\)/,
);
assert.doesNotMatch( bodyRule, /background-size:\s*[^;]*(?:2|3)rem\s+(?:2|3)rem/ );
assert.doesNotMatch(
components,
/@media\s*\(max-width:\s*599px\)[\s\S]*?body\s*\{[\s\S]*?background-size:/,
);
} );
test( 'the home introduction declares compact desktop and mobile bounds', () => {
const components = read( 'assets/css/components.css' );
const desktopRule = components.match( /\.chrnx-home\s*>\s*\.chrnx-home-intro\s*\{(?<declarations>[\s\S]*?)\n\}/ )?.groups?.declarations ?? '';
const mobileRules = components.match( /@media\s*\(max-width:\s*599px\)[\s\S]*$/ )?.[ 0 ] ?? '';
const mobileRule = mobileRules.match( /\.chrnx-home\s*>\s*\.chrnx-home-intro\s*\{(?<declarations>[\s\S]*?)\n\t\}/ )?.groups?.declarations ?? '';
assert.match( desktopRule, /min-height:\s*min\((?:6[0-8])vh,\s*42rem\);/ );
assert.match( mobileRule, /min-height:\s*auto;/ );
assert.match( mobileRule, /max-height:\s*34rem;/ );
assert.match( mobileRule, /align-content:\s*start;/ );
} );
test( 'all approved portraits rebuild byte-identically within payload bounds', () => {
const readme = read( 'README.md' );
const documentedCommand = 'mktemp -d "${TMPDIR:-/tmp}/chrnx-responsive.XXXXXX"';