Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referral UI #284

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:

env:
solana_version: stable
solana_version: v1.14.17
VERBOSE: 1

jobs:
Expand Down
10 changes: 6 additions & 4 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
"@heroicons/react": "^2.0.13",
"@metaplex-foundation/js": "^0.18.3",
"@popperjs/core": "^2.11.6",
"@solana/pay": "^0.2.5",
"@solana/spl-token": "^0.3.6",
"@solana/wallet-adapter-base": "^0.9.22",
"@solana/wallet-adapter-react": "^0.15.30",
"@solana/wallet-adapter-react-ui": "^0.9.29",
"@solana/wallet-adapter-wallets": "^0.19.15",
"@solana/wallet-adapter-base": "^0.9.23",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/wallet-adapter-react-ui": "^0.9.34",
"@solana/wallet-adapter-wallets": "^0.19.23",
"@solana/web3.js": "^1.66.2",
"@sunrisestake/client": "*",
"@sunrisestake/marinade-ts-sdk": "4.0.4-alpha.18",
Expand All @@ -37,6 +38,7 @@
"classnames": "^2.3.2",
"constants-browserify": "^1.0.0",
"crypto-browserify": "^3.12.0",
"daisyui": "^3.9.2",
"dayjs": "^1.11.7",
"dotenv-cli": "^6.0.0",
"https-browserify": "^1.0.0",
Expand Down
Binary file added packages/app/public/clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/guide/refer/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/guide/refer/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/sowing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/watering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/wood-transparent-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/wood-transparent-thin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/wood-transparent-v-thin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/wood-transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/wood-vert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 0 additions & 8 deletions packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import {
} from "@solana/wallet-adapter-react";
import { WalletModalProvider } from "@solana/wallet-adapter-react-ui";
import {
BackpackWalletAdapter,
BraveWalletAdapter,
CoinbaseWalletAdapter,
ExodusWalletAdapter,
GlowWalletAdapter,
PhantomWalletAdapter,
SolflareWalletAdapter,
TorusWalletAdapter,
Expand All @@ -36,13 +32,9 @@ const App: FC = () => {
const wallets = useMemo(
() => [
new PhantomWalletAdapter(),
new GlowWalletAdapter(),
new SolflareWalletAdapter(),
new TorusWalletAdapter(),
new BackpackWalletAdapter(),
new ExodusWalletAdapter(),
new CoinbaseWalletAdapter(),
new BraveWalletAdapter(),
],
[]
);
Expand Down
26 changes: 23 additions & 3 deletions packages/app/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ import { ForestApp } from "./forest/ForestApp";
import { GrowApp } from "./grow/GrowApp";
import { HubApp } from "./hub/HubApp";
import { LockingApp } from "./locking/LockingApp";
import { ReferralApp } from "./referral/ReferralApp";
import { StakingApp } from "./staking/StakingApp";
import { Link, useLocation } from "react-router-dom";
import { useLocation } from "react-router-dom";
import { Layout } from "./common/partials/Layout";
import { debounce } from "./common/utils";
import { useHelp } from "./common/context/HelpContext";
import { LinkWithQuery } from "./common/components/LinkWithQuery";

export enum AppRoute {
Connect = "/connect", // not a route at present TODO fix
Forest = "/forest",
Grow = "/grow",
Hub = "/",
Lock = "/lock",
Referral = "/referral",
Stake = "/stake",
}

Expand All @@ -32,6 +35,7 @@ export const Routes: FC = () => {
grow: useRef<null | HTMLDivElement>(null),
hub: useRef<null | HTMLDivElement>(null),
locking: useRef<null | HTMLDivElement>(null),
referral: useRef<null | HTMLDivElement>(null),
lost: useRef<null | HTMLDivElement>(null),
staking: useRef<null | HTMLDivElement>(null),
};
Expand Down Expand Up @@ -96,6 +100,16 @@ export const Routes: FC = () => {
setCurrentHelpRoute(AppRoute.Lock);
},
},
{
path: AppRoute.Referral,
onMatch: () => {
appRefs.referral.current?.scrollIntoView({
behavior: "smooth",
});
setCurrentRouteApp(appRefs.referral);
setCurrentHelpRoute(AppRoute.Referral);
},
},
{
path: AppRoute.Stake,
onMatch: () => {
Expand Down Expand Up @@ -136,6 +150,12 @@ export const Routes: FC = () => {
ref={appRefs.locking}
active={currentRouteApp === appRefs.locking}
/>
<ReferralApp
id="referral-app"
className="App ReferralApp"
ref={appRefs.referral}
active={currentRouteApp === appRefs.referral}
/>
<StakingApp
id="staking-app"
className="App StakingApp"
Expand All @@ -150,12 +170,12 @@ export const Routes: FC = () => {
<p className="text-2xl font-bold">
Oh, oh. You&apos;ve got lost in the woods... 🐺
</p>
<Link
<LinkWithQuery
className="mt-2 px-5 py-3 border-2 border-green rounded-lg leading-6 text-green text-xl"
to="/"
>
Back home
</Link>
</LinkWithQuery>
</div>
</div>
</Layout>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/common/components/ExternalLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
FaTwitter,
} from "react-icons/fa";
import { Panel } from "./Panel";
import { type FC } from "react";
import React, { type FC } from "react";

export const ExternalLinks: FC = () => {
return (
Expand Down
24 changes: 24 additions & 0 deletions packages/app/src/common/components/LinkWithQuery.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Link, type LinkProps, useLocation } from "react-router-dom";
import { type FC, type PropsWithChildren } from "react";

export const LinkWithQuery: FC<PropsWithChildren & LinkProps> = ({
children,
to,
...props
}) => {
const { search } = useLocation();

const linkParams = typeof to === "string" ? { pathname: to } : to;

return (
<Link
to={{
...linkParams,
search,
}}
{...props}
>
{children}
</Link>
);
};
23 changes: 23 additions & 0 deletions packages/app/src/common/components/Tweet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { type FC } from "react";
import { useScript } from "../hooks";

export const Tweet: FC<{
tweet: string;
url?: string;
size?: "small" | "medium" | "large";
}> = ({ tweet, url, size = "large" }) => {
useScript("https://platform.x.com/widgets.js");
return (
<a
href="https://twitter.com/share?ref_src=twsrc%5Etfw"
className="twitter-share-button"
data-size={size}
data-text={tweet}
data-url={url}
data-related="sunrisestake"
data-show-count="false"
>
Tweet
</a>
);
};
22 changes: 5 additions & 17 deletions packages/app/src/common/components/TweetButton.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React from "react";
import toast, { type Toast } from "react-hot-toast";

import { useScript } from "../hooks";
import { BaseModal } from "./modals";
import { Tweet } from "./Tweet";

interface TweetButtonProps {
amount: string;
t: Toast;
}

const TweetButton: React.FC<TweetButtonProps> = ({ t }) => {
useScript("https://platform.twitter.com/widgets.js");

return (
<BaseModal
ok={() => {
Expand Down Expand Up @@ -43,21 +41,11 @@ const TweetButton: React.FC<TweetButtonProps> = ({ t }) => {
</div>

<div className="flex flex-row justify-center mb-16">
<a
href="https://twitter.com/share?ref_src=twsrc%5Etfw"
className="twitter-share-button"
data-size="large"
data-text="I just staked with Sunrise, offsetting carbon and making Solana stronger."
data-url="https://app.sunrisestake.com/"
data-via="sunrisestake"
// data-hashtags=""
// data-related=""
data-show-count="false"
>
Tweet
</a>
<Tweet
url="https://app.sunrisestake.com/"
tweet="I just staked with Sunrise, offsetting carbon and making Solana stronger."
/>
</div>
{/* </div> */}
</BaseModal>
);
};
Expand Down
49 changes: 49 additions & 0 deletions packages/app/src/common/container/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { type FC, type PropsWithChildren, type ReactNode } from "react";
import clx from "classnames";

interface CardProps {
title?: string;
image?: ReactNode;
orientation?: "horizontal" | "vertical";
size?: "small" | "medium" | "large";
}

export const Card: FC<PropsWithChildren & CardProps> = ({
children,
image,
title,
orientation = "vertical",
size = "medium",
}) => (
<div
className={clx(
orientation === "horizontal" && "card-side",
size === "small"
? "w-32 h-32 p-2"
: size === "medium"
? "w-48 h-48 p-4"
: "w-128 h-128 p-4",
"card glass"
)}
>
{image !== undefined && <figure className="min-h-2/3">{image}</figure>}
<div
className={clx(
"card-body items-center content-center",
size === "small" ? "p-1" : size === "medium" ? "p-1" : "p-3"
)}
>
{title !== undefined && (
<h2
className={clx(
"card-title text-center",
size === "small" && "text-s"
)}
>
{title}
</h2>
)}
{children}
</div>
</div>
);
50 changes: 50 additions & 0 deletions packages/app/src/common/container/TopicContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, {
type ForwardRefRenderFunction,
type PropsWithChildren,
type ReactNode,
} from "react";
import clx from "classnames";

interface TitleProps {
children: ReactNode;
}

const Title: React.FC<TitleProps> = ({ children }) => (
<div className="h-[25vh] flex items-center justify-center">{children}</div>
);

interface MainProps {
children: ReactNode;
}

const Main: React.FC<MainProps> = ({ children }) => (
<div
className={`h-[75vh] bg-wood-sm bg-cover overflow-y-auto pt-5 mb-5 md:bg-wood-md lg:bg-wood-lg lg:flex lg:items-center`}
>
{children}
</div>
);

const _TopicContainer: ForwardRefRenderFunction<
HTMLDivElement,
{
className?: string;
active?: boolean;
titleContents: ReactNode;
} & React.HTMLAttributes<HTMLElement> &
PropsWithChildren
> = ({ children, titleContents, className, active = false, ...rest }, ref) => (
<div
className={clx(
"relative flex flex-col justify-start items-center",
className
)}
ref={ref}
{...rest}
>
<Title>{titleContents}</Title>
<Main>{children}</Main>
</div>
);

export const TopicContainer = React.forwardRef(_TopicContainer);
10 changes: 6 additions & 4 deletions packages/app/src/common/context/ZenModeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import {
useEffect,
} from "react";

interface ZenModeSettings {
export interface ZenModeSettings {
showBGImage: boolean;
showExternalLinks: boolean;
showHelpButton: boolean;
showWallet: boolean;
}

const ZenModeContext = createContext<
[ZenModeSettings, Dispatch<ZenModeSettings>]
[ZenModeSettings, Dispatch<React.SetStateAction<ZenModeSettings>>]
>([
{
showBGImage: false,
Expand Down Expand Up @@ -50,7 +50,9 @@ const ZenModeProvider: FC<{ children: ReactNode }> = ({ children }) => {
);
};

const useZenMode = (): [ZenModeSettings, Dispatch<ZenModeSettings>] =>
useContext(ZenModeContext);
const useZenMode = (): [
ZenModeSettings,
Dispatch<React.SetStateAction<ZenModeSettings>>
] => useContext(ZenModeContext);

export { ZenModeProvider, useZenMode };
Loading