Skip to content

Commit

Permalink
doc indiv new page added
Browse files Browse the repository at this point in the history
  • Loading branch information
devvsakib committed Jul 27, 2024
1 parent 984aa91 commit 88c5648
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 24 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
"pretty-quick": "^3.1.3",
"tailwindcss": "^3.2.4",
"vite": "^4.0.0"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
19 changes: 13 additions & 6 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import "./index.css";
import Error from "./components/Error/Error";
import SearchInput from "./components/Search/SearchInput";
import Layout from "./components/Layout/Layout";
import BGShape from "./components/BGShape";

function App() {
const [search, setSearch] = useState("");
const [type, setType] = useState("");
const [countStar, setCountStar] = useState(0);

useEffect(() => {
fetch("https://api.github.com/repos/devvsakib/github-error-solve")
.then((response) => response.json())
.then((data) => setCountStar(data.stargazers_count))
.catch((error) => console.error("Error fetching GitHub stars:", error));
}, []);
console.log(countStar)
return (
<>
<Layout>
<SearchInput search={search} setSearch={setSearch} setType={setType} />
<Error search={search} type={type} />
</Layout>
<Layout stars={countStar}>
<SearchInput search={search} setSearch={setSearch} setType={setType} />
<Error search={search} type={type} />
</Layout>
</>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/BGShape.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

const BGShape = () => {
return (
<div className='-z-[99999] fixed top-0 left-0 w-full h-full'>
<div className='-z-[99999] fixed top-0 left-0 w-full h-full opacity-40'>
{/* <div className='-z-[999] absolute top-0 left-0 w-full h-full bg-[#44ff15]/20 backdrop-blur-[5px] rounded-lg'></div>*/}
<div className='-z-[99999999999999] absolute -top-[70%] md:-top-[90%] -left-[50%] md:left-0 w-[800px] md:w-full h-[500px] rounded-full bg-[#16f8d2f3]/30 blur-[100px]'></div>

Expand Down
18 changes: 14 additions & 4 deletions src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { HiMoon, HiSun } from "react-icons/hi";
import { ThemeContext } from "../../context/ThemeContext";
import { useContext, useState } from "react";

function Header({ notice }) {
function Header({ countStar, notice }) {
const { theme, toggleTheme } = useContext(ThemeContext);
const [open, setOpen] = useState(false);

Expand Down Expand Up @@ -78,8 +78,19 @@ function Header({ notice }) {
return (
<div key={`${link.name}-${index}`}>
{link?.isExternalURL ? (
<a target="_blank" href={link.link} className="githubBtn">
{link.icon}
<a target="_blank" href={link.link}>
<div className="bg-blue-600/50 shadow font-semibold flex gap-1 p-1 px-2 items-center rounded-full">
<span className="githubBtn">
{link.icon}
</span>
{
countStar && (
<div className="flex items-center gap-1">
{countStar}
</div>
)
}
</div>
</a>
) : (
<Link className="flex items-center gap-1" to={link.link}>
Expand All @@ -90,7 +101,6 @@ function Header({ notice }) {
</div>
);
})}

<div className="text-lg cursor-pointer" onClick={toggleTheme}>
<HiMoon className="dark:hidden" />
<HiSun className="hidden dark:inline" />
Expand Down
23 changes: 13 additions & 10 deletions src/components/Layout/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ import { ThemeProvider } from '../../context/ThemeContext';
* prop
* @returns A div with a header and children.
*/
const Layout = ({children}) => {
const Layout = ({ stars, children }) => {
return (
<ThemeProvider>
<Header
notice={"Under Construction"}
/>
<div className='relative'>
{children}
</div>
<Footer />
</ThemeProvider>
<div className='flex flex-col justify-between min-h-screen'>
<ThemeProvider>
<Header
countStar={stars}
notice={"Under Construction"}
/>
<div className='relative'>
{children}
</div>
<Footer />
</ThemeProvider>
</div>
);
};

Expand Down
38 changes: 36 additions & 2 deletions src/pages/single doc/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
import { useParams } from "react-router-dom";
import Layout from "../../components/Layout/Layout";
import { docs } from '../../data/Doc.json';
import { useEffect, useState } from "react";

const SingleDoc = () => {
const { doc_name } = useParams();
const [doc, setDoc] = useState({});
const [loading, setLoading] = useState(true);

useEffect(() => {
setLoading(true);
const doc = docs.find(item => item.title.toLowerCase() === doc_name.split("_").join(" "));
setDoc(doc);
setTimeout(() => {
setLoading(false);
}, 300);
}, [doc_name]);

return (
<Layout>
<section className="px-5 md:px-10">
{doc_name.split("_").join(" ")}
<section className="px-5 md:px-10 min-h-screen">
<h3 className="text-2xl md:text-3xl capitalize text-center my-10 mb-20">
{doc_name.split("_").join(" ")}
</h3>
{
loading ? <p>Loading...</p>
:
<div className="">
<div>
<div className="">
{
doc.tag.map((tag, index) => (
<span key={index} className="bg-primary text-white px-2 py-1 rounded-lg mr-2">
{tag}
</span>
))
}
</div>
<hr className="my-5" />
</div>
<p className="text-justify">{doc.description}</p>
</div>
}
</section>
</Layout>
);
Expand Down

0 comments on commit 88c5648

Please sign in to comment.