Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ prerendered markup — never another route's — or hydration mismatches.

### Analyzer live view

While a run is active `pages/Analyzer.tsx` hides the uploader and wraps the page in `.analyzer-live` (viewport height minus header, minus the sticky ad bar when it is filled), so the ad row and `components/AnalysisProgress.tsx` (a container-query card: grid, face and steps resize to the space left) fit one screen. The ad row and the results list stay mounted so no ad is re-requested. A run that produced a report holds the finished card for 1.6 s, then a summary strip (stop code, likely cause from `getReportFacts`) sits above the results until "Analyze another file". The animation moves only transform, translate, scale and opacity inside the card.
While a run is active `pages/Analyzer.tsx` hides the uploader and wraps the page in `.analyzer-live` (viewport height minus header, minus the sticky ad bar when it is filled), so the ad row and `components/AnalysisProgress.tsx` (a container-query card: grid, face and steps resize to the space left) fit one screen. The leaderboard is placed manually (`DisplayAdSafe fixed`: 320x100, 468x60 or 728x90 by width, no `data-ad-format`), so whatever fills it cannot resize the page, and the card keeps at least 24rem. The ad row and the results list stay mounted so no ad is re-requested. A run that produced a report holds the finished card for 1.6 s, then a summary strip (stop code, likely cause from `getReportFacts`) sits above the results until "Analyze another file". The animation moves only transform, translate, scale and opacity inside the card.

### Key Files

Expand Down
20 changes: 12 additions & 8 deletions components/AdSenseWithSizeCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ const useElementWidth = (ref: React.RefObject<HTMLElement | null>, minWidth: num
};

// Enhanced Display Ad with size checking
export const DisplayAdSafe: React.FC<AdProps> = ({
className = '',
style = {},
minWidth = 200
// `fixed` places the unit manually at a size set in CSS (.ad-fixed-row: 320x100,
// 468x60 or 728x90 by width) instead of letting AdSense pick one, so a page
// that has to fit a screen is never resized by the creative that fills it.
export const DisplayAdSafe: React.FC<AdProps & { fixed?: boolean }> = ({
className = '',
style = {},
minWidth = 200,
fixed = false
}) => {
const containerRef = useRef<HTMLDivElement>(null);
const hasWidth = useElementWidth(containerRef, minWidth);
Expand Down Expand Up @@ -71,15 +75,15 @@ export const DisplayAdSafe: React.FC<AdProps> = ({
if (isPremium) return null;

return (
<div ref={containerRef} className={`ad-container ${className}`} style={{ minHeight: '90px', ...style }}>
<div ref={containerRef} className={`ad-container ${fixed ? 'ad-fixed-row ' : ''}${className}`} style={fixed ? style : { minHeight: '90px', ...style }}>
{hasWidth && (
<ins
className="adsbygoogle"
style={{ display: 'block', minHeight: '90px' }}
style={fixed ? undefined : { display: 'block', minHeight: '90px' }}
data-ad-client={ADSENSE_CONFIG.client}
data-ad-slot={getAdSlot('headerDisplay')}
data-ad-format="auto"
data-full-width-responsive="true"
data-ad-format={fixed ? undefined : 'auto'}
data-full-width-responsive={fixed ? undefined : 'true'}
/>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions pages/Analyzer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ const Analyzer: React.FC = () => {
</section>

{/* Ad after upload section */}
<DisplayAdSafe
<DisplayAdSafe
className="ad-header"
style={{ minHeight: '90px' }}
minWidth={250}
fixed
/>

<div className="container">
Expand Down
13 changes: 10 additions & 3 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3157,9 +3157,16 @@ body.mobile-menu-open .header {
}

/* Analysis progress (components/AnalysisProgress.tsx): a card that fills the space the page gives it. */
.analyzer-live { display: grid; grid-template-rows: auto minmax(0, 1fr); height: calc(100dvh - 4.5rem - 1px); }
@media (max-width: 480px) { .analyzer-live { height: calc(100dvh - 4rem - 1px); } }
body:has(.sticky-ad ins[data-ad-status="filled"]) .analyzer-live { height: calc(100dvh - 4.5rem - 1px - var(--sticky-ad-height)); }
/* A manually placed ad: its box is the size of the unit, from first paint. */
.ad-container.ad-fixed-row { --w: 320px; --h: 100px; min-height: var(--h); }
@media (min-width: 500px) { .ad-container.ad-fixed-row { --w: 468px; --h: 60px; } }
@media (min-width: 800px) { .ad-container.ad-fixed-row { --w: 728px; --h: 90px; } }
.ad-fixed-row { text-align: center; }
.ad-container.ad-fixed-row ins.adsbygoogle { display: inline-block; vertical-align: top; width: var(--w); height: var(--h); min-height: 0; }
/* The page is at least one screen tall; a tall ad pushes it past that rather than squeezing the card below 24rem. */
.analyzer-live { display: grid; grid-template-rows: auto minmax(24rem, 1fr); min-height: calc(100dvh - 4.5rem - 1px); }
@media (max-width: 480px) { .analyzer-live { min-height: calc(100dvh - 4rem - 1px); } }
body:has(.sticky-ad ins[data-ad-status="filled"]) .analyzer-live { min-height: calc(100dvh - 4.5rem - 1px - var(--sticky-ad-height)); }
.analyzer-live .ad-header { margin: 0.75rem auto 0; }
.analyzer-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem 1.5rem; margin-top: 1rem; padding: 0.9rem 1.25rem; border: 1px solid var(--status-success); border-radius: 16px; background: var(--glass-bg); animation: progress-fade 0.5s; }
.analyzer-summary small { display: block; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }
Expand Down
Loading