Skip to content

Commit

Permalink
feat: Fan art on setup (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
cma2819 authored Aug 11, 2024
1 parent c7427f5 commit 62abb12
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/browser/graphics/views/break.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {swipeEnter, swipeExit} from "../components/lib/blur-swipe";
import {newlineString} from "../components/lib/util";
import {useFitViewport} from "../components/lib/use-fit-viewport";
import {render} from "../../render.js";
import {FanArtTweet} from "../components/fan-art-tweet.js";

const Spacer = () => <img src={nextGameSpacer} width={50} height={60}></img>;

Expand Down Expand Up @@ -216,6 +217,7 @@ const TweetContainer = () => {
const tweetTag = useRef(null);
const fanartTag = useRef(null);
const tweetRef = useRef(null);
const fanArtRef = useRef(null);
const transitionTimeline = useCallback(() => {
const tl = gsap.timeline();
tl.to([tweetTag.current, tweetRef.current], {
Expand All @@ -226,7 +228,22 @@ const TweetContainer = () => {
tl.to(
[tweetTag.current, tweetRef.current],
{x: 0, duration: 1, ease: Power2.easeOut},
"+=10",
"+=15",
);
return tl;
}, []);

const transitionFanArtTimeline = useCallback((width: number) => {
const tl = gsap.timeline();
tl.to([fanartTag.current, fanArtRef.current], {
x: (width + 490) * -1,
duration: 1,
ease: Power2.easeOut,
});
tl.to(
[fanartTag.current, fanArtRef.current],
{x: 0, duration: 1, ease: Power2.easeOut},
"+=20",
);
return tl;
}, []);
Expand Down Expand Up @@ -261,7 +278,6 @@ const TweetContainer = () => {
width={30}
height={98}
style={{
display: "none", // TODO: remove after adding fanart
gridRow: "2 / 3",
gridColumn: "1 / 2",
alignSelf: "start",
Expand All @@ -286,6 +302,24 @@ const TweetContainer = () => {
>
<Tweet onShow={transitionTimeline}></Tweet>
</div>
<div
ref={fanArtRef}
style={{
gridRow: "1 / 3",
gridColumn: "2 / 4",
alignSelf: "start",
justifySelf: "stretch",
padding: "50px",
borderColor: setup.frameBorder,
borderStyle: "solid",
borderWidth: "2px 0 2px 2px",
borderRadius: "7px 0 0 7px",
background: setup.frameBg,
willChange: "transform",
}}
>
<FanArtTweet onShow={transitionFanArtTimeline} />
</div>
</div>
);
};
Expand Down

0 comments on commit 62abb12

Please sign in to comment.