feat : update btn and modal for better ui

This commit is contained in:
alij
2024-06-09 22:48:22 -07:00
parent 0c28e72536
commit 114440f48c
6 changed files with 46 additions and 33 deletions

View File

@@ -54,9 +54,11 @@ export default function MuiModal({
<motion.div className="w-full h-full flex flex-col justify-between text-center items-center"> <motion.div className="w-full h-full flex flex-col justify-between text-center items-center">
{children} {children}
</motion.div> </motion.div>
<motion.div className="w-full h-full flex justify-end items-center gap-2 md:gap-3 text-lg md:text-xl"> <motion.div className={`w-full h-full flex ${submitText ? 'justify-end' : 'justify-center' } items-center gap-2 md:gap-3 text-lg md:text-xl`}>
<Button onClick={() => handleClose()}> بستن </Button> <Button onClick={() => handleClose()}> بستن </Button>
<Button onClick={submitOnClick}> {submitText} </Button> {submitText && (
<Button onClick={submitOnClick}> {submitText} </Button>
)}
</motion.div> </motion.div>
</motion.div> </motion.div>
</Modal> </Modal>

View File

@@ -3,9 +3,9 @@ import { ButtonProps } from "../../types/props";
function Button({ children, extra, active,...attrs }: ButtonProps) { function Button({ children, extra, active,...attrs }: ButtonProps) {
return ( return (
<button <button
className={`px-4 py-1 md:px-5 md:py-2 rounded-md transition duration-300 ease-in-out transform bg-white text-[#333] hover:bg-gray-600 hover:text-white ${ className={`px-4 py-1 md:px-5 md:py-2 rounded-md transition duration-300 ease-in-out transform bg-white text-[#333] hover:bg-gray-600 hover:text-white shadow-lg hover:!shadow-gray-600 ${
active active
? "!bg-secondTheme shadow-secondTheme hover:shadow-gray-600 shadow-lg" ? "!bg-secondTheme shadow-secondTheme shadow-lg hover:!shadow-gray-600"
: "" : ""
} ${extra}`} } ${extra}`}
type="button" type="button"

View File

@@ -3,30 +3,40 @@ import { ProgressSpaceProps } from "../../types/props";
const ProgressSpace = ({ startSpace, endSpace }: ProgressSpaceProps) => { const ProgressSpace = ({ startSpace, endSpace }: ProgressSpaceProps) => {
let startSpacePercentage; let startSpacePercentage;
let remaining;
if (typeof endSpace === "number") { if (typeof endSpace === "number") {
startSpacePercentage = (startSpace / endSpace) * 100; startSpacePercentage = (startSpace / endSpace) * 100;
remaining = endSpace - startSpace;
} }
return ( return (
<div className="relative w-full h-full p-3 bg-gray-800 rounded-md flex gap-2 justify-center items-center"> <>
<div className="flex gap-1"> <div className="relative w-full h-full p-3 bg-gray-800 rounded-md flex gap-2 justify-center items-center">
<span>حجم </span> <div className="flex gap-1">
<span>{startSpace}</span> <span>حجم </span>
<span>GB</span> <span>GB</span>
<span>{startSpace}</span>
</div>
<div className="w-full rounded-full h-2 md:h-2.5 bg-gray-700">
<motion.div
className="bg-secondTheme h-2 md:h-2.5 rounded-full"
animate={{ width: `${startSpacePercentage}%` }}
initial={{ width: 0 }}
transition={{ type: "tween", duration: 1 }}
style={{ transformOrigin: "right" }}
></motion.div>
</div>
<div className="flex flex-row-reverse gap-1">
<span> {endSpace}</span>
<span>GB</span>
</div>
</div> </div>
<div className="w-full rounded-full h-2.5 bg-gray-700"> <div className="w-full h-full mt-1 p-2 text-center text-xs md:text-base">
<motion.div <p>
className="bg-blue-600 h-2.5 rounded-full" {" "}
animate={{ width: `${startSpacePercentage}%` }} حجم باقیمانده کانفیگ شما از {endSpace} گیگ <span className="mx-1 border-b border-secondTheme">{remaining}</span>گیگ میباشد{" "}
initial={{ width: 0 }} </p>
transition={{ type: "tween", duration: 1 }}
style={{ transformOrigin: "right" }}
></motion.div>
</div> </div>
<div className="flex flex-row-reverse gap-1"> </>
<span> {endSpace}</span>
<span>GB</span>
</div>
</div>
); );
}; };

View File

@@ -25,16 +25,16 @@ const ConfigItem = ({ dateBuy, configName, isDisabled }: ConfigItemProps) => {
<div className="relative w-full h-full rounded-md"> <div className="relative w-full h-full rounded-md">
{isDisabled && ( {isDisabled && (
<div className="absolute inset-0 flex items-center justify-center bg-opacity-50 rounded-md backdrop-blur-sm z-10"> <div className="absolute inset-0 flex items-center justify-center bg-opacity-50 rounded-md backdrop-blur-sm z-10">
<p className="text-white font-bold px-1 bg-red-600 text-xs md:text-base rounded-md shadow-md shadow-red-600"> <div className="text-white font-bold p-1 bg-red-600 text-xs md:text-base rounded-md shadow-md shadow-red-600">
کانفیگ <span className="text-secondTheme">{configName}</span> غیر کانفیگ <span className="text-secondTheme">{configName}</span> غیر
فعال است .{" "} فعال است .{" "}
<span <Button
className="text-secondTheme cursor-pointer" extra="cursor-pointer !px-1 !py-0 rounded-md bg-white"
onClick={() => setIsOpen(true)} onClick={() => setIsOpen(true)}
> >
تمدید برای تمدید کلیک کنید
</span> </Button>
</p> </div>
</div> </div>
)} )}
<div <div

View File

@@ -22,7 +22,6 @@ const ModalConfigDetails = ({
<MuiModal <MuiModal
isOpenModal={isOpen} isOpenModal={isOpen}
setIsOpenModal={setIsOpen} setIsOpenModal={setIsOpen}
submitText="باشه"
nameService={nameConfig} nameService={nameConfig}
> >
{isDisabled && <Alert type="warning"> {nameConfig} غیر فعال است </Alert>} {isDisabled && <Alert type="warning"> {nameConfig} غیر فعال است </Alert>}
@@ -32,9 +31,11 @@ const ModalConfigDetails = ({
</h1> </h1>
<div className="w-full h-full flex flex-row-reverse gap-2 justify-center items-center"> <div className="w-full h-full flex flex-row-reverse gap-2 justify-center items-center">
{isDisabled ? ( {isDisabled ? (
<Button extra="!m-0 !px-2 !py-1 shadow-md shadow-secondTheme !bg-secondTheme "> <div className="w-full h-full grid grid-cols-1 justify-center items-center">
تمدید <Button extra="!m-0 !px-2 !py-1 shadow-md shadow-secondTheme !bg-secondTheme font-bold hover:!bg-gray-800 hover:!shadow-gray-800 ">
</Button> تمدید
</Button>
</div>
) : ( ) : (
<> <>
<Button extra="!m-0 !px-2 !py-1.5 flex flex-row-reverse justify-center items-center gap-1 shadow-md shadow-white"> <Button extra="!m-0 !px-2 !py-1.5 flex flex-row-reverse justify-center items-center gap-1 shadow-md shadow-white">

View File

@@ -107,7 +107,7 @@ export interface MuiModalProps {
setIsOpenModal: SetStateAction; setIsOpenModal: SetStateAction;
title?: string; title?: string;
nameService?: string; nameService?: string;
submitText: string; submitText?: string;
submitOnClick?: () => void; submitOnClick?: () => void;
children: React.ReactNode; children: React.ReactNode;
} }