Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
CRBl69 committed Dec 4, 2024
1 parent 590d377 commit f4266b9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { type symbolBytesToEmojis } from "@sdk/emoji_data";
import { type AnimationPlaybackControls, useAnimate } from "framer-motion";
import { useEffect, useMemo, useState } from "react";
import { useWindowSize } from "react-use";

const DROP_FALL_TIME = 7.5;
const DROP_INTERVAL = 1;
Expand All @@ -17,13 +16,11 @@ export function EmojiRainDrop({
index: number;
emojis: number;
}) {
const { height, width } = useWindowSize();

// Position all emojis above the visible space.
const initialX = -200;
const initialY = -200;

// Calculate a random position on the Y axis.
const y = useMemo(() => Math.random() * (width - 20) + 10, [width]);
// Calculate a random position on the X axis.
const x = useMemo(() => Math.random() * 90 + 5, []);

// Calculate a random delay for the emojis to be staggered.
const delay = useMemo(() => (Math.random() + index) * DROP_INTERVAL, [index]);
Expand All @@ -34,7 +31,7 @@ export function EmojiRainDrop({
useEffect(() => {
const controls = animate(
scope.current,
{ top: height + 100 },
{ top: "110vh" },
{
duration: DROP_FALL_TIME,
delay,
Expand All @@ -47,7 +44,7 @@ export function EmojiRainDrop({
setControls(controls);

return () => controls.complete();
}, [scope, animate, delay, height, emojis]);
}, [scope, animate, delay, emojis]);

return (
<div
Expand All @@ -61,9 +58,9 @@ export function EmojiRainDrop({
onMouseOut={() => controls?.play()}
className="absolute emoji-rain-drop z-10 flex flex-col select-none cursor-pointer"
style={{
left: y,
left: `${x}vw`,
fontSize: "2em",
top: initialX,
top: initialY,
}}
ref={scope}
>
Expand Down
4 changes: 3 additions & 1 deletion src/typescript/sdk/src/indexer-v2/queries/app/launch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import "server-only";
if (process.env.NODE_ENV !== "test") {
require("server-only");
}

import { DatabaseRpc } from "../../types/json-types";
import { postgrest } from "../client";
Expand Down
1 change: 1 addition & 0 deletions src/typescript/sdk/src/indexer-v2/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ export const toPriceFeed = (data: DatabaseJsonType["price_feed"]) => {
};
};

/// Replace `\x` with `0x` then convert to market symbol data.
export const toRandomSymbolsRPCResponse = (data: DatabaseJsonType["random_symbols"]) =>
symbolBytesToEmojis("0" + data.emojis.substring(1));

Expand Down
3 changes: 1 addition & 2 deletions src/typescript/sdk/src/indexer-v2/types/json-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ export enum TableName {

export enum DatabaseRpc {
UserPools = "user_pools",
PriceFeed = "price_feed",
RandomSymbols = "random_symbols",
}

Expand Down Expand Up @@ -366,7 +365,7 @@ export type DatabaseJsonType = {
ProcessedFields &
UserLPCoinBalance & { daily_volume: Uint128String }
>;
[DatabaseRpc.RandomSymbols]: { emojis: string };
[DatabaseRpc.RandomSymbols]: { emojis: `\\x${string}` };
};

type Columns = DatabaseJsonType[TableName.GlobalStateEvents] &
Expand Down

0 comments on commit f4266b9

Please sign in to comment.