11"use client" ;
22
33import React from "react" ;
4+ import Image from "next/image" ;
45import Script from "next/script" ;
56import classes from "../app/index.module.css" ;
67
@@ -36,17 +37,6 @@ export default class InteractiveLogo extends React.Component<LogoProps> {
3637 this . container = React . createRef ( ) ;
3738 }
3839
39- private createStaticLogo ( ) {
40- if ( this . container . current ) {
41- const staticLogo = document . createElement ( "IMG" ) as HTMLImageElement ;
42- staticLogo . src = "/logo.svg" ;
43- staticLogo . alt = "Ruffle Logo" ;
44- staticLogo . className = classes . staticLogo ;
45- this . container . current . textContent = "" ;
46- this . container . current . appendChild ( staticLogo ) ;
47- }
48- }
49-
5040 private load ( ) {
5141 if ( this . player ) {
5242 // Already loaded.
@@ -57,7 +47,6 @@ export default class InteractiveLogo extends React.Component<LogoProps> {
5747
5848 if ( this . player ) {
5949 this . container . current ! . appendChild ( this . player ) ;
60-
6150 this . player . load ( {
6251 url : "/logo-anim.swf" ,
6352 autoplay : "on" ,
@@ -66,16 +55,21 @@ export default class InteractiveLogo extends React.Component<LogoProps> {
6655 contextMenu : "off" ,
6756 splashScreen : false ,
6857 preferredRenderer : "canvas" ,
58+ } ) . then ( ( ) => {
59+ this ?. container ?. current ?. querySelector ( "img" ) ?. classList ?. toggle ( classes . hidden ) ;
6960 } ) . catch ( ( ) => {
70- this . createStaticLogo ( ) ;
61+ this . player ?. remove ( ) ;
62+ this . player = null ;
7163 } ) ;
7264 this . player . style . width = "100%" ;
7365 this . player . style . height = "100%" ;
74- } else {
75- this . createStaticLogo ( ) ;
7666 }
7767 }
7868
69+ componentDidMount ( ) {
70+ this . load ( ) ;
71+ }
72+
7973 componentWillUnmount ( ) {
8074 this . player ?. remove ( ) ;
8175 this . player = null ;
@@ -87,9 +81,10 @@ export default class InteractiveLogo extends React.Component<LogoProps> {
8781 < Script
8882 src = "https://unpkg.com/@ruffle-rs/ruffle"
8983 onReady = { ( ) => this . load ( ) }
90- onError = { ( ) => this . createStaticLogo ( ) }
9184 />
92- < div ref = { this . container } className = { this . props . className } />
85+ < div ref = { this . container } className = { this . props . className } >
86+ < Image src = "/logo.svg" alt = "Ruffle Logo" className = { classes . staticLogo } width = "340" height = "110" />
87+ </ div >
9388 </ >
9489 ) ;
9590 }
0 commit comments