From 0438fd4a0f47b677d0bc579130887a9ea29b0452 Mon Sep 17 00:00:00 2001 From: paur94 Date: Tue, 16 Apr 2024 17:33:31 +0400 Subject: [PATCH 1/2] added maintanance --- app/page.tsx | 4 ++ components/buttons/submitButton.tsx | 87 ++++++++++++++++++++++++++ components/cardContainer.tsx | 10 +++ components/icons/TwitterLogo.tsx | 7 +++ components/icons/spinIcon.tsx | 10 +++ components/maintanance/maintanance.tsx | 32 ++++++++++ context/authContext.tsx | 38 +++++++++++ 7 files changed, 188 insertions(+) create mode 100644 components/buttons/submitButton.tsx create mode 100644 components/cardContainer.tsx create mode 100644 components/icons/TwitterLogo.tsx create mode 100644 components/icons/spinIcon.tsx create mode 100644 components/maintanance/maintanance.tsx create mode 100644 context/authContext.tsx diff --git a/app/page.tsx b/app/page.tsx index f22f5c9..3c505f2 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,9 +1,13 @@ import Search from "@/components/Search"; import DataTable from "./DataTable"; import { SettingsProvider } from "@/context/settings"; +import MaintananceContent from "@/components/maintanance/maintanance"; export default async function Home() { + if (process.env.NEXT_PUBLIC_MAINTANANCE == String(true)) + return + return (
diff --git a/components/buttons/submitButton.tsx b/components/buttons/submitButton.tsx new file mode 100644 index 0000000..dcd956d --- /dev/null +++ b/components/buttons/submitButton.tsx @@ -0,0 +1,87 @@ +import { FC, MouseEventHandler } from "react"; +import SpinIcon from "../icons/spinIcon"; + +type buttonStyle = 'outline' | 'filled'; +type buttonSize = 'small' | 'medium' | 'large'; +type text_align = 'center' | 'left' +type button_align = 'left' | 'right' + +export class SubmitButtonProps { + isDisabled?: boolean; + isSubmitting?: boolean; + type?: 'submit' | 'reset' | 'button' | undefined; + onClick?: MouseEventHandler | undefined; + icon?: React.ReactNode; + buttonStyle?: buttonStyle = 'filled'; + size?: buttonSize = 'medium'; + text_align?: text_align = 'center' + button_align?: button_align = 'left'; + className?: string; + children?: React.ReactNode; +} + +function constructClassNames(size: buttonSize, buttonStyle: buttonStyle) { + let defaultStyle = ' border border-primary disabled:border-primary-900 items-center space-x-1 disabled:text-opacity-40 disabled:bg-primary-900 disabled:cursor-not-allowed relative w-full flex justify-center font-semibold rounded-md transform hover:brightness-125 transition duration-200 ease-in-out' + defaultStyle += buttonStyle == 'filled' ? " bg-primary text-primary-actionButtonText" : " text-primary"; + + switch (size) { + case 'large': + defaultStyle += " py-4 px-4"; + break; + case 'medium': + defaultStyle += " py-3 px-2 md:px-3"; + break; + case 'small': + defaultStyle += " py-1.5 px-1.5"; + break; + } + + return defaultStyle; +} + +const SubmitButton: FC = ({ isDisabled, isSubmitting, icon, children, type, onClick, buttonStyle = 'filled', size = 'medium', text_align = 'center', button_align = 'left', className }) => { + return ( + + ); +} + + +type DoubleLineTextProps = { + primaryText: string, + secondarytext: string, + colorStyle: 'mltln-text-light' | 'mltln-text-dark', + reversed?: boolean +} + +const text_styles = { + 'mltln-text-light': { + primary: 'text-primary-actionButtonText', + secondary: 'text-primary-100' + }, + 'mltln-text-dark': { + primary: 'text-primary', + secondary: 'text-primary-600' + } +} + +export const DoubleLineText = ({ primaryText, secondarytext, colorStyle, reversed }: DoubleLineTextProps) => { + return
+
{secondarytext}
+
{primaryText}
+
+} + +export default SubmitButton; \ No newline at end of file diff --git a/components/cardContainer.tsx b/components/cardContainer.tsx new file mode 100644 index 0000000..f097550 --- /dev/null +++ b/components/cardContainer.tsx @@ -0,0 +1,10 @@ +export default function CardContainer(props:any) { + return (
+
+
+
+ {props.children} +
+
+
); +} \ No newline at end of file diff --git a/components/icons/TwitterLogo.tsx b/components/icons/TwitterLogo.tsx new file mode 100644 index 0000000..62fe9f2 --- /dev/null +++ b/components/icons/TwitterLogo.tsx @@ -0,0 +1,7 @@ +const TwitterLogo = (props: any) => ( + + + +); + +export default TwitterLogo; \ No newline at end of file diff --git a/components/icons/spinIcon.tsx b/components/icons/spinIcon.tsx new file mode 100644 index 0000000..809ad35 --- /dev/null +++ b/components/icons/spinIcon.tsx @@ -0,0 +1,10 @@ +import * as React from 'react' +const SpinIcon = (props:any) => ( + + + + +) + +export default SpinIcon; + diff --git a/components/maintanance/maintanance.tsx b/components/maintanance/maintanance.tsx new file mode 100644 index 0000000..571261a --- /dev/null +++ b/components/maintanance/maintanance.tsx @@ -0,0 +1,32 @@ +import TwitterLogo from "../icons/TwitterLogo"; +import LayerswapExplorerLogo from "../icons/layerswapExplorer"; +import CardContainer from "../cardContainer"; +import SubmitButton from "../buttons/submitButton"; + +function MaintananceContent(props: any) { + const twitterLogo = + const handleClick = () => { + window.open('https://twitter.com/layerswap', '_blank') + } + + return ( +
+ + +
+

+

+ We're upgrading our systems and infrastructure to give you the best experience yet. +

+ We'll be back at 15:00 UTC +

+ Any pending swaps will be completed after maintenance. +

+

+
+
+
+ ); +} + +export default MaintananceContent; diff --git a/context/authContext.tsx b/context/authContext.tsx new file mode 100644 index 0000000..01b77ea --- /dev/null +++ b/context/authContext.tsx @@ -0,0 +1,38 @@ +import React, { Context } from "react"; + +export const AuthStateContext = React.createContext({ authData: undefined, email: undefined, codeRequested: undefined, guestAuthData: undefined, tempEmail: undefined, userId: undefined, userLockedOut: false, userType: undefined }); + +type AuthState = { + email?: string, + authData?: AuthData, + guestAuthData?: AuthData, + codeRequested?: boolean, + tempEmail?: string, + userId?: string, + userLockedOut?: boolean, + userType?: UserType +} + +export type AuthData = { + access_token?: string, + expires_in?: number, + refresh_token?: string, + scope?: string, + token_type?: string, +} + +export enum UserType { + NotAuthenticatedUser = 'NotAunthenticatedUser', + GuestUser = 'guest', + AuthenticatedUser = 'main' +} + +export function useAuthState() { + const data = React.useContext(AuthStateContext as Context); + + if (data === undefined) { + throw new Error('useAuthState must be used within a AuthStateProvider'); + } + + return data; +} \ No newline at end of file From 73c39d288d93c03d86bb5e757186002fb2d1327a Mon Sep 17 00:00:00 2001 From: Aren Date: Tue, 16 Apr 2024 17:37:33 +0400 Subject: [PATCH 2/2] delete unnessecary code --- components/buttons/submitButton.tsx | 87 -------------------------- components/icons/TwitterLogo.tsx | 7 --- components/maintanance/maintanance.tsx | 6 -- context/authContext.tsx | 38 ----------- 4 files changed, 138 deletions(-) delete mode 100644 components/buttons/submitButton.tsx delete mode 100644 components/icons/TwitterLogo.tsx delete mode 100644 context/authContext.tsx diff --git a/components/buttons/submitButton.tsx b/components/buttons/submitButton.tsx deleted file mode 100644 index dcd956d..0000000 --- a/components/buttons/submitButton.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import { FC, MouseEventHandler } from "react"; -import SpinIcon from "../icons/spinIcon"; - -type buttonStyle = 'outline' | 'filled'; -type buttonSize = 'small' | 'medium' | 'large'; -type text_align = 'center' | 'left' -type button_align = 'left' | 'right' - -export class SubmitButtonProps { - isDisabled?: boolean; - isSubmitting?: boolean; - type?: 'submit' | 'reset' | 'button' | undefined; - onClick?: MouseEventHandler | undefined; - icon?: React.ReactNode; - buttonStyle?: buttonStyle = 'filled'; - size?: buttonSize = 'medium'; - text_align?: text_align = 'center' - button_align?: button_align = 'left'; - className?: string; - children?: React.ReactNode; -} - -function constructClassNames(size: buttonSize, buttonStyle: buttonStyle) { - let defaultStyle = ' border border-primary disabled:border-primary-900 items-center space-x-1 disabled:text-opacity-40 disabled:bg-primary-900 disabled:cursor-not-allowed relative w-full flex justify-center font-semibold rounded-md transform hover:brightness-125 transition duration-200 ease-in-out' - defaultStyle += buttonStyle == 'filled' ? " bg-primary text-primary-actionButtonText" : " text-primary"; - - switch (size) { - case 'large': - defaultStyle += " py-4 px-4"; - break; - case 'medium': - defaultStyle += " py-3 px-2 md:px-3"; - break; - case 'small': - defaultStyle += " py-1.5 px-1.5"; - break; - } - - return defaultStyle; -} - -const SubmitButton: FC = ({ isDisabled, isSubmitting, icon, children, type, onClick, buttonStyle = 'filled', size = 'medium', text_align = 'center', button_align = 'left', className }) => { - return ( - - ); -} - - -type DoubleLineTextProps = { - primaryText: string, - secondarytext: string, - colorStyle: 'mltln-text-light' | 'mltln-text-dark', - reversed?: boolean -} - -const text_styles = { - 'mltln-text-light': { - primary: 'text-primary-actionButtonText', - secondary: 'text-primary-100' - }, - 'mltln-text-dark': { - primary: 'text-primary', - secondary: 'text-primary-600' - } -} - -export const DoubleLineText = ({ primaryText, secondarytext, colorStyle, reversed }: DoubleLineTextProps) => { - return
-
{secondarytext}
-
{primaryText}
-
-} - -export default SubmitButton; \ No newline at end of file diff --git a/components/icons/TwitterLogo.tsx b/components/icons/TwitterLogo.tsx deleted file mode 100644 index 62fe9f2..0000000 --- a/components/icons/TwitterLogo.tsx +++ /dev/null @@ -1,7 +0,0 @@ -const TwitterLogo = (props: any) => ( - - - -); - -export default TwitterLogo; \ No newline at end of file diff --git a/components/maintanance/maintanance.tsx b/components/maintanance/maintanance.tsx index 571261a..166bd68 100644 --- a/components/maintanance/maintanance.tsx +++ b/components/maintanance/maintanance.tsx @@ -1,13 +1,7 @@ -import TwitterLogo from "../icons/TwitterLogo"; import LayerswapExplorerLogo from "../icons/layerswapExplorer"; import CardContainer from "../cardContainer"; -import SubmitButton from "../buttons/submitButton"; function MaintananceContent(props: any) { - const twitterLogo = - const handleClick = () => { - window.open('https://twitter.com/layerswap', '_blank') - } return (
diff --git a/context/authContext.tsx b/context/authContext.tsx deleted file mode 100644 index 01b77ea..0000000 --- a/context/authContext.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React, { Context } from "react"; - -export const AuthStateContext = React.createContext({ authData: undefined, email: undefined, codeRequested: undefined, guestAuthData: undefined, tempEmail: undefined, userId: undefined, userLockedOut: false, userType: undefined }); - -type AuthState = { - email?: string, - authData?: AuthData, - guestAuthData?: AuthData, - codeRequested?: boolean, - tempEmail?: string, - userId?: string, - userLockedOut?: boolean, - userType?: UserType -} - -export type AuthData = { - access_token?: string, - expires_in?: number, - refresh_token?: string, - scope?: string, - token_type?: string, -} - -export enum UserType { - NotAuthenticatedUser = 'NotAunthenticatedUser', - GuestUser = 'guest', - AuthenticatedUser = 'main' -} - -export function useAuthState() { - const data = React.useContext(AuthStateContext as Context); - - if (data === undefined) { - throw new Error('useAuthState must be used within a AuthStateProvider'); - } - - return data; -} \ No newline at end of file