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 src/app/compatibility/avm2/class_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import classes from "./avm2.module.css";
import React from "react";
import {
ClassStatus,
ProgressIcon,
displayedPercentage,
} from "@/app/compatibility/avm2/report_utils";
import { ProgressIcon } from "@/app/compatibility/avm2/icons";

export function ClassBox(props: ClassStatus) {
const [opened, { toggle }] = useDisclosure(false);
Expand Down
54 changes: 54 additions & 0 deletions src/app/compatibility/avm2/icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { rem, ThemeIcon } from "@mantine/core";
import { IconCheck, IconProgress, IconX } from "@tabler/icons-react";

export function IconDone() {
return (
<ThemeIcon
size={20}
radius="xl"
color="var(--mantine-color-green-9)"
title="Done"
>
<IconCheck
color="white"
style={{ width: rem(12), height: rem(12) }}
stroke={4}
/>
</ThemeIcon>
);
}

export function IconStub() {
return (
<ThemeIcon size={20} radius="xl" title="Partial">
<IconProgress
color="#3c1518"
style={{ width: rem(12), height: rem(12) }}
stroke={4}
/>
</ThemeIcon>
);
}

export function IconMissing() {
return (
<ThemeIcon size={20} radius="xl" color="#3c1518" title="Missing">
<IconX
color="white"
style={{ width: rem(12), height: rem(12) }}
stroke={4}
/>
</ThemeIcon>
);
}

export function ProgressIcon(type: "stub" | "missing" | "done") {
switch (type) {
case "stub":
return <IconStub />;
case "missing":
return <IconMissing />;
case "done":
return <IconDone />;
}
}
6 changes: 4 additions & 2 deletions src/app/compatibility/avm2/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import classes from "./avm2.module.css";
import { ClassBox } from "@/app/compatibility/avm2/class_box";
import {
getReportByNamespace,
NamespaceStatus,
} from "@/app/compatibility/avm2/report_utils";
import {
IconDone,
IconMissing,
IconStub,
NamespaceStatus,
} from "@/app/compatibility/avm2/report_utils";
} from "@/app/compatibility/avm2/icons";
import Link from "next/link";

function NamespaceBox(props: NamespaceStatus) {
Expand Down
55 changes: 0 additions & 55 deletions src/app/compatibility/avm2/report_utils.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,4 @@
import { rem, ThemeIcon } from "@mantine/core";
import { IconCheck, IconProgress, IconX } from "@tabler/icons-react";
import { fetchReport } from "@/app/downloads/github";
import React from "react";

export function IconDone() {
return (
<ThemeIcon
size={20}
radius="xl"
color="var(--mantine-color-green-9)"
title="Done"
>
<IconCheck
color="white"
style={{ width: rem(12), height: rem(12) }}
stroke={4}
/>
</ThemeIcon>
);
}

export function IconStub() {
return (
<ThemeIcon size={20} radius="xl" title="Partial">
<IconProgress
color="#3c1518"
style={{ width: rem(12), height: rem(12) }}
stroke={4}
/>
</ThemeIcon>
);
}

export function IconMissing() {
return (
<ThemeIcon size={20} radius="xl" color="#3c1518" title="Missing">
<IconX
color="white"
style={{ width: rem(12), height: rem(12) }}
stroke={4}
/>
</ThemeIcon>
);
}

export function ProgressIcon(type: "stub" | "missing" | "done") {
switch (type) {
case "stub":
return <IconStub />;
case "missing":
return <IconMissing />;
case "done":
return <IconDone />;
}
}

export interface SummaryStatistics {
max_points: number;
Expand Down
105 changes: 42 additions & 63 deletions src/components/logo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import React from "react";
import React, { useEffect, useRef, useState } from "react";
import Image from "next/image";
import Script from "next/script";
import classes from "../app/index.module.css";
Expand All @@ -27,44 +27,29 @@ interface LogoProps {
className?: string;
}

interface LogoState {
player: RufflePlayer | null;
}

export default class InteractiveLogo extends React.Component<
LogoProps,
LogoState
> {
private readonly container: React.RefObject<HTMLDivElement>;
private player: RufflePlayer | null = null;
export default function InteractiveLogo({ className }: LogoProps) {
const container = useRef<HTMLDivElement>(null);
const [player, setPlayer] = useState<RufflePlayer | null>(null);

constructor(props: LogoProps) {
super(props);

this.container = React.createRef();
this.state = {
player: null,
};
}
const removeRufflePlayer = () => {
player?.remove();
setPlayer(null);
};

private removeRufflePlayer() {
this.player?.remove();
this.player = null;
this.setState({ player: null });
}

private load() {
if (this.player) {
const loadPlayer = () => {
if (player) {
// Already loaded.
return;
}

this.player = (window.RufflePlayer as PublicAPI)?.newest()?.createPlayer();
const rufflePlayer = (window.RufflePlayer as PublicAPI)
?.newest()
?.createPlayer();

if (this.player) {
this.container.current!.appendChild(this.player);
if (rufflePlayer) {
container.current!.appendChild(rufflePlayer);

this.player
rufflePlayer
.load({
url: "/logo-anim.swf",
autoplay: "on",
Expand All @@ -75,39 +60,33 @@ export default class InteractiveLogo extends React.Component<
preferredRenderer: "canvas",
})
.catch(() => {
this.removeRufflePlayer();
removeRufflePlayer();
});
this.player.style.width = "100%";
this.player.style.height = "100%";
this.setState({ player: this.player });
rufflePlayer.style.width = "100%";
rufflePlayer.style.height = "100%";
setPlayer(rufflePlayer);
}
}

componentDidMount() {
this.load();
}

componentWillUnmount() {
this.removeRufflePlayer();
}

render() {
return (
<>
<Script
src="https://unpkg.com/@ruffle-rs/ruffle"
onReady={() => this.load()}
};

useEffect(() => {
return () => removeRufflePlayer();
}, []);

return (
<>
<Script
src="https://unpkg.com/@ruffle-rs/ruffle"
onReady={() => loadPlayer()}
/>
<div ref={container} className={className}>
<Image
src="/logo.svg"
alt="Ruffle Logo"
className={player ? classes.hidden : classes.staticLogo}
width="340"
height="110"
/>
<div ref={this.container} className={this.props.className}>
<Image
src="/logo.svg"
alt="Ruffle Logo"
className={this.state.player ? classes.hidden : classes.staticLogo}
width="340"
height="110"
/>
</div>
</>
);
}
</div>
</>
);
}