Skip to content

Conversation

jivikag
Copy link
Collaborator

@jivikag jivikag commented Aug 21, 2025

Migrate the "Watch Our AI Demo" component on https://policyengine.org/us/ai page to App v2 so that it can handle generic Embed components (videos, images, or other external embed content).

vimeoEx vidEx imgEx iframeEx

Copy link
Collaborator

@anth-volk anth-volk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work @jivikag. I've left some comments. Please also review the results of the GitHub Actions that ran on your PR, you'll find some linting issues.

src/Router.tsx Outdated
Comment on lines 11 to 14
{
path: '/us/ai',
element: <AIDemoPage />,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue, blocking: We're not looking to embed this as a page at this point.

Please remove this from the routes. We're looking to create reusable design components at the moment, not actually code pages yet.

import React from "react";
import { Card, Stack, Title, Text } from "@mantine/core";

type Kind = "youtube" | "vimeo" | "iframe" | "image";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit/suggestion: "kind" is a pretty non-standard term for something like this. "type" is more standard, but obviously quite vague and a reserved keyword. I'd recommend something like "embedType"

Comment on lines 6 to 13
type Props = {
header: string;
kind: Kind;
src: string; // iframe src or image src
description?: string; // optional text under header
aspectRatio?: `${number} / ${number}` | number; // default 16/9
alt?: string; // required if kind="image"
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: While you can describe this as a type, it's more standard to use an interface here

One drawback of types is that you lose the model name when using IntelliSense. Since you're not actually reusing this structure anywhere except the model of the inbound props, I'd recommend interface here


type Props = {
header: string;
kind: Kind;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Here, again, kind is fairly non-canonical. Would recommend something more standard.

const fixSrc = (kind: Kind, src: string) => {
if (kind === "youtube") {
const id =
src.match(/(?:v=|youtu\.be\/|\/embed\/)([A-Za-z0-9_-]{6,})/)?.[1] ?? null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Define this regex elsewhere as a const and pass into .match() as an arg

It's tough to read these inline


const fixSrc = (kind: Kind, src: string) => {
if (kind === "youtube") {
const id =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion/nit: ID is often used to refer to records in a database. Instead, call this link.

aspectRatio = "16 / 9",
alt,
}: Props) {
const normalized = fixSrc(kind, src);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion/nit: Normalization often refers to structuring data in such a way that it's easy to find different record types by their IDs. Instead, I'd refer to this as "modified," I guess? Or something else.

Comment on lines 39 to 46
<div style={{ maxWidth: 960, margin: "0 auto" }}>
<h2 style={{ margin: "0 0 6px 0" }}>{header}</h2>
{description ? (
<p style={{ margin: "0 0 10px 0", color: "#6b7280" }}>{description}</p>
) : null}

<div
style={{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue, blocking: Please use Mantine v8 components when building. You can find their docs at https://mantine.dev/.

Please also use styling from the design framework. Our preference on styling is overrides to defaults -> defined "variants" in the styles folder -> local overrides

);
}

export default Embed;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Super minor, but my preference is to just use ES6+ "export default function Embed". Not necessary, though.

Comment on lines 1 to 14
import { Embed } from "../components/Embed/Embed";

export default function AIDemoPage() {
return (
<div style={{ padding: 24 }}>
<Embed
header="Watch Our AI Demo"
kind="youtube"
src="https://www.youtube.com/watch?v=fnuDyLKpt90" // replace with real ID
/>
</div>
);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue, blocking: Please remove, as we are just looking to create generic components at the moment.

Copy link
Collaborator Author

@jivikag jivikag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented feedback and pushed new code (yields same results as before)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants