style: apply CHRNX character-led sections

This commit is contained in:
chrnx committed 2026-08-12 17:40:22 -05:00
1 parent 5518e3598a
commit 11ac0ac715
3 files changed
+643 -8

No files matched your search

+318 -8
View File
@@ -754,15 +754,12 @@ html[data-theme="light"] .chrnx-home-music p {
}
.chrnx-topic-hero {
display: grid;
min-height: 30rem;
grid-template-columns: minmax(0, 1fr) minmax(15rem, 0.65fr);
align-items: end;
overflow: hidden;
display: block;
min-height: 0;
overflow: visible;
margin-bottom: 3rem;
border: 1px solid var(--chrnx-line);
border-radius: calc(var(--chrnx-radius) * 1.5);
background: linear-gradient(135deg, var(--chrnx-surface), var(--chrnx-accent-soft));
border: 0;
background: none;
}
.chrnx-topic-hero__content {
@@ -1087,3 +1084,316 @@ html[data-theme="light"] .chrnx-home-music p {
scroll-behavior: auto;
}
}
/* Shared character-led section frame. */
.chrnx-character-stage {
--chrnx-character-accent: var(--chrnx-accent);
--chrnx-character-halo: color-mix(in srgb, var(--chrnx-character-accent) 30%, transparent);
--chrnx-character-wash: color-mix(in srgb, var(--chrnx-character-accent) 12%, transparent);
--chrnx-character-shadow: drop-shadow(0 1.75rem 1.5rem rgb(0 0 0 / 32%));
position: relative;
display: grid;
box-sizing: border-box;
min-height: clamp(30rem, 44vw, 38rem);
grid-template-columns: minmax(0, 55fr) minmax(0, 45fr);
isolation: isolate;
overflow: clip;
border: 1px solid color-mix(in srgb, var(--chrnx-character-accent) 32%, var(--chrnx-line));
border-radius: calc(var(--chrnx-radius) * 1.5);
background-color: var(--chrnx-surface);
background-image: linear-gradient(125deg, var(--chrnx-surface) 0 45%, var(--chrnx-character-wash) 100%);
box-shadow: var(--chrnx-shadow);
color: var(--chrnx-text);
}
.chrnx-character-stage__atmosphere {
position: absolute;
z-index: 0;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.chrnx-character-stage__atmosphere::before {
position: absolute;
top: 8%;
right: -4%;
width: min(48rem, 62%);
aspect-ratio: 1;
border-radius: 50%;
background: radial-gradient(circle, var(--chrnx-character-halo) 0 24%, transparent 68%);
content: "";
filter: blur(0.2rem);
}
.chrnx-character-stage__atmosphere::after {
position: absolute;
inset: 0;
background-image:
linear-gradient(112deg, transparent 0 49%, var(--chrnx-character-wash) 49.5% 50.5%, transparent 51%),
linear-gradient(28deg, transparent 0 72%, color-mix(in srgb, var(--chrnx-character-accent) 18%, transparent) 72.5% 74%, transparent 74.5%),
radial-gradient(ellipse at 78% 100%, rgb(0 0 0 / 20%) 0 12%, transparent 42%);
content: "";
}
.chrnx-character-stage__content {
position: relative;
z-index: 2;
display: grid;
box-sizing: border-box;
width: 100%;
min-width: 0;
align-content: center;
align-self: stretch;
grid-column: 1;
grid-row: 1;
margin: 0 !important;
padding: clamp(2rem, 5vw, 5rem);
color: var(--chrnx-text);
}
.chrnx-character-stage__content > :first-child {
margin-block-start: 0;
}
.chrnx-character-stage__content > :last-child {
margin-block-end: 0;
}
.chrnx-character-stage__art {
position: relative;
z-index: 3;
display: flex;
box-sizing: border-box;
width: 100%;
min-width: 0;
height: 100%;
align-self: end;
align-items: end;
justify-content: center;
grid-column: 2;
grid-row: 1;
margin: 0;
}
.chrnx-character-stage__art::before {
position: absolute;
z-index: 1;
right: 5%;
bottom: -1.25rem;
left: 5%;
height: 4.5rem;
border-radius: 50%;
background: radial-gradient(ellipse, rgb(0 0 0 / 38%), transparent 68%);
content: "";
filter: blur(0.55rem);
}
.chrnx-character-stage__art > .chrnx-responsive-portrait {
position: relative;
z-index: 2;
display: flex;
width: 100%;
height: 100%;
align-items: end;
justify-content: center;
margin: 0;
}
.chrnx-character-stage__art img {
display: block;
width: 100%;
height: auto;
max-height: clamp(28rem, 44vw, 38rem);
object-fit: contain;
object-position: center bottom;
filter: var(--chrnx-character-shadow) saturate(0.96) contrast(1.04);
}
.chrnx-character-stage__secondary-art {
position: absolute;
z-index: 1;
right: 27%;
bottom: 0;
width: min(29%, 18rem);
height: auto;
opacity: 0.34;
filter: saturate(0.55) contrast(1.08) drop-shadow(0 1rem 2rem rgb(0 0 0 / 24%));
}
.chrnx-character-stage__atmosphere > .chrnx-responsive-portrait {
position: absolute;
z-index: 1;
inset: 0;
width: 100%;
height: 100%;
}
.chrnx-character-stage__atmosphere .chrnx-character-stage__collage {
width: 100%;
height: 100%;
object-fit: cover;
object-position: 68% center;
filter: saturate(0.68) contrast(1.08);
opacity: 0.46;
}
.chrnx-music-landing .chrnx-character-stage__content > .chrnx-responsive-portrait:has(.chrnx-character-stage__collage) {
position: absolute;
z-index: 0;
inset: 0;
width: 100%;
height: 100%;
overflow: hidden;
opacity: 0.28;
}
.chrnx-music-landing .chrnx-character-stage__content > h2,
.chrnx-music-landing .chrnx-character-stage__content > p {
position: relative;
z-index: 1;
}
.chrnx-music-landing .chrnx-character-stage__collage {
width: 100%;
height: 100%;
object-fit: cover;
filter: saturate(0.72) contrast(1.08);
}
.chrnx-home-projects .chrnx-character-stage,
.is-topic-code .chrnx-character-stage {
--chrnx-character-accent: #59c3c3;
}
.is-topic-research .chrnx-character-stage {
--chrnx-character-accent: #a5d66a;
}
.is-topic-literature .chrnx-character-stage {
--chrnx-character-accent: #b88ad9;
}
.chrnx-home-music .chrnx-character-stage,
.chrnx-music-landing .chrnx-character-stage,
.is-topic-music .chrnx-character-stage {
--chrnx-character-accent: #d36b3f;
}
.chrnx-home-music .chrnx-character-stage,
.chrnx-music-landing .chrnx-character-stage {
background-color: #0d1117;
background-image: linear-gradient(125deg, #0d1117 0 45%, rgb(84 38 15 / 72%) 100%);
color: #e6edf3;
}
.chrnx-home-music .chrnx-character-stage__content,
.chrnx-home-music .chrnx-character-stage__content h2,
.chrnx-home-music .chrnx-character-stage__content p,
.chrnx-music-landing .chrnx-character-stage__content,
.chrnx-music-landing .chrnx-character-stage__content h2,
.chrnx-music-landing .chrnx-character-stage__content p,
.chrnx-music-landing .chrnx-character-stage__content a {
color: #e6edf3;
}
.chrnx-podcast-landing .chrnx-character-stage,
.is-topic-podcasts .chrnx-character-stage,
.is-topic-silicon-ranch .chrnx-character-stage {
--chrnx-character-accent: #58a7d8;
}
.chrnx-about .chrnx-character-stage,
.is-topic-life .chrnx-character-stage {
--chrnx-character-accent: #e0b75b;
}
.is-topic-gaming .chrnx-character-stage {
--chrnx-character-accent: #da7b45;
}
.chrnx-topic-hero__fallback {
position: absolute;
right: 9%;
bottom: 0;
width: min(36%, 24rem);
aspect-ratio: 0.78;
border: 1px solid color-mix(in srgb, var(--chrnx-character-accent) 46%, transparent);
border-bottom: 0;
border-radius: 48% 48% 0 0;
background:
radial-gradient(circle at 50% 26%, var(--chrnx-character-halo) 0 14%, transparent 15%),
linear-gradient(145deg, var(--chrnx-character-wash), transparent 62%);
box-shadow: 0 1.5rem 3rem rgb(0 0 0 / 18%);
}
.chrnx-character-facets {
position: relative;
z-index: 0;
opacity: 0.84;
}
.chrnx-character-facets .chrnx-section-portrait {
filter: saturate(0.72) contrast(1.02) drop-shadow(0 1rem 1.25rem rgb(0 0 0 / 20%));
}
@media (max-width: 780px) {
.chrnx-topic-hero {
min-height: 0;
}
.chrnx-character-stage {
min-height: 0;
grid-template-columns: 1fr;
grid-template-rows: auto auto;
}
.chrnx-character-stage__content {
align-self: start;
grid-column: 1;
grid-row: 1;
padding: clamp(1.5rem, 7vw, 3rem);
}
.chrnx-character-stage__art {
width: 76%;
height: clamp(20rem, 100vw, 34rem);
justify-self: end;
grid-column: 1;
grid-row: 2;
margin: 0;
}
.chrnx-character-stage__art img {
max-height: 100%;
}
.chrnx-character-stage__secondary-art {
display: none;
}
.chrnx-character-stage__atmosphere::before {
top: auto;
right: -18%;
bottom: 0;
width: 100%;
}
.chrnx-character-stage__atmosphere .chrnx-character-stage__collage {
object-position: 62% center;
opacity: 0.34;
}
}
@media (prefers-reduced-motion: reduce) {
.chrnx-character-stage,
.chrnx-character-stage *,
.chrnx-character-stage::before,
.chrnx-character-stage::after {
animation: none !important;
transition: none !important;
}
}
+306
View File
@@ -8,6 +8,107 @@ const viewports = [
{ width: 2560, height: 1440 },
];
const characterSurfaces = [
{ name: 'home-projects', path: '/', selector: '.chrnx-home-projects .chrnx-character-stage' },
{ name: 'home-music', path: '/', selector: '.chrnx-home-music .chrnx-character-stage' },
{ name: 'projects', path: '/projects/', selector: '.chrnx-home-projects .chrnx-character-stage' },
{ name: 'music', path: '/music/', selector: '.chrnx-music-landing .chrnx-character-stage' },
{
name: 'podcasts',
path: '/podcasts/',
selector: '.chrnx-podcast-landing .chrnx-character-stage',
},
{ name: 'about', path: '/about/', selector: '.chrnx-about .chrnx-character-stage' },
{
name: 'show-silicon-ranch',
path: '/show/silicon-ranch/',
selector: '.chrnx-topic-hero .chrnx-character-stage',
},
...[ 'research', 'code', 'literature', 'music', 'podcasts', 'life', 'gaming' ].map(
( topic ) => ( {
name: `topic-${ topic }`,
path: `/topic/${ topic }/`,
selector: '.chrnx-topic-hero .chrnx-character-stage',
} ),
),
];
async function setExplicitTheme( page, theme ) {
await page.addInitScript( ( value ) => {
window.localStorage.setItem( 'chrnx-theme', value );
}, theme );
}
async function readCharacterGeometry( stage ) {
return stage.evaluate( ( element ) => {
const content = element.querySelector( ':scope > .chrnx-character-stage__content' );
const art = element.querySelector( ':scope > .chrnx-character-stage__art' );
const atmosphere = element.querySelector( ':scope > .chrnx-character-stage__atmosphere' );
const picture = art.querySelector( ':scope > picture' );
const image = picture?.querySelector( 'img' );
const secondary = atmosphere.querySelector( 'picture' );
const collage = element
.querySelector( '.chrnx-character-stage__collage' )
?.closest( 'picture' );
const facets = element.parentElement.querySelector( ':scope > .chrnx-character-facets' );
const stageRect = element.getBoundingClientRect();
const contentRect = content.getBoundingClientRect();
const artRect = art.getBoundingClientRect();
const pictureRect = picture?.getBoundingClientRect();
const imageStyle = image ? window.getComputedStyle( image ) : null;
const pictureStyle = picture ? window.getComputedStyle( picture ) : null;
const atmosphereStyle = window.getComputedStyle( atmosphere );
const secondaryStyle = secondary ? window.getComputedStyle( secondary ) : null;
const collageStyle = collage ? window.getComputedStyle( collage ) : null;
const facetsStyle = facets ? window.getComputedStyle( facets ) : null;
const intersects = ( first, second ) =>
first.left < second.right - 1 &&
first.right > second.left + 1 &&
first.top < second.bottom - 1 &&
first.bottom > second.top + 1;
const following = [
...element.parentElement.querySelectorAll(
'.chrnx-release-card, .chrnx-podcast-card, .chrnx-character-facets',
),
].filter( ( candidate ) => ! element.contains( candidate ) );
return {
stageWidth: stageRect.width,
artWidth: artRect.width,
artBottomGap: Math.abs( stageRect.bottom - artRect.bottom ),
contentTop: contentRect.top,
contentBottom: contentRect.bottom,
artTop: artRect.top,
contentArtIntersect: intersects( contentRect, artRect ),
followingIntersections: following.filter( ( candidate ) =>
intersects( stageRect, candidate.getBoundingClientRect() ),
).length,
stageOverflow: element.scrollWidth - element.clientWidth,
pictureVisible: Boolean(
pictureRect && pictureRect.width > 0 && pictureRect.height > 0 && image?.complete,
),
pictureContained: Boolean(
pictureRect &&
pictureRect.left >= artRect.left - 1 &&
pictureRect.right <= artRect.right + 1 &&
pictureRect.top >= artRect.top - 1 &&
pictureRect.bottom <= artRect.bottom + 1,
),
pictureZ: Number.parseInt( pictureStyle?.zIndex || '0', 10 ) || 0,
atmosphereZ: Number.parseInt( atmosphereStyle.zIndex, 10 ) || 0,
secondaryZ: Number.parseInt( secondaryStyle?.zIndex || '0', 10 ) || 0,
collageZ: Number.parseInt( collageStyle?.zIndex || '0', 10 ) || 0,
collageLoading: collage?.querySelector( 'img' )?.loading,
facetsOpacity: facetsStyle ? Number.parseFloat( facetsStyle.opacity ) : null,
facetsZ: Number.parseInt( facetsStyle?.zIndex || '0', 10 ) || 0,
effect: imageStyle
? `${ imageStyle.filter }|${ imageStyle.boxShadow }|${ imageStyle.maskImage }|${ imageStyle.webkitMaskImage }`
: '',
loading: image?.loading,
};
} );
}
async function expectNoHorizontalOverflow( page ) {
const overflow = await page.evaluate( () => ( {
document: document.documentElement.scrollWidth - window.innerWidth,
@@ -672,3 +773,208 @@ test( 'key public surfaces pass automated WCAG 2.2 AA checks', async ( { page },
}
}
} );
test( 'character stage geometry, layering, effects, loading, and inspection captures', async ( {
page,
}, testInfo ) => {
test.skip( testInfo.project.name !== 'chromium', 'Character geometry is reviewed in Chromium.' );
for ( const theme of [ 'dark', 'light' ] ) {
await setExplicitTheme( page, theme );
for ( const viewport of viewports ) {
await page.setViewportSize( viewport );
for ( const surface of characterSurfaces ) {
await page.goto( surface.path );
await expect( page.locator( 'html' ) ).toHaveAttribute( 'data-theme', theme );
const stage = page.locator( surface.selector ).first();
await expect( stage, `${ surface.name } stage` ).toBeVisible();
const initial = await stage.evaluate( ( element ) => ( {
top: element.getBoundingClientRect().top,
loading: element.querySelector( ':scope > .chrnx-character-stage__art picture img' )
?.loading,
priority: element.querySelector( ':scope > .chrnx-character-stage__art picture img' )
?.fetchPriority,
} ) );
await stage.scrollIntoViewIfNeeded();
await stage
.locator( ':scope > .chrnx-character-stage__art picture img' )
.evaluate( ( image ) => image.decode() );
const geometry = await readCharacterGeometry( stage );
const mobile = viewport.width <= 768;
const ratio = geometry.artWidth / geometry.stageWidth;
expect(
ratio,
`${ surface.name } art ratio at ${ viewport.width }px ${ theme }`,
).toBeGreaterThanOrEqual( mobile ? 0.62 : 0.35 );
if ( ! mobile ) {
expect( ratio ).toBeLessThanOrEqual( 0.48 );
}
expect( geometry.artBottomGap ).toBeLessThanOrEqual( 2 );
if ( mobile ) {
expect( geometry.contentTop ).toBeLessThan( geometry.artTop );
expect( geometry.contentBottom ).toBeLessThanOrEqual( geometry.artTop + 1 );
}
expect( geometry.contentArtIntersect ).toBeFalsy();
expect( geometry.followingIntersections ).toBe( 0 );
expect( geometry.stageOverflow ).toBeLessThanOrEqual( 1 );
expect( geometry.pictureVisible ).toBeTruthy();
expect( geometry.pictureContained ).toBeTruthy();
expect( geometry.pictureZ ).toBeGreaterThan( geometry.atmosphereZ );
expect( geometry.pictureZ ).toBeGreaterThan( geometry.secondaryZ );
expect( geometry.pictureZ ).toBeGreaterThan( geometry.collageZ );
expect( geometry.effect ).not.toBe( 'none|none|none|none' );
if ( surface.name === 'home-music' || surface.name === 'music' ) {
expect( geometry.collageLoading ).toBe( 'lazy' );
}
if ( surface.name === 'about' ) {
expect( geometry.facetsOpacity ).toBeLessThan( 1 );
expect( geometry.facetsZ ).toBeLessThan( geometry.pictureZ );
}
await expectNoHorizontalOverflow( page );
if ( initial.top >= viewport.height ) {
expect( initial.loading ).not.toBe( 'eager' );
expect( initial.priority ).not.toBe( 'high' );
}
await testInfo.attach(
`character-stage-${ surface.name }-${ viewport.width }-${ theme }.png`,
{ body: await stage.screenshot(), contentType: 'image/png' },
);
}
}
}
} );
test( 'character stage long copy grows safely with AA contrast in both themes', async ( {
page,
}, testInfo ) => {
test.skip( testInfo.project.name !== 'chromium', 'Character geometry is reviewed in Chromium.' );
for ( const theme of [ 'dark', 'light' ] ) {
await setExplicitTheme( page, theme );
for ( const width of [ 375, 1440 ] ) {
await page.setViewportSize( { width, height: width === 375 ? 812 : 900 } );
for ( const surface of characterSurfaces ) {
await page.goto( surface.path );
const stage = page.locator( surface.selector ).first();
await stage.locator( ':scope > .chrnx-character-stage__content' ).evaluate( ( content ) => {
const walker = document.createTreeWalker( content, window.NodeFilter.SHOW_TEXT );
const nodes = [];
while ( walker.nextNode() ) {
if ( walker.currentNode.textContent.trim() ) {
nodes.push( walker.currentNode );
}
}
for ( const node of nodes ) {
node.textContent = `${ node.textContent.trim() } `.repeat( 4 ).trim();
}
} );
const result = await stage.evaluate( ( element ) => {
const content = element.querySelector( ':scope > .chrnx-character-stage__content' );
const art = element.querySelector( ':scope > .chrnx-character-stage__art' );
const stageRect = element.getBoundingClientRect();
const contentRect = content.getBoundingClientRect();
const artRect = art.getBoundingClientRect();
const following = [
...element.parentElement.querySelectorAll(
'.chrnx-release-card, .chrnx-podcast-card, .chrnx-character-facets',
),
].filter( ( candidate ) => {
const rect = candidate.getBoundingClientRect();
return ! element.contains( candidate ) && rect.height > 0 && rect.top >= stageRect.top;
} );
const foregrounds = [ ...content.querySelectorAll( 'h1, h2, h3, h4, h5, h6, p, li, a' ) ]
.filter( ( candidate ) => candidate.getClientRects().length > 0 )
.map( ( candidate ) => window.getComputedStyle( candidate ).color );
const background = window.getComputedStyle( element ).backgroundColor;
return {
stageBottom: stageRect.bottom,
contentBottom: contentRect.bottom,
artTop: artRect.top,
artBottom: artRect.bottom,
nextTop: following.length
? Math.min(
...following.map( ( candidate ) => candidate.getBoundingClientRect().top ),
)
: Number.POSITIVE_INFINITY,
foregrounds,
background,
};
} );
expect( result.stageBottom ).toBeGreaterThanOrEqual( result.contentBottom - 1 );
expect( result.stageBottom ).toBeGreaterThanOrEqual( result.artBottom - 1 );
expect( result.nextTop ).toBeGreaterThanOrEqual( result.stageBottom - 1 );
if ( width === 375 ) {
expect( result.artTop ).toBeGreaterThanOrEqual( result.contentBottom - 1 );
}
expect( result.foregrounds.length ).toBeGreaterThan( 0 );
for ( const foreground of result.foregrounds ) {
expect(
contrastRatio( foreground, result.background ),
`${ surface.name } ${ width }px ${ theme } contrast`,
).toBeGreaterThanOrEqual( 4.5 );
}
await expectNoHorizontalOverflow( page );
}
}
}
} );
test( 'character stage is static under reduced motion and visible without JavaScript', async ( {
browser,
}, testInfo ) => {
test.skip( testInfo.project.name !== 'chromium', 'Character geometry is reviewed in Chromium.' );
const cases = characterSurfaces.filter( ( surface ) =>
[ 'home-music', 'about', 'topic-code' ].includes( surface.name ),
);
for ( const surface of cases ) {
const regularContext = await browser.newContext( {
baseURL: testInfo.project.use.baseURL,
viewport: { width: 375, height: 812 },
} );
const reducedContext = await browser.newContext( {
baseURL: testInfo.project.use.baseURL,
viewport: { width: 375, height: 812 },
reducedMotion: 'reduce',
} );
const noJavaScriptContext = await browser.newContext( {
baseURL: testInfo.project.use.baseURL,
viewport: { width: 375, height: 812 },
javaScriptEnabled: false,
} );
const [ regular, reduced, noJavaScript ] = await Promise.all( [
regularContext.newPage(),
reducedContext.newPage(),
noJavaScriptContext.newPage(),
] );
try {
for ( const page of [ regular, reduced, noJavaScript ] ) {
await page.goto( surface.path );
}
const regularStage = regular.locator( surface.selector ).first();
const reducedStage = reduced.locator( surface.selector ).first();
const noJsStage = noJavaScript.locator( surface.selector ).first();
const [ regularBox, reducedBox ] = await Promise.all( [
regularStage.boundingBox(),
reducedStage.boundingBox(),
] );
expect( Math.abs( regularBox.width - reducedBox.width ) ).toBeLessThanOrEqual( 1 );
expect( Math.abs( regularBox.height - reducedBox.height ) ).toBeLessThanOrEqual( 1 );
await expect( noJsStage ).toBeVisible();
const noJsGeometry = await readCharacterGeometry( noJsStage );
expect( noJsGeometry.pictureVisible ).toBeTruthy();
expect( noJsGeometry.stageOverflow ).toBeLessThanOrEqual( 1 );
await expectNoHorizontalOverflow( noJavaScript );
} finally {
await Promise.all( [
regularContext.close(),
reducedContext.close(),
noJavaScriptContext.close(),
] );
}
}
} );
+19
View File
@@ -271,3 +271,22 @@ test( 'character-led openings share the exact stage class contract', () => {
assert.match( read( 'patterns/about.php' ), /chrnx-character-facets/ );
assert.match( read( 'blocks/topic-hero/render.php' ), /chrnx-topic-hero__fallback/ );
} );
test( 'character stages define the shared mockup effect and responsive geometry', () => {
const components = read( 'assets/css/components.css' );
for ( const token of [
'--chrnx-character-accent',
'--chrnx-character-halo',
'--chrnx-character-wash',
'--chrnx-character-shadow',
] ) {
assert.match( components, new RegExp( token ), `${ token } must be shared` );
}
assert.match( components, /\.chrnx-character-stage\s*\{[\s\S]*?grid-template-columns:\s*minmax\(0,\s*55fr\)\s+minmax\(0,\s*45fr\)/ );
assert.match( components, /\.chrnx-character-stage__atmosphere::before/ );
assert.match( components, /\.chrnx-character-stage__atmosphere::after/ );
assert.match( components, /\.chrnx-character-stage__art\s*>\s*\.chrnx-responsive-portrait/ );
assert.match( components, /@media \(max-width:\s*780px\)[\s\S]*?\.chrnx-character-stage\s*\{[\s\S]*?grid-template-columns:\s*1fr/ );
assert.match( components, /@media \(prefers-reduced-motion:\s*reduce\)[\s\S]*?\.chrnx-character-stage/ );
} );