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
20 changes: 15 additions & 5 deletions apps/app/src/components/fragments/project-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,47 @@ import * as muiIcon from "@mui/icons-material";
import * as mui from "@mui/material";
import { Link as GatsbyLink } from "gatsby";

import { styles } from "./styles";
import { styles, useMediaStyles } from "./styles";

export interface MediaProps {
frameUrl?: string;
title: string;
url: string;
}

export const Media = ({ title, url }: MediaProps) => {
export const Media = (props: MediaProps) => {
const { frameUrl, title } = props;

const styles = useMediaStyles(props);

return (
<mui.Box css={styles.media}>
<iframe css={styles.mediaIframe} src={url} title={title} />
{frameUrl ? (
<iframe css={styles.mediaIframe} src={frameUrl} title={title} />
) : (
<muiIcon.Language css={styles.mediaNoFrame} />
)}
</mui.Box>
);
};

export interface ProjectCardProps {
description?: string;
frameUrl?: string;
onCopy?: () => void;
title: string;
url: string;
}

export const ProjectCard = ({
description,
frameUrl,
onCopy,
title,
url,
}: ProjectCardProps) => {
return (
<mui.Card css={styles.root}>
<mui.CardMedia component={Media} title={title} url={url} />
<mui.CardMedia component={Media} frameUrl={frameUrl} title={title} />
<mui.Divider />
<mui.CardContent css={styles.content}>
<mui.Typography gutterBottom variant="h5">
Expand Down
40 changes: 29 additions & 11 deletions apps/app/src/components/fragments/project-card/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { css } from "@emotion/react";
import { type AppTheme } from "@n8v/app/theme";
import { ellipsis } from "polished";

import type { MediaProps } from ".";

export const styles = {
actions: () => css({ justifyContent: "end", marginTop: "auto" }),

Expand All @@ -16,14 +18,32 @@ export const styles = {
...ellipsis("100%", 3),
}),

media: (theme: AppTheme) =>
root: (theme: AppTheme) =>
css({
height: theme.spacing(27),
overflow: "hidden",
pointerEvents: "none",
position: "relative",
display: "flex",
flexDirection: "column",
height: theme.spacing(50),
width: theme.spacing(40),
}),
};

export const useMediaStyles = (props: MediaProps) => ({
media: (theme: AppTheme) =>
css([
{
color: theme.palette.text.secondary,
height: theme.spacing(27),
overflow: "hidden",
pointerEvents: "none",
position: "relative",
width: theme.spacing(40),
},
!props.frameUrl && {
alignItems: "center",
display: "flex",
justifyContent: "center",
},
]),

mediaIframe: () =>
css({
Expand All @@ -36,11 +56,9 @@ export const styles = {
width: "500%",
}),

root: (theme: AppTheme) =>
mediaNoFrame: (theme: AppTheme) =>
css({
display: "flex",
flexDirection: "column",
height: theme.spacing(50),
width: theme.spacing(40),
height: theme.spacing(10),
width: theme.spacing(10),
}),
};
});
2 changes: 2 additions & 0 deletions apps/app/src/components/screens/projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { styles } from "./styles";

export interface Project {
description?: string;
frameUrl?: string;
title: string;
url: string;
}
Expand All @@ -30,6 +31,7 @@ export const ProjectsScreen = ({
{projects.map((project) => (
<ProjectCard
description={project.description}
frameUrl={project.frameUrl}
key={project.url}
onCopy={() => {
onCopy?.(project.url);
Expand Down
1 change: 1 addition & 0 deletions apps/app/src/hooks/use-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const useProjects = () =>
{
description:
"A simple counter app compiled to WebAssembly, written in Rust.",
frameUrl: "/apps/counter",
title: "Wasm Counter",
url: "/apps/counter",
},
Expand Down