feat : add progressSpace Components and add in ListConfig
This commit is contained in:
33
src/components/progressSpace/index.tsx
Normal file
33
src/components/progressSpace/index.tsx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { motion } from "framer-motion";
|
||||||
|
import { ProgressSpaceProps } from "../../types/props";
|
||||||
|
|
||||||
|
const ProgressSpace = ({ startSpace, endSpace }: ProgressSpaceProps) => {
|
||||||
|
let startSpacePercentage;
|
||||||
|
if (typeof endSpace === "number") {
|
||||||
|
startSpacePercentage = (startSpace / endSpace) * 100;
|
||||||
|
}
|
||||||
|
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">
|
||||||
|
<span>حجم </span>
|
||||||
|
<span>{startSpace}</span>
|
||||||
|
<span>GB</span>
|
||||||
|
</div>
|
||||||
|
<div className="w-full rounded-full h-2.5 bg-gray-700">
|
||||||
|
<motion.div
|
||||||
|
className="bg-blue-600 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>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProgressSpace;
|
||||||
@@ -3,9 +3,16 @@ import Button from "../../../../components/button";
|
|||||||
import { ConfigItemProps } from "../../../../types/props";
|
import { ConfigItemProps } from "../../../../types/props";
|
||||||
import ModalConfigDetails from "./ModalConfigDetails";
|
import ModalConfigDetails from "./ModalConfigDetails";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import Dropdown, { DropdownItem } from "../../../../components/dropdown";
|
||||||
|
import ProgressSpace from "../../../../components/progressSpace";
|
||||||
|
|
||||||
const ConfigItem = ({ dateBuy, configName, isDisabled }: ConfigItemProps) => {
|
const ConfigItem = ({ dateBuy, configName, isDisabled }: ConfigItemProps) => {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
const [isOpenDropDown, setIsOpenDropDown] = useState(false);
|
||||||
|
const handleToggle = () => {
|
||||||
|
setIsOpenDropDown(!isOpen);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ModalConfigDetails
|
<ModalConfigDetails
|
||||||
@@ -40,12 +47,27 @@ const ConfigItem = ({ dateBuy, configName, isDisabled }: ConfigItemProps) => {
|
|||||||
{configName}
|
{configName}
|
||||||
</li>
|
</li>
|
||||||
<div className="max-md:hidden flex flex-row-reverse gap-2 justify-end items-center">
|
<div className="max-md:hidden flex flex-row-reverse gap-2 justify-end items-center">
|
||||||
<Button extra="!m-0 !px-2 !py-1.5 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">
|
||||||
|
کپی
|
||||||
<IoCopy />
|
<IoCopy />
|
||||||
</Button>
|
</Button>
|
||||||
<Button extra="!m-0 !px-2 !py-1 shadow-md shadow-white">
|
<Button extra="!m-0 !px-2 !py-1.5 shadow-md shadow-white">
|
||||||
آموزش
|
آموزش
|
||||||
</Button>
|
</Button>
|
||||||
|
<Dropdown isOpen={isOpenDropDown} setIsOpen={setIsOpenDropDown}>
|
||||||
|
<Button
|
||||||
|
id="dropdownDefaultButton"
|
||||||
|
data-dropdown-toggle="dropdown"
|
||||||
|
type="button"
|
||||||
|
onClick={handleToggle}
|
||||||
|
extra="!m-0 !px-2 !py-1.5 shadow-md shadow-white"
|
||||||
|
>
|
||||||
|
حجم
|
||||||
|
</Button>
|
||||||
|
<DropdownItem widthTailwind="w-[20rem] left-0">
|
||||||
|
<ProgressSpace startSpace={100} endSpace={200} />
|
||||||
|
</DropdownItem>
|
||||||
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
<div className="md:hidden flex flex-row-reverse gap-2 justify-end items-center">
|
<div className="md:hidden flex flex-row-reverse gap-2 justify-end items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import MuiModal from "../../../../common/modal";
|
|||||||
import Button from "../../../../components/button";
|
import Button from "../../../../components/button";
|
||||||
import { IoCopy } from "react-icons/io5";
|
import { IoCopy } from "react-icons/io5";
|
||||||
import Alert from "../../../../components/alert/Alert";
|
import Alert from "../../../../components/alert/Alert";
|
||||||
|
import ProgressSpace from "../../../../components/progressSpace";
|
||||||
|
|
||||||
const ModalConfigDetails = ({
|
const ModalConfigDetails = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
@@ -36,15 +37,21 @@ const ModalConfigDetails = ({
|
|||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Button extra="!m-0 !px-2 !py-1.5 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">
|
||||||
|
کپی
|
||||||
<IoCopy />
|
<IoCopy />
|
||||||
</Button>
|
</Button>
|
||||||
<Button extra="!m-0 !px-2 !py-1 shadow-md shadow-white">
|
<Button extra="!m-0 !px-2 !py-1.5 shadow-md shadow-white">
|
||||||
آموزش
|
آموزش
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{!isDisabled && (
|
||||||
|
<div className="w-full h-full">
|
||||||
|
<ProgressSpace startSpace={100} endSpace={200} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</MuiModal>
|
</MuiModal>
|
||||||
);
|
);
|
||||||
|
|||||||
29
src/types/props.d.ts
vendored
29
src/types/props.d.ts
vendored
@@ -8,9 +8,8 @@ export interface AlertProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// begin Button.tsx
|
// begin Button.tsx
|
||||||
export interface ButtonProps {
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
onClick?: () => void;
|
|
||||||
extra?: string;
|
extra?: string;
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
}
|
}
|
||||||
@@ -50,7 +49,14 @@ export interface NavData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// begin ListTutorial.tsx
|
// begin ListTutorial.tsx
|
||||||
import React, { Component, InputHTMLAttributes, SetStateAction } from "react";
|
import React, {
|
||||||
|
ButtonHTMLAttributes,
|
||||||
|
Component,
|
||||||
|
Dispatch,
|
||||||
|
InputHTMLAttributes,
|
||||||
|
ReactNode,
|
||||||
|
SetStateAction,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
export type TutorialList = { id: number; name: string }[];
|
export type TutorialList = { id: number; name: string }[];
|
||||||
|
|
||||||
@@ -112,3 +118,20 @@ export interface ConfigItemProps {
|
|||||||
isDisabled: boolean;
|
isDisabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// نوع Item برای آیتمهای داخل Dropdown
|
||||||
|
export interface DropdownItem {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
onClick: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DropdownProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
||||||
|
children: ReactNode | ReactNode[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProgressSpaceProps {
|
||||||
|
startSpace: number;
|
||||||
|
endSpace: number | "ultimate";
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user