mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 13:49:57 -05:00
ui: act on review -- corner chrome, a swallowed className, and the poster frame
Three real defects from the PR review, each reproduced before it was fixed.
The tag mark and a video's duration were pinned to the poster BAND, which
is the full width of the card, rather than to the painted image. Once the
height cap landed the two stopped being the same box: measured, the mark
sat 39px clear of a book cover, 56px clear of a small poster and 60px
clear of a vertical video, and the duration 55px clear. It went unnoticed
because on a 16:9 poster the image fills the band and the two pin to the
same place -- so the tests cover the height-bound ratios, and assert the
letterbox gap is really there before measuring into it.
CardPoster now centres a frame that shrink-wraps the image, and the frame
is what corner chrome is positioned against. VideoCard passes its
duration through a new `overlay` prop rather than wrapping CardPoster in a
box of its own.
The mark also went back INSIDE the link. Splitting it out made the
tagged corner a dead spot on an otherwise clickable poster.
CardLink and ExternalCardLink wrote `className='...' {...props}`, so a
caller's className replaced the pair instead of adding to it. Every
archive title passes `card-title-ellipsis`, so every archive title lost
`card-link` -- the one card type this PR migrates for layout was the one
missing the title treatment. Both compose now.
On the fourth comment, the breadth of the ActionIcon remap: it is
deliberate and the numbers are small. 59 IconButton call sites, 52 of
them at the default size, 7 at `xs` (one in Flasher, three in the
inventory schema editor). The one library control that stands beside an
input rather than a button is SearchBox's clear, and the remap is exactly
what that scale is for -- it now matches its field to the pixel, where
before it was 28px against a 36px input. Guarded by a test that fails at
42 vs 36 if the default is reverted.
1078 jest, 158 in ui-layout.cy.js, clean build.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c581dadae6
commit
e36bd85f54
5 changed files with 190 additions and 17 deletions
|
|
@ -174,19 +174,30 @@ export function isoDatetimeToString(dt, time = false) {
|
|||
return d;
|
||||
}
|
||||
|
||||
export function CardLink({to, newTab = false, ...props}) {
|
||||
/*
|
||||
* Both card links COMPOSE the caller's className rather than being overwritten by it.
|
||||
* Written as `className='...' {...props}`, the spread put the caller's class last and it
|
||||
* replaced the pair outright -- so every archive title, which passes
|
||||
* `card-title-ellipsis`, lost `card-link` and rendered in the link colour instead of the
|
||||
* card's text colour. The one card type whose classes are set this way, and the one whose
|
||||
* title looked wrong.
|
||||
*/
|
||||
const cardLinkClass = (className) =>
|
||||
['no-link-underscore', 'card-link', className].filter(Boolean).join(' ');
|
||||
|
||||
export function CardLink({to, newTab = false, className, ...props}) {
|
||||
props = newTab === true ? {...props, target: '_blank', rel: 'noopener noreferrer'} : props;
|
||||
return <Link to={to} className="no-link-underscore card-link" {...props}>
|
||||
return <Link to={to} className={cardLinkClass(className)} {...props}>
|
||||
{props.children}
|
||||
</Link>
|
||||
}
|
||||
|
||||
export function ExternalCardLink({to, children, ...props}) {
|
||||
export function ExternalCardLink({to, children, className, ...props}) {
|
||||
return <a
|
||||
href={to}
|
||||
target='_blank'
|
||||
rel='noopener noreferrer'
|
||||
className='no-link-underscore card-link'
|
||||
className={cardLinkClass(className)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
|
|
@ -726,7 +737,7 @@ export function findPosterPath(file) {
|
|||
}
|
||||
}
|
||||
|
||||
export function CardPoster({to, file}) {
|
||||
export function CardPoster({to, file, overlay}) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
// Marks a tagged file, pinned to the poster's corner.
|
||||
|
|
@ -739,16 +750,29 @@ export function CardPoster({to, file}) {
|
|||
// FileGroup has a poster (screenshot/thumbnail) file.
|
||||
posterPath = `/media/${encodeMediaPath(posterPath)}`;
|
||||
|
||||
// Sized by `.wrolpi-card-poster`: as wide as the card allows, natural ratio.
|
||||
const image = <img alt='poster' src={posterPath}/>;
|
||||
/*
|
||||
* Sized by `.wrolpi-card-poster`: as wide as the card allows, capped in height,
|
||||
* natural ratio. The corner chrome goes INSIDE the link, beside the image:
|
||||
*
|
||||
* - the frame shrink-wraps the painted image, so a mark pinned to its corner
|
||||
* tracks the poster rather than the letterbox space beside it. A height-capped
|
||||
* poster is a good deal narrower than its band -- 155px inside a 233px card for
|
||||
* a book cover, less for a vertical video;
|
||||
* - and the mark stays part of the poster's hit target, rather than a dead spot
|
||||
* on the corner of an otherwise clickable image.
|
||||
*/
|
||||
const inner = <>
|
||||
{imageLabel}
|
||||
<img alt='poster' src={posterPath}/>
|
||||
{overlay}
|
||||
</>;
|
||||
|
||||
return <div className='wrolpi-card-poster'>
|
||||
{imageLabel}
|
||||
{to
|
||||
// Link within this App.
|
||||
? <Link to={to}>{image}</Link>
|
||||
? <Link to={to} className='wrolpi-card-poster-frame'>{inner}</Link>
|
||||
// Preview the file.
|
||||
: <PreviewLink file={file}>{image}</PreviewLink>}
|
||||
: <PreviewLink file={file} className='wrolpi-card-poster-frame'>{inner}</PreviewLink>}
|
||||
</div>
|
||||
} else {
|
||||
// FileGroup has no poster.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue