Skip to content

Commit c8dfe9a

Browse files
committed
fix(resources): apply CSS transform trickery only to Wixsite
This commit should resolve most of the questions of why we need so much code for a single iframe scenario, as we typically assume all websites adhere to responsive designs. To be fair, WordPress link we received does, but just not for the wixsite link. Unfortunately, we kind of entered a local maximum and decided to fix everything ourselves (a wiser way would be asking the wixsite owner for the account and optimizing on that side). Therefore, we disable the tricks on the WordPress website, as it is responsive by design. Left a TODO to explain this big pile of code/logic just for this very edge-case scenario.
1 parent 9bcbd2f commit c8dfe9a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/app/resources/[slug]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default async function ResourceEmbedPage({ params }: { params: Promise<{
2828
title={resource.title}
2929
websiteUrl={resource.websiteUrl}
3030
hideTopPx={resource.hideTopPx}
31+
scale={resource.scale}
3132
hideHeader
3233
showOnMobile
3334
containerHeight="100dvh"

src/components/sections/resource-iframe.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
66
import { cn, isInternalHref, noReturnDebounce } from "@/lib/utils";
77
import { CSSProperties, RefObject, useCallback, useEffect, useRef, useState } from "react";
88

9+
/**
10+
* @todo Explain why we need sophisticated iframe size calculation/CSS transform trickery
11+
* The reason is for the Wix website that we got, it is not truly responsive for iframe scenarios
12+
*/
913
const IFRAME_SIZE = {
1014
/**
1115
* For Wix, mobile UA serves:
@@ -15,9 +19,9 @@ const IFRAME_SIZE = {
1519
* Hence MOBILE_WIDTH = 320.
1620
*/
1721
MOBILE_WIDTH: 320,
18-
DESKTOP_WIDTH: 1440,
22+
DESKTOP_WIDTH: 1338,
1923
/** DEFAULT_WIDTH = DESKTOP_WIDTH */
20-
DEFAULT_WIDTH: 1440,
24+
DEFAULT_WIDTH: 1338,
2125
/** Non-fullscreen view iframe height in /resource page */
2226
HEIGHT: 400,
2327
} as const;
@@ -160,7 +164,7 @@ export function ResourceIframe({
160164
title={title}
161165
allowFullScreen
162166
loading="lazy"
163-
className="border-0"
167+
className="border-0 w-full"
164168
style={{
165169
transform: `scale(${finalScale})`,
166170
transformOrigin: "top left",

src/lib/resources.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type Resource = {
44
websiteUrl: string;
55
hideTopPx: number;
66
authorLine?: string;
7+
scale?: number;
78
};
89

910
export const resources: Resource[] = [
@@ -20,6 +21,7 @@ export const resources: Resource[] = [
2021
websiteUrl: "https://thespineofthenation.wordpress.com/2025/07/22/the-spine-of-the-nation/",
2122
hideTopPx: 49,
2223
authorLine: "Mr Richard Yan (ALPHA Summer Program 2025)",
24+
scale: 1,
2325
},
2426
];
2527

0 commit comments

Comments
 (0)