Skip to content

Commit

Permalink
Add market page banner and navigation link to arena
Browse files Browse the repository at this point in the history
  • Loading branch information
CRBl69 committed Jan 21, 2025
1 parent 32e27cd commit 6021317
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 24 deletions.
9 changes: 8 additions & 1 deletion src/typescript/frontend/src/app/market/[market]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getMarketAddress } from "@sdk/emojicoin_dot_fun";
import { type Metadata } from "next";
import { getAptPrice } from "lib/queries/get-apt-price";
import { AptPriceContextProvider } from "context/AptPrice";
import { fetchMelee } from "@/queries/arena";

export const revalidate = 2;

Expand Down Expand Up @@ -77,13 +78,18 @@ const EmojicoinPage = async (params: EmojicoinPageProps) => {
const { marketID } = state.market;
const marketAddress = getMarketAddress(emojis);

const [chats, swaps, marketView, aptPrice] = await Promise.all([
const [chats, swaps, marketView, aptPrice, melee] = await Promise.all([
fetchChatEvents({ marketID, pageSize: EVENTS_ON_PAGE_LOAD }),
fetchSwapEvents({ marketID, pageSize: EVENTS_ON_PAGE_LOAD }),
wrappedCachedContractMarketView(marketAddress.toString()),
getAptPrice(),
fetchMelee({}),
]);

const isInMelee =
melee?.arenaMelee.emojicoin0MarketAddress === state.market.marketAddress ||
melee?.arenaMelee.emojicoin1MarketAddress === state.market.marketAddress;

return (
<AptPriceContextProvider aptPrice={aptPrice}>
<ClientEmojicoinPage
Expand All @@ -95,6 +101,7 @@ const EmojicoinPage = async (params: EmojicoinPageProps) => {
marketView,
...state.market,
}}
isInMelee={isInMelee}
/>
</AptPriceContextProvider>
);
Expand Down
22 changes: 22 additions & 0 deletions src/typescript/frontend/src/components/Badge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useThemeContext } from "context";
import type { Colors } from "theme/types";

export const Badge: React.FC<React.PropsWithChildren<{ color: keyof Colors }>> = ({
children,
color,
}) => {
const { theme } = useThemeContext();

return (
<div
style={{
border: `1px solid ${theme.colors[color]}`,
borderRadius: "8px",
color: theme.colors[color],
}}
className="pixel-heading-4 px-[.4rem] h-min h-min"
>
{children}
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { FlexGap } from "@containers";

import { type MenuItemProps } from "./types";

const MenuItem: React.FC<MenuItemProps> = ({ title, width, onClick = () => {} }) => {
const MenuItem: React.FC<MenuItemProps> = ({ title, width, onClick = () => {}, pill }) => {
const { t } = translationFunction();

const { ref, replay } = useScramble({
Expand All @@ -32,6 +32,7 @@ const MenuItem: React.FC<MenuItemProps> = ({ title, width, onClick = () => {} })
ref={ref}
ellipsis
/>
{pill}
<Text textScale="pixelHeading4" color="econiaBlue" textTransform="uppercase" fontSize="24px">
{" }"}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export type MenuItemProps = {
title: string;
width: string;
onClick?: () => void;
pill?: React.ReactNode;
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const MobileMenuItem: React.FC<MobileMenuItemProps> = ({
title,
onClick = () => {},
borderBottom = true,
pill,
}) => {
const { t } = translationFunction();

Expand All @@ -25,14 +26,15 @@ const MobileMenuItem: React.FC<MobileMenuItemProps> = ({

return (
<StyledItemWrapper onMouseOver={replay} onClick={onClick} borderBottom={borderBottom}>
<div className={withIcon?.className}>
<div className={`${withIcon?.className} ${pill?.className}`}>
{withIcon?.icon}
<Text
textScale={withIcon ? "pixelHeading4" : "pixelHeading3"}
color="black"
textTransform="uppercase"
ref={ref}
/>
{pill?.pill}
</div>
{!withIcon && <Arrow width="18px" color="black" />}
</StyledItemWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ export type MobileMenuItemProps = {
title: string;
onClick?: () => void;
borderBottom?: boolean;
pill?: {
className: string;
pill: React.ReactNode;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useWalletModal } from "context/wallet-context/WalletModalContext";
import { AnimatePresence, useAnimationControls } from "framer-motion";
import AnimatedDropdownItem from "./components/animated-dropdown-item";
import useIsUserGeoblocked from "@hooks/use-is-user-geoblocked";
import { Badge } from "components/Badge";

const IconClass = "w-[22px] h-[22px] m-auto ml-[3ch] mr-[1.5ch]";

Expand Down Expand Up @@ -146,7 +147,18 @@ export const MobileMenu: React.FC<MobileMenuProps> = ({
onClick={handleCloseMobileMenu}
width="100%"
>
<MobileMenuItem title={title} borderBottom={i !== linksForCurrentPage.length - 1} />
<MobileMenuItem
title={title}
borderBottom={i !== linksForCurrentPage.length - 1}
pill={
title === "arena"
? {
className: "flex flex-row items-center gap-[.5em]",
pill: <Badge color="black">NEW</Badge>,
}
: undefined
}
/>
</Link>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion src/typescript/frontend/src/components/header/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ROUTES } from "router/routes";

export const NAVIGATE_LINKS = [
{ title: "home", path: ROUTES.home, width: "45px" },
{ title: "arena", path: ROUTES.arena, width: "52px" },
{ title: "pools", path: ROUTES.pools, width: "52px" },
{ title: "launch emojicoin", path: ROUTES.launch, width: "158px" },
{ title: "docs", path: ROUTES.docs, width: "42px" },
Expand Down
7 changes: 6 additions & 1 deletion src/typescript/frontend/src/components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ButtonWithConnectWalletFallback from "./wallet-button/ConnectWalletButton
import { useSearchParams } from "next/navigation";
import Link, { type LinkProps } from "next/link";
import { useEmojiPicker } from "context/emoji-picker-context";
import { Badge } from "components/Badge";

const Header = ({ isOpen, setIsOpen }: HeaderProps) => {
const { isDesktop } = useMatchBreakpoints();
Expand Down Expand Up @@ -91,7 +92,11 @@ const Header = ({ isOpen, setIsOpen }: HeaderProps) => {
href={path}
target={path.startsWith("https://") ? "_blank" : undefined}
>
<MenuItem width={width} title={title} />
<MenuItem
width={width}
title={title}
pill={title === "arena" ? <Badge color="econiaBlue">NEW</Badge> : undefined}
/>
</Link>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import MainInfo from "./components/main-info/MainInfo";
import { useReliableSubscribe } from "@hooks/use-reliable-subscribe";
import { type BrokerEvent } from "@/broker/types";
import { marketToLatestBars } from "@/store/event/candlestick-bars";
import Carousel from "components/carousel";
import { Text } from "components";
import { GlobeIcon } from "lucide-react";
import { useThemeContext } from "context";
import Link from "next/link";
import { ROUTES } from "router/routes";

const EVENT_TYPES: BrokerEvent[] = ["Chat", "PeriodicState", "Swap"];

Expand All @@ -32,8 +38,27 @@ const ClientEmojicoinPage = (props: EmojicoinProps) => {

useReliableSubscribe({ eventTypes: EVENT_TYPES });

const { theme } = useThemeContext();

return (
<Box>
{props.isInMelee && (
<Carousel gap={16}>
<div className="flex flex-row items-center gap-[16px]">
<Link href={ROUTES.arena}>
<Text
textScale="pixelHeading3"
color="econiaBlue"
className="w-max"
textTransform="uppercase"
>
To trade this inside the melee, go to arena
</Text>
</Link>
<GlobeIcon color={theme.colors.econiaBlue} />
</div>
</Carousel>
)}
<MainInfo data={props.data} />
{isTablet || isMobile ? <MobileGrid data={props.data} /> : <DesktopGrid data={props.data} />}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type DataProps = MarketMetadataModel & {

export interface EmojicoinProps {
data: DataProps;
isInMelee: boolean;
}

export interface MainInfoProps {
Expand Down
19 changes: 1 addition & 18 deletions src/typescript/frontend/src/components/svg/icons/LogoIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,8 @@ import Svg from "components/svg/Svg";
import { VERSION } from "lib/env";
import { type SvgProps } from "../types";
import { useThemeContext } from "context";
import Text from "components/text";
import type { Colors } from "theme/types";

const Badge: React.FC<React.PropsWithChildren<{ color: keyof Colors }>> = ({ children, color }) => {
const { theme } = useThemeContext();

return (
<Text
style={{
border: `1px solid ${theme.colors[color]}`,
borderRadius: "8px",
color: theme.colors[color],
}}
className="!pixel-heading-4 px-[.4rem] text-[15px]"
>
{children}
</Text>
);
};
import { Badge } from "components/Badge";

const VersionBadge: React.FC<{ color: keyof Colors }> = ({ color }) =>
// prettier-ignore
Expand Down
1 change: 1 addition & 0 deletions src/typescript/frontend/src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const ROUTES = {
maintenance: "/maintenance",
launching: "/launching",
dexscreener: "/dexscreener",
arena: "/arena",
} as const;

0 comments on commit 6021317

Please sign in to comment.