Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Css refactor (#432)
Browse files Browse the repository at this point in the history
* display section clean

* foot section

* main section

* final cleans
  • Loading branch information
harshasomisetty authored Jul 16, 2023
1 parent 7fde5f6 commit 1fdc926
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 77 deletions.
33 changes: 17 additions & 16 deletions apps/payment-ui/src/components/DisplaySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ import { useSelector } from 'react-redux';
const DisplaySection = () => {
const paymentDetails = useSelector(getPaymentDetails);

const handleBackButtonClick = () => {
if (paymentDetails?.cancelUrl) {
window.location.href = paymentDetails.cancelUrl;
}
};

return (
<div className="grid grid-cols-3 w-full max-w-xl">
<div className="flex flex-row">
<button
className="btn btn-ghost z-10"
onClick={() => {
if (paymentDetails?.cancelUrl != null) {
window.location.href = paymentDetails.cancelUrl;
}
}}
>
<MdArrowBack color="white" size={30} />
</button>
</div>
<div className="flex flex-col mx-auto my-auto">
<Image src="/solana-pay.svg" alt="Solana Pay Logo" width={80} height={200} />
<div className="w-full max-w-xl mx-auto">
<div className="container mx-auto">
<div className="grid grid-cols-3 h-16 py-2 font-black text-white text-2xl">
<button className="btn btn-ghost z-10" onClick={handleBackButtonClick}>
<MdArrowBack color="white" size={30} />
</button>
<div className="flex flex-col mx-auto my-auto">
<Image src="/solana-pay.svg" alt="Solana Pay Logo" width={80} height={200} />
</div>
<div />
</div>
</div>
<div className="flex flex-col"></div>
</div>
);
};
Expand Down
25 changes: 14 additions & 11 deletions apps/payment-ui/src/components/FooterSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ const FooterSection = () => {
const isSolanaPayNotification = useSelector(getIsSolanaPayNotification);
const connectedWalletNotification = useSelector(getConnectWalletNotification);

if (paymentMethod == 'connect-wallet' && mergedState == MergedState.start) {
return <PayWithWalletSection />;
} else if (paymentMethod == 'qr-code' && isSolanaPayNotification) {
return <SolanaPayErrorView />;
} else if (
const isPayWithWalletSection = () => paymentMethod == 'connect-wallet' && mergedState == MergedState.start;
const isSolanaPayErrorView = () => paymentMethod == 'qr-code' && isSolanaPayNotification;
const isCancelTransactionButton = () =>
mergedState > MergedState.start &&
mergedState < MergedState.completed &&
connectedWalletNotification != Notification.declined
) {
return <CancelTransactionButton />;
} else {
return <div></div>;
}
connectedWalletNotification != Notification.declined;

return (
<div className="w-full">
<div className="container h-36 mx-auto px-4 sm:px-20 bg-white text-white text-center max-w-2xl">
{isPayWithWalletSection() && <PayWithWalletSection />}
{isSolanaPayErrorView() && <SolanaPayErrorView />}
{isCancelTransactionButton() && <CancelTransactionButton />}
</div>
</div>
);
};

export default FooterSection;
20 changes: 6 additions & 14 deletions apps/payment-ui/src/components/MainSection.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
import { BlockedProps } from '@/pages';
import { useRouter } from 'next/router';
import React, { ReactNode } from 'react';
import CheckoutSection from './CheckoutSection';

interface CheckoutWrapperProps {
children: ReactNode;
}

const CheckoutWrapper: React.FC<CheckoutWrapperProps> = ({ children }) => {
return <div className="flex flex-grow flex-col h-full">{children}</div>;
};

const MainSection = (props: BlockedProps) => {
const MainSection = () => {
const router = useRouter();

if (!router.isReady) {
return <div>Loading...</div>;
}

return (
<CheckoutWrapper>
<CheckoutSection />
</CheckoutWrapper>
<div className="flex flex-col flex-auto">
<div className="flex-grow container mx-auto bg-white rounded-t-2xl max-w-2xl px-4 sm:px-20">
<CheckoutSection />
</div>
</div>
);
};

Expand Down
6 changes: 5 additions & 1 deletion apps/payment-ui/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ class MyDocument extends Document {
render() {
return (
<Html lang="en">
<Head />
<Head>
<title>Solana Pay Payment Portal</title>
<meta name="description" content="Use Solana Pay for your Shopify Checkout" />
<link rel="icon" href="/favicon.ico" />
</Head>
<body>
<Main />
<NextScript />
Expand Down
39 changes: 4 additions & 35 deletions apps/payment-ui/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import FooterSection from '@/components/FooterSection';
import { getPaymentMethod } from '@/features/payment-options/paymentOptionsSlice';
import { getMergedState } from '@/features/payment-session/paymentSessionSlice';
import { GetServerSideProps, GetServerSidePropsContext } from 'next';
import Head from 'next/head';
import React from 'react';
import { useSelector } from 'react-redux';
import DisplaySection from '../components/DisplaySection';
import MainSection from '../components/MainSection';

Expand All @@ -16,41 +12,14 @@ export const getServerSideProps: GetServerSideProps = async (context: GetServerS
};
};

export type BlockedProps = {
isBlocked: string;
country: string;
};

export default function Home({ isBlocked, country }: BlockedProps) {
const paymentMethod = useSelector(getPaymentMethod);
const mergedState = useSelector(getMergedState);

export default function Home() {
return (
<>
<Head>
<title>Solana Pay Payment Portal</title>
<meta name="description" content="Use Solana Pay for your Shopify Checkout" />
<link rel="icon" href="/favicon.ico" />
</Head>
<React.Fragment>
<div className="flex flex-col h-screen bg-black">
<div className="w-full max-w-xl mx-auto">
<div className="container mx-auto">
<div className="block h-16 py-2 font-black text-white text-2xl max-w-xl">
<DisplaySection />
</div>
</div>
</div>
<div className="flex flex-col flex-auto bg-black">
<div className="flex-grow container mx-auto bg-white rounded-t-2xl max-w-2xl px-4 sm:px-20">
<MainSection isBlocked={'false'} country={'usa'} />
</div>
</div>
<div className="w-full bg-black">
<div className="container h-36 mx-auto px-4 sm:px-20 bg-white text-white text-center max-w-2xl">
<FooterSection />
</div>
</div>
<DisplaySection />
<MainSection />
<FooterSection />
</div>
</React.Fragment>
</>
Expand Down

1 comment on commit 1fdc926

@vercel
Copy link

@vercel vercel bot commented on 1fdc926 Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.