-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Bogdan Crisan <[email protected]>
- Loading branch information
Showing
122 changed files
with
4,222 additions
and
8,441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule processor
updated
8 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 7 additions & 49 deletions
56
...cript/frontend/src/components/pages/home/components/table-card/LinkOrAnimationTrigger.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,17 @@ | ||
import { type SymbolEmojiData } from "@sdk/emoji_data/types"; | ||
import { useGenerateEvent } from "../../test-generate-event/use-generate-event"; | ||
import { type PropsWithChildren } from "react"; | ||
import { ROUTES } from "router/routes"; | ||
import { emojiNamesToPath } from "utils/pathname-helpers"; | ||
import Link from "next/link"; | ||
import { VERCEL } from "@sdk/const"; | ||
import React from "react"; | ||
|
||
/** | ||
* To facilitate easy visual testing, we swap out the link on the grid table card with a div that triggers a | ||
* random event when clicked. Note that the test click div will never render in Vercel build mode or in | ||
* production. You also have to set a specific environment variable to true. | ||
* | ||
* We put this component in the grid table card component so that when the user clicks on the card, it will | ||
* trigger the event (or navigate to the market page if not in test mode). | ||
* | ||
* @returns {JSX.Element} The link that goes to the market page, or if in test, the div that emulates triggering a | ||
* random event in our event state store. | ||
*/ | ||
export const GenerateEventComponent = ({ | ||
export const EmojiMarketPageLink = ({ | ||
emojis, | ||
marketID, | ||
...props | ||
}: { emojis: SymbolEmojiData[]; marketID: number } & PropsWithChildren) => { | ||
// Note that without `stateOnly: true`, the event could conflict with other events. This may cause | ||
// visual artifacts that won't actually appear with real data. | ||
const generateEvent = useGenerateEvent({ marketID, emojis, stateOnly: true }); | ||
}: { emojis: SymbolEmojiData[] } & PropsWithChildren) => ( | ||
<Link href={`${ROUTES.market}/${emojiNamesToPath(emojis.map((x) => x.name))}`}> | ||
{props.children} | ||
</Link> | ||
); | ||
|
||
return ( | ||
<> | ||
<div onClick={generateEvent}>{props.children}</div> | ||
</> | ||
); | ||
}; | ||
|
||
export const LinkOrAnimationTrigger = ({ | ||
emojis, | ||
marketID, | ||
...props | ||
}: { emojis: SymbolEmojiData[]; marketID: number } & PropsWithChildren) => { | ||
return ( | ||
<> | ||
{VERCEL || | ||
process.env.NODE_ENV === "production" || | ||
process.env.NEXT_PUBLIC_ANIMATION_TEST !== "true" ? ( | ||
<Link href={`${ROUTES.market}/${emojiNamesToPath(emojis.map((x) => x.name))}`}> | ||
{props.children} | ||
</Link> | ||
) : ( | ||
<GenerateEventComponent emojis={emojis} marketID={marketID}> | ||
{props.children} | ||
</GenerateEventComponent> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default React.memo(LinkOrAnimationTrigger); | ||
export default React.memo(EmojiMarketPageLink); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.