fix: align CHRNX stage presentation
This commit is contained in:
2 files changed
+97
No files matched your search
@@ -1357,6 +1357,12 @@ html[data-theme="light"] .chrnx-music-landing .chrnx-character-stage {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chrnx-music-landing .chrnx-character-stage__content > h2,
|
||||||
|
.chrnx-podcast-landing .chrnx-character-stage__content > h2 {
|
||||||
|
margin-inline: auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.chrnx-music-landing .chrnx-character-stage__art,
|
.chrnx-music-landing .chrnx-character-stage__art,
|
||||||
.chrnx-podcast-landing .chrnx-character-stage__art {
|
.chrnx-podcast-landing .chrnx-character-stage__art {
|
||||||
align-self: end;
|
align-self: end;
|
||||||
|
|||||||
@@ -94,6 +94,48 @@ async function readStage( page, landing ) {
|
|||||||
}, landing );
|
}, landing );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test( 'Music and Podcast main titles stay centered while internal headings stay aligned', async ( {
|
||||||
|
page,
|
||||||
|
} ) => {
|
||||||
|
test.setTimeout( 90_000 );
|
||||||
|
for ( const theme of [ 'dark', 'light' ] ) {
|
||||||
|
await setTheme( page, theme );
|
||||||
|
for ( const width of [ 375, 768, 1440 ] ) {
|
||||||
|
await page.setViewportSize( { width, height: width === 375 ? 812 : 1024 } );
|
||||||
|
for ( const landing of landings ) {
|
||||||
|
await page.goto( landing.path );
|
||||||
|
const state = await page.locator( landing.root ).evaluate( ( root, landingName ) => {
|
||||||
|
const title = root.querySelector( '.chrnx-character-stage__content > h2' );
|
||||||
|
const content = title.parentElement;
|
||||||
|
const internal =
|
||||||
|
landingName === 'Music'
|
||||||
|
? root.querySelector( ':scope > h3' )
|
||||||
|
: root.querySelector( '.chrnx-podcast-card__title' );
|
||||||
|
const titleRect = title.getBoundingClientRect();
|
||||||
|
const contentRect = content.getBoundingClientRect();
|
||||||
|
const titleStyle = window.getComputedStyle( title );
|
||||||
|
return {
|
||||||
|
alignment: titleStyle.textAlign,
|
||||||
|
centerDelta: Math.abs(
|
||||||
|
( titleRect.left + titleRect.right ) / 2 -
|
||||||
|
( contentRect.left + contentRect.right ) / 2,
|
||||||
|
),
|
||||||
|
marginLeft: Number.parseFloat( titleStyle.marginLeft ),
|
||||||
|
marginRight: Number.parseFloat( titleStyle.marginRight ),
|
||||||
|
internalAlignment: window.getComputedStyle( internal ).textAlign,
|
||||||
|
};
|
||||||
|
}, landing.name );
|
||||||
|
expect( state.alignment, `${ landing.name } ${ theme } ${ width }px title` ).toBe(
|
||||||
|
'center',
|
||||||
|
);
|
||||||
|
expect( state.centerDelta ).toBeLessThanOrEqual( 1 );
|
||||||
|
expect( Math.abs( state.marginLeft - state.marginRight ) ).toBeLessThanOrEqual( 1 );
|
||||||
|
expect( state.internalAlignment ).toBe( 'start' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
test( 'desktop grunge stages compose atmosphere, copy, art, and latest in both themes', async ( {
|
test( 'desktop grunge stages compose atmosphere, copy, art, and latest in both themes', async ( {
|
||||||
page,
|
page,
|
||||||
} ) => {
|
} ) => {
|
||||||
@@ -295,9 +337,24 @@ test( 'DOM-only long Podcast copy wraps normally without clipping', async ( { pa
|
|||||||
);
|
);
|
||||||
const link = panel.querySelector( '.chrnx-podcast-card__link' );
|
const link = panel.querySelector( '.chrnx-podcast-card__link' );
|
||||||
const titleStyle = window.getComputedStyle( title );
|
const titleStyle = window.getComputedStyle( title );
|
||||||
|
const probe = document.createElement( 'span' );
|
||||||
|
Object.assign( probe.style, {
|
||||||
|
fontFamily: titleStyle.fontFamily,
|
||||||
|
fontSize: titleStyle.fontSize,
|
||||||
|
fontWeight: titleStyle.fontWeight,
|
||||||
|
position: 'fixed',
|
||||||
|
visibility: 'hidden',
|
||||||
|
width: '28ch',
|
||||||
|
} );
|
||||||
|
document.body.append( probe );
|
||||||
|
const probeWidth = probe.getBoundingClientRect().width;
|
||||||
|
probe.remove();
|
||||||
return {
|
return {
|
||||||
titleLength: title.textContent.length,
|
titleLength: title.textContent.length,
|
||||||
minWidth: window.getComputedStyle( content ).minWidth,
|
minWidth: window.getComputedStyle( content ).minWidth,
|
||||||
|
columns: window.getComputedStyle( link ).gridTemplateColumns.split( ' ' ).length,
|
||||||
|
contentWidth: content.getBoundingClientRect().width,
|
||||||
|
probeWidth,
|
||||||
overflowWrap: titleStyle.overflowWrap,
|
overflowWrap: titleStyle.overflowWrap,
|
||||||
wordBreak: titleStyle.wordBreak,
|
wordBreak: titleStyle.wordBreak,
|
||||||
titleClip: title.scrollWidth - title.clientWidth,
|
titleClip: title.scrollWidth - title.clientWidth,
|
||||||
@@ -309,6 +366,9 @@ test( 'DOM-only long Podcast copy wraps normally without clipping', async ( { pa
|
|||||||
} );
|
} );
|
||||||
expect( state.titleLength ).toBeGreaterThan( 120 );
|
expect( state.titleLength ).toBeGreaterThan( 120 );
|
||||||
expect( state.minWidth ).toBe( '0px' );
|
expect( state.minWidth ).toBe( '0px' );
|
||||||
|
if ( state.columns === 2 ) {
|
||||||
|
expect( state.contentWidth ).toBeGreaterThanOrEqual( state.probeWidth - 1 );
|
||||||
|
}
|
||||||
expect( state.overflowWrap ).toBe( 'normal' );
|
expect( state.overflowWrap ).toBe( 'normal' );
|
||||||
expect( state.wordBreak ).toBe( 'normal' );
|
expect( state.wordBreak ).toBe( 'normal' );
|
||||||
expect( state.titleClip ).toBeLessThanOrEqual( 1 );
|
expect( state.titleClip ).toBeLessThanOrEqual( 1 );
|
||||||
@@ -329,6 +389,8 @@ const immutableSurfaces = [
|
|||||||
atmosphereCount: 1,
|
atmosphereCount: 1,
|
||||||
imageSources: [ 'alter-ego-research.png', 'alter-ego-code.png' ],
|
imageSources: [ 'alter-ego-research.png', 'alter-ego-code.png' ],
|
||||||
headings: [ 'Selected work', 'Expressive Tea', 'Ailed', 'Published research' ],
|
headings: [ 'Selected work', 'Expressive Tea', 'Ailed', 'Published research' ],
|
||||||
|
paragraphs: [],
|
||||||
|
contentText: 'Selected work Expressive Tea Ailed Published research',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'About',
|
name: 'About',
|
||||||
@@ -342,6 +404,14 @@ const immutableSurfaces = [
|
|||||||
'alter-ego-gaming-half-body.png',
|
'alter-ego-gaming-half-body.png',
|
||||||
],
|
],
|
||||||
headings: [ 'About', 'Beyond the work' ],
|
headings: [ 'About', 'Beyond the work' ],
|
||||||
|
paragraphs: [
|
||||||
|
'I work as Lead Developer @Expressive Tea, building full-stack software with JavaScript and Python. I am also an independent researcher exploring emotion modeling and game AI; my practice includes open source work and amateur data science.',
|
||||||
|
'I am a published researcher. My current paper is available on arXiv:2603.05352.',
|
||||||
|
'I am an autistic Level 1 software developer and researcher.',
|
||||||
|
'I am the father of three wonderful children, a musician, a gamer, and pet-friendly.',
|
||||||
|
],
|
||||||
|
contentText:
|
||||||
|
'About I work as Lead Developer @Expressive Tea, building full-stack software with JavaScript and Python. I am also an independent researcher exploring emotion modeling and game AI; my practice includes open source work and amateur data science. I am a published researcher. My current paper is available on arXiv:2603.05352. I am an autistic Level 1 software developer and researcher. Beyond the work I am the father of three wonderful children, a musician, a gamer, and pet-friendly.',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -366,6 +436,16 @@ test( 'Projects and About assets, copy, layering, and geometry remain immutable'
|
|||||||
for ( const source of surface.imageSources ) {
|
for ( const source of surface.imageSources ) {
|
||||||
await expect( root.locator( `picture img[src*="${ source }"]` ) ).toHaveCount( 1 );
|
await expect( root.locator( `picture img[src*="${ source }"]` ) ).toHaveCount( 1 );
|
||||||
}
|
}
|
||||||
|
const approvedCopy = await root
|
||||||
|
.locator( '.chrnx-character-stage__content' )
|
||||||
|
.evaluate( ( content ) => ( {
|
||||||
|
contentText: content.textContent.trim().replace( /\s+/g, ' ' ),
|
||||||
|
paragraphs: [ ...content.querySelectorAll( ':scope > p' ) ].map( ( paragraph ) =>
|
||||||
|
paragraph.textContent.trim().replace( /\s+/g, ' ' ),
|
||||||
|
),
|
||||||
|
} ) );
|
||||||
|
expect( approvedCopy.contentText ).toBe( surface.contentText );
|
||||||
|
expect( approvedCopy.paragraphs ).toEqual( surface.paragraphs );
|
||||||
const state = await root.evaluate( ( element ) => {
|
const state = await root.evaluate( ( element ) => {
|
||||||
const readRect = ( target ) => {
|
const readRect = ( target ) => {
|
||||||
const bounds = target.getBoundingClientRect();
|
const bounds = target.getBoundingClientRect();
|
||||||
@@ -381,8 +461,15 @@ test( 'Projects and About assets, copy, layering, and geometry remain immutable'
|
|||||||
const stage = element.querySelector( '.chrnx-character-stage' );
|
const stage = element.querySelector( '.chrnx-character-stage' );
|
||||||
const children = [ ...stage.children ].map( ( child ) => child.className );
|
const children = [ ...stage.children ].map( ( child ) => child.className );
|
||||||
const art = stage.querySelector( '.chrnx-character-stage__art' );
|
const art = stage.querySelector( '.chrnx-character-stage__art' );
|
||||||
|
const artImage = art.querySelector( 'img' );
|
||||||
const stageRect = readRect( stage );
|
const stageRect = readRect( stage );
|
||||||
const artRect = readRect( art );
|
const artRect = readRect( art );
|
||||||
|
const imageRect = readRect( artImage );
|
||||||
|
const contained = ( child, parent ) =>
|
||||||
|
child.left >= parent.left - 1 &&
|
||||||
|
child.right <= parent.right + 1 &&
|
||||||
|
child.top >= parent.top - 1 &&
|
||||||
|
child.bottom <= parent.bottom + 1;
|
||||||
return {
|
return {
|
||||||
layerOrder: children.map( ( classes ) =>
|
layerOrder: children.map( ( classes ) =>
|
||||||
[ 'atmosphere', 'content', 'art' ].find( ( layer ) =>
|
[ 'atmosphere', 'content', 'art' ].find( ( layer ) =>
|
||||||
@@ -393,11 +480,15 @@ test( 'Projects and About assets, copy, layering, and geometry remain immutable'
|
|||||||
'.chrnx-character-stage__atmosphere picture',
|
'.chrnx-character-stage__atmosphere picture',
|
||||||
).length,
|
).length,
|
||||||
artRatio: artRect.width / stageRect.width,
|
artRatio: artRect.width / stageRect.width,
|
||||||
|
artFrameContained: contained( artRect, stageRect ),
|
||||||
|
artImageContained: contained( imageRect, artRect ) && contained( imageRect, stageRect ),
|
||||||
overflow: stage.scrollWidth - stage.clientWidth,
|
overflow: stage.scrollWidth - stage.clientWidth,
|
||||||
};
|
};
|
||||||
} );
|
} );
|
||||||
expect( state.layerOrder ).toEqual( [ 'atmosphere', 'content', 'art' ] );
|
expect( state.layerOrder ).toEqual( [ 'atmosphere', 'content', 'art' ] );
|
||||||
expect( state.atmospherePictures ).toBe( surface.atmosphereCount );
|
expect( state.atmospherePictures ).toBe( surface.atmosphereCount );
|
||||||
|
expect( state.artFrameContained ).toBeTruthy();
|
||||||
|
expect( state.artImageContained ).toBeTruthy();
|
||||||
if ( width === 1440 ) {
|
if ( width === 1440 ) {
|
||||||
expect( state.artRatio ).toBeGreaterThanOrEqual( 0.35 );
|
expect( state.artRatio ).toBeGreaterThanOrEqual( 0.35 );
|
||||||
expect( state.artRatio ).toBeLessThanOrEqual( 0.48 );
|
expect( state.artRatio ).toBeLessThanOrEqual( 0.48 );
|
||||||
|
|||||||
Reference in new issue
Block a user