Skip to content

Commit

Permalink
Merge pull request #99 from SashenJayathilaka/myNewBranchtt
Browse files Browse the repository at this point in the history
⚙️ Release AGRG v1.2.0 (#99)
  • Loading branch information
SashenJayathilaka authored Jun 14, 2023
2 parents f6958f5 + c26d1b4 commit 15b2eda
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 8 deletions.
4 changes: 4 additions & 0 deletions components/BodyContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ import ActionLode from "./ActionLode";
import ButtonActions from "./ButtonActions";
import ConfettiSection from "./ConfettiSection";
import SmallHeader from "./Contents/SmallHeader";
import DividerLine from "./DividerLine";
import FeedBackForm from "./FeedBackForm";
import FormContainer from "./FormContainer";
import Markdown from "./markdown/Markdown";
import MarkdownPreview from "./markdown/MarkdownPreview";
import ConfigOptions from "./process/ConfigOptions";

type Props = {};

Expand Down Expand Up @@ -194,6 +196,8 @@ function BodyContent({}: Props) {
<AiOutlineDownload size={25} />
</button>
</div>
<DividerLine />
<ConfigOptions />
</>
)}
</>
Expand Down
10 changes: 6 additions & 4 deletions components/Contents/Contact.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
"use client";

import { gitHubDetails } from "@/atom/gitHubDetails";
Expand All @@ -11,12 +12,13 @@ import InputField from "../InputField";
type Props = {};

function Contact({}: Props) {
const [details, setDetails] = useRecoilState(gitHubDetails);

const [contactValues, setContactsValue] = useState({
name: "",
twitter: "",
email: "",
name: details.name,
twitter: details.twitter,
email: details.email,
});
const [details, setDetails] = useRecoilState(gitHubDetails);

const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setContactsValue((prev) => ({
Expand Down
5 changes: 3 additions & 2 deletions components/Contents/Contributing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function Contributing({}: Props) {

useEffect(() => {
updateState();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contributingValue]);

return (
Expand All @@ -57,7 +58,7 @@ function Contributing({}: Props) {
<Heading label="Contributing" icon={MdWavingHand} />
<div className="flex justify-start gap-20 items-center">
<div>
<p className="text-lg font-medium text-gray-300">
<p className="text-lg font-medium dark:text-gray-300 text-gray-600">
If you want add Contributions section
</p>
</div>
Expand Down Expand Up @@ -93,7 +94,7 @@ function Contributing({}: Props) {
<Heading label="Code of Conduct" icon={HiClipboardDocumentList} />
<div className="flex justify-start gap-20 items-center">
<div>
<p className="text-lg font-medium text-gray-300">
<p className="text-lg font-medium dark:text-gray-300 text-gray-600">
If you want add Code of Conduct section
</p>
</div>
Expand Down
107 changes: 106 additions & 1 deletion components/process/ConfigOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,114 @@
"use client";

import { gitBadge } from "@/atom/displayBadges";
import { gitHubDetails } from "@/atom/gitHubDetails";
import { gitImages } from "@/atom/images";
import { readmeRows } from "@/atom/readmeRow";
import { gitImagesSizes } from "@/atom/size";
import { gitTechStack } from "@/atom/techStack";
import updateCurrentStateValue from "@/hook/updateCurrentStateValue";
import { JsonDataType } from "@/type";
import { FormEvent, useCallback, useState } from "react";
import { toast } from "react-toastify";
import { useRecoilState } from "recoil";
import Options from "./components/Options";

type Props = {};

function ConfigOptions({}: Props) {
return <div>ConfigOptions</div>;
const [files, setFiles] = useState<JsonDataType | null>(null);
const [fileName, setFileName] = useState("");
const [isLoading, setIsLoading] = useState(false);

const [gitHubDetail, setGitHubDetail] = useRecoilState(gitHubDetails);
const [readmeRow, setIsReadmeRow] = useRecoilState(readmeRows);
const [gitHubTechStack, setGitHubTechStack] = useRecoilState(gitTechStack);
const [images, setImages] = useRecoilState(gitImages);
const [size, setSize] = useRecoilState(gitImagesSizes);
const [displayBadges, setDisplayBadges] = useRecoilState(gitBadge);

const {
updateFirstElement,
updateSecondElement,
updateThirdElement,
updateFourthElement,
updateFifthElement,
updateSixthElement,
} = updateCurrentStateValue();

const handleChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
const fileReader = new FileReader();

const fileType = event.target.files && event.target.files[0];

if (!fileType) return;

if (fileType.type === "application/json") {
setFileName(fileType.name);
fileReader.readAsText(fileType, "UTF-8");
fileReader.onload = (event) => {
const jasonData = JSON.parse(event.target?.result as string);
setFiles(jasonData);
};
} else {
toast.error("This File Type Not Supported");
setFileName(fileType.name);
}
},
[]
);

const handleProcess = useCallback(
(e: FormEvent) => {
e.preventDefault();

if (!files) return;

setIsLoading(true);

updateFirstElement(files.gitHubTechStack, setGitHubTechStack);
updateSecondElement(files.gitHubDetail, setGitHubDetail);
updateThirdElement(files.readmeRow, setIsReadmeRow);
updateFourthElement(files.images, setImages);
updateFifthElement(files.size, setSize);
updateSixthElement(files.displayBadges, setDisplayBadges);

setTimeout(() => {
setIsLoading(false);
toast.success("JSON Text Restore Successfully");
}, 1000);
},
[
files,
setDisplayBadges,
setGitHubDetail,
setGitHubTechStack,
setImages,
setIsReadmeRow,
setSize,
updateFifthElement,
updateFirstElement,
updateFourthElement,
updateSecondElement,
updateSixthElement,
updateThirdElement,
]
);

return (
<div className="w-full pt-12">
<Options
files={files}
fileName={fileName}
isLoading={isLoading}
setFiles={setFiles}
setFileName={setFileName}
handleProcess={handleProcess}
handleChange={handleChange}
/>
</div>
);
}

export default ConfigOptions;
135 changes: 135 additions & 0 deletions components/process/components/Options.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/* eslint-disable @next/next/no-img-element */
"use client";

import { JsonDataType } from "@/type";
import { motion } from "framer-motion";
import { FormEvent } from "react";
import { AiOutlineLoading3Quarters } from "react-icons/ai";

type Props = {
files: JsonDataType | null;
fileName: string;
isLoading: boolean;
setFiles: (value: JsonDataType | null) => void;
setFileName: (value: string) => void;
handleProcess: (event: FormEvent) => void;
handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
};

function Options({
files,
fileName,
isLoading,
setFiles,
setFileName,
handleProcess,
handleChange,
}: Props) {
return (
<div className="w-full p-10 bg-gradient-to-r from-gray-100 via-gray-200 to-gray-100 dark:bg-gradient-to-r dark:from-[#191a47] dark:via-[#0d0d37] dark:to-[#06375f] rounded-xl z-10">
<div className="text-center">
<h2 className="mt-5 text-3xl font-bold text-gray-900 dark:text-gray-100">
Config options
</h2>
<p className="mt-2 text-sm text-gray-400">
Enter the downloaded JSON text to restore
</p>
</div>
<form className="mt-8 space-y-3" action="#" method="POST">
<div className="grid grid-cols-1 space-y-2">
<label className="text-sm font-bold text-gray-500 tracking-wide">
Attach Json Document
</label>
<div className="flex items-center justify-center w-full">
{files || fileName ? (
<div className="flex flex-col rounded-lg border-4 border-dashed w-full h-60 p-10 group text-center cursor-pointer overflow-hidden items-center">
<div
onClick={() => {
setFiles(null);
setFileName("");
}}
>
{fileName.includes("json") ? (
<motion.img
initial={{ opacity: 0, scale: 0.5 }}
animate={{ opacity: 1, scale: 1 }}
transition={{
duration: 0.8,
delay: 0.5,
ease: [0, 0.71, 0.2, 1.01],
}}
src="https://cdn2.iconfinder.com/data/icons/document-file-fill-outline-1/64/File_Document_Doc_Folder_JSON-512.png"
alt="img"
className="w-36 items-center"
/>
) : (
<motion.img
initial={{ opacity: 0, scale: 0.5 }}
animate={{ opacity: 1, scale: 1 }}
transition={{
duration: 0.8,
delay: 0.5,
ease: [0, 0.71, 0.2, 1.01],
}}
src="https://cdn3.iconfinder.com/data/icons/file-management/32/5_forbidden_ban_no_file_document-512.png"
alt="img"
className="w-36 items-center"
/>
)}
<p>{fileName}</p>
</div>
</div>
) : (
<label className="flex flex-col rounded-lg border-4 border-dashed dark:border-gray-500 border-gray-300 w-full h-60 p-10 group text-center cursor-pointer">
<motion.div
initial={{ opacity: 0, scale: 0.5 }}
animate={{ opacity: 1, scale: 1 }}
transition={{
duration: 0.8,
delay: 0.5,
ease: [0, 0.71, 0.2, 1.01],
}}
className="h-full w-full text-center flex flex-col justify-center items-center"
>
<div className="flex flex-auto max-h-48 w-2/5 -mt-10 justify-center">
<img
className="has-mask h-36 object-center"
src="https://cosmoindia.in/wp-content/uploads/2020/08/businessgrowth.png"
alt="freepik image"
/>
</div>
<p className="pointer-none text-gray-500 ">
<span className="text-sm">Drag and drop</span> files here{" "}
<br /> or{" "}
<span id="" className="text-blue-600 hover:underline">
select a file
</span>{" "}
from your computer
</p>
</motion.div>
<input type="file" className="hidden" onChange={handleChange} />
</label>
)}
</div>
</div>
<p className="text-sm text-gray-700 dark:text-gray-300">
<span>File type: json</span>
</p>
<div>
<button
onClick={handleProcess}
className="my-5 w-full flex justify-center bg-blue-500 text-gray-100 p-4 rounded-full tracking-wide font-semibold focus:outline-none focus:shadow-outline hover:bg-blue-600 cursor-pointer transition ease-in duration-300"
>
{isLoading ? (
<AiOutlineLoading3Quarters size={25} className="animate-spin" />
) : (
"Process"
)}
</button>
</div>
</form>
</div>
);
}

export default Options;
3 changes: 2 additions & 1 deletion components/profile/process/components/Options.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @next/next/no-img-element */
"use client";

import { ProfileAtomDetails } from "@/type";
import { JsonDataType, ProfileAtomDetails } from "@/type";
import { motion } from "framer-motion";
import { FormEvent } from "react";
import { AiOutlineLoading3Quarters } from "react-icons/ai";
Expand Down
9 changes: 9 additions & 0 deletions type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ export interface ProfileAtomDetails {
endWelcomeSection: boolean;
}

export interface JsonDataType {
gitHubDetail: GitHubDetail;
gitHubTechStack: GitHubTechStack;
readmeRow: ReadmeRow;
images: GitHubImages;
size: GitHubImagesSize;
displayBadges: GitBadges;
}

/* export interface GitHubRepoDetails {
websiteUpDown: string;
websiteLink: string;
Expand Down

1 comment on commit 15b2eda

@vercel
Copy link

@vercel vercel bot commented on 15b2eda Jun 14, 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.