Skip to content

Commit

Permalink
Merge pull request #19 from Staketab/dev
Browse files Browse the repository at this point in the history
Purchase popup
  • Loading branch information
VitalikKarpuk authored Mar 6, 2024
2 parents 4d08c7c + b17e1d8 commit 977556b
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 3 deletions.
1 change: 1 addition & 0 deletions ui/app/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ body {
--col--gray4: rgba(0, 0, 0, 0.3);
--col--gray8: rgba(0, 0, 0, 0.05);
--col--secondary8: rgba(57, 99, 255, 0.5);
--col--border: #dde0eb;

/* BUTTON */
/* rgba(52, 89, 231, 1) */
Expand Down
2 changes: 1 addition & 1 deletion ui/components/atoms/button/button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

.apiButton:disabled {
background-color: var(--col--button4);
cursor: not-allowed;
cursor: default;
box-shadow: none;
}

Expand Down
13 changes: 11 additions & 2 deletions ui/components/atoms/resultItem/resultItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Button } from "../button";
import { Variant } from "../button/types";
import style from "./index.module.css";
import { interMedium } from "@/app/fonts";
import ModalInfo from "@/components/molecules/modals/modalInfo/modalInfo";
import { useState } from "react";
import { mockData } from "./response.mock";
import { ModalInfo } from "@/components/molecules/modals/modalInfo";
import { ModalPurchase } from "@/components/molecules/modals/modalPurchase";

const ResultItem = ({
statusName,
Expand Down Expand Up @@ -44,7 +45,15 @@ const ResultItem = ({
variant={Variant.blue}
onClick={handleInfo}
/>
<ModalInfo open={open} onClose={() => setOpen(false)} data={mockData} />
{isReserved ? (
<ModalInfo open={open} onClose={() => setOpen(false)} data={mockData} />
) : (
<ModalPurchase
open={open}
onClose={() => setOpen(false)}
name={name}
/>
)}
</div>
);
};
Expand Down
1 change: 1 addition & 0 deletions ui/components/molecules/modals/modalInfo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ModalInfo } from "./modalInfo";
79 changes: 79 additions & 0 deletions ui/components/molecules/modals/modalPurchase/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.wrapper {
border-radius: 12px;
background: var(--col--light);
padding: 24px 24px 34px 24px;
width: 654px;
display: flex;
flex-direction: column;
align-items: center;
}

.header {
font-size: 28px;
}

.header span {
color: #9c9ea6;
}

.periodWrapper {
border-radius: 35px;
border: 1px solid rgba(0, 0, 0, 0.4);
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
margin: 22px 0;
width: 100%;
}

.periodWrapper > div {
color: #88d6a9;
font-size: 28px;
font-weight: 500;
}

.minus,
.plus {
display: flex;
width: 50px;
height: 50px;
justify-content: center;
align-items: center;
border-radius: 50%;
border: 1px solid #597fff;
font-size: 20px;
color: #597fff;
cursor: pointer;
}

.disableActionIcon {
cursor: default;
border-color: var(--col--border);
color: rgba(0, 0, 0, 0.3);
}

.costInformation {
display: flex;
flex-direction: column;
width: 100%;
padding: 16px 12px;
gap: 8px;
border-radius: 9px;
background: #f7f8fa;
margin-bottom: 32px;
}

.costInformation > div {
display: flex;
justify-content: space-between;
color: rgba(0, 0, 0, 0.6);
}

.totalText {
color: rgba(0, 0, 0, 0.6);
}

.costInformation > div span:last-child {
color: var(--col--dark)
}
1 change: 1 addition & 0 deletions ui/components/molecules/modals/modalPurchase/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ModalPurchase } from "./modalPurchase";
88 changes: 88 additions & 0 deletions ui/components/molecules/modals/modalPurchase/modalPurchase.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import classNames from "classnames";
import PopupOverlay from "../../popupOverlay";

import style from "./index.module.css";
import { interBold, interMedium, interSemiBold } from "@/app/fonts";
import { Button } from "@/components/atoms/button";
import { Variant } from "@/components/atoms/button/types";
import { useState } from "react";

type ModalPurchaseProps = {
name: string;
open: boolean;
onClose: () => void;
};

const ModalPurchase = ({
open,
onClose,
name,
}: ModalPurchaseProps): JSX.Element => {
const [selectedPeriod, setSelectedPeriod] = useState<number>(1);
const maxPeriod = 3;
const minPeriod = 1;

const increment = (): void => {
if (selectedPeriod === maxPeriod) return;
setSelectedPeriod(selectedPeriod + 1);
};

const decrement = (): void => {
if (selectedPeriod === minPeriod) return;
setSelectedPeriod(selectedPeriod - 1);
};
return (
<PopupOverlay
position="center"
animation="appear"
onClose={onClose}
show={open}
>
<div className={style.wrapper}>
<div className={classNames(style.header, interMedium.className)}>
{name}<span>.mina</span>
</div>
<div
className={classNames(style.periodWrapper, interSemiBold.className)}
>
<span
className={classNames(style.minus, {
[style.disableActionIcon]: selectedPeriod === minPeriod,
})}
onClick={decrement}
>
-
</span>
<div className={interMedium.className}>{selectedPeriod} year</div>
<span
className={classNames(style.plus, {
[style.disableActionIcon]: selectedPeriod === maxPeriod,
})}
onClick={increment}
>
+
</span>
</div>
<div
className={classNames(style.costInformation, interMedium.className)}
>
<div>
<span>1 year registration</span>
<span className={interSemiBold.className}>10 MINA</span>
</div>
<div>
<span>Est. network fee</span>
<span className={interSemiBold.className}>0.00000312 MINA</span>
</div>
<div>
<span className={classNames(style.totalText, interBold.className)}>Estimated Total</span>
<span className={interSemiBold.className}>10.00000312 MINA</span>
</div>
</div>
<Button text="Purchase" variant={Variant.blue} disabled />
</div>
</PopupOverlay>
);
};

export default ModalPurchase;

0 comments on commit 977556b

Please sign in to comment.