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

feature: Terms and Privacy modals #97

Merged
merged 16 commits into from
Aug 21, 2024
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-staking",
"version": "0.2.37",
"version": "0.2.38",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { shouldDisplayTestingMsg } from "@/config";

import { ConnectSmall } from "../Connect/ConnectSmall";
import { ConnectedSmall } from "../Connect/ConnectedSmall";
import { Logo } from "../Logo/Logo";
import { TestingInfo } from "../TestingInfo/TestingInfo";
import { ThemeToggle } from "../ThemeToggle/ThemeToggle";

import { Logo } from "./Logo";

interface HeaderProps {
onConnect: () => void;
address: string;
Expand Down
36 changes: 36 additions & 0 deletions src/app/components/Logo/Icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useTheme } from "next-themes";
import Image from "next/image";
import { useEffect, useState } from "react";

import darkIcon from "@/app/assets/icon-black.svg";
import lightIcon from "@/app/assets/icon-white.svg";

interface IconProps {}

export const Icon: React.FC<IconProps> = () => {
const [mounted, setMounted] = useState(false);
const { resolvedTheme } = useTheme();
const lightSelected = resolvedTheme === "light";

// useEffect only runs on the client, so now we can safely show the UI
useEffect(() => {
setMounted(true);
}, []);

// uses placeholder of babylon logo with primary color
// since before theme is resolved, we don't know which logo to show
if (!mounted) {
return <span className="h-[24px] w-[24px]" />;
}

return (
<span className="inline-block mx-2">
<Image
src={lightSelected ? darkIcon : lightIcon}
alt="Babylon"
width={24}
height={24}
/>
</span>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const Logo: React.FC<LogoProps> = () => {
setMounted(true);
}, []);

// uses skeleton of babylon logo with primary color
// uses placeholder of babylon logo with primary color
// since before theme is resolved, we don't know which logo to show
if (!mounted) {
return <div className="h-[40px] w-[159px]" />;
Expand Down
11 changes: 10 additions & 1 deletion src/app/components/Modals/ConnectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IoMdClose } from "react-icons/io";
import { PiWalletBold } from "react-icons/pi";
import { Tooltip } from "react-tooltip";

import { usePrivacy } from "@/app/context/Privacy/PrivacyContext";
import { useTerms } from "@/app/context/Terms/TermsContext";
import { getNetworkConfig } from "@/config/network.config";
import { BROWSER_INJECTED_WALLET_NAME, walletList } from "@/utils/wallet/list";
Expand Down Expand Up @@ -42,6 +43,7 @@ export const ConnectModal: React.FC<ConnectModalProps> = ({
const BROWSER = "btcwallet";

const { openTerms } = useTerms();
const { openPrivacy } = usePrivacy();

useEffect(() => {
const fetchWalletProviderDetails = async () => {
Expand Down Expand Up @@ -156,10 +158,17 @@ export const ConnectModal: React.FC<ConnectModalProps> = ({
I certify that I have read and accept the updated{" "}
<button
onClick={openTerms}
className="transition-colors hover:text-primary cursor-pointer btn btn-link no-underline text-base-content px-0 h-auto min-h-0"
className="cursor-pointer btn btn-link px-0 h-auto min-h-0"
>
Terms of Use
</button>
{" and "}
<button
onClick={openPrivacy}
className="cursor-pointer btn btn-link px-0 h-auto min-h-0"
>
Privacy Policy
</button>
.
</span>
</label>
Expand Down
30 changes: 30 additions & 0 deletions src/app/components/Modals/Privacy/PrivacyModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { IoMdClose } from "react-icons/io";

import { GeneralModal } from "../GeneralModal";

import { Privacy } from "./data/privacy";

interface PrivacyModalProps {
open: boolean;
onClose: (value: boolean) => void;
}

export const PrivacyModal: React.FC<PrivacyModalProps> = ({
open,
onClose,
}) => {
return (
<GeneralModal open={open} onClose={onClose}>
<div className="mb-4 flex items-center justify-between">
<h4 className="font-bold">Privacy Policy</h4>
<button
className="btn btn-circle btn-ghost btn-sm"
onClick={() => onClose(false)}
>
<IoMdClose size={24} />
</button>
</div>
<Privacy />
</GeneralModal>
);
};
Loading