-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: make drawer component #189
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b04bf79
created Drawer component
fvcci 5cc521d
decoupled Drawer out of welcome page
fvcci 4394d34
decoupled Drawer out of dashboard, grade, me, and scanner pages
fvcci 4c1d275
change ApplicationTable button text from View Application to View
fvcci 96319de
remove unused files
fvcci b6286bd
cleaning up file dependencies
fvcci 9273b0d
removed navigation file
fvcci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import ThemeToggle from "./ThemeToggle"; | ||
import { signOut, useSession } from "next-auth/react"; | ||
import Background from "./Background"; | ||
import { useRef } from "react"; | ||
import { useRouter } from "next/router"; | ||
import NavBar from "./NavBar"; | ||
import Link from "next/link"; | ||
|
||
interface PageTab { | ||
pageName: string; | ||
link: string; | ||
} | ||
|
||
export const Drawer = ({ | ||
children, | ||
pageTabs, | ||
}: { | ||
children: JSX.Element[] | JSX.Element; | ||
pageTabs?: PageTab[]; | ||
}) => { | ||
const { data: session } = useSession(); | ||
const router = useRouter(); | ||
|
||
const drawer = useRef<HTMLInputElement>(null); | ||
|
||
return ( | ||
<> | ||
<Background /> | ||
<div className="drawer drawer-end relative h-full min-h-screen w-full overflow-x-hidden font-montserrat"> | ||
<input | ||
id="my-drawer-3" | ||
type="checkbox" | ||
className="drawer-toggle" | ||
ref={drawer} | ||
/> | ||
|
||
<div className="drawer-content flex flex-col"> | ||
<NavBar /> | ||
{children} | ||
</div> | ||
|
||
<div className="drawer-side md:hidden z-50 "> | ||
<label | ||
htmlFor="my-drawer-3" | ||
className="drawer-overlay md:hidden" | ||
></label> | ||
|
||
<div className="menu h-full w-80 flex-row content-between overflow-y-auto bg-white p-4 dark:bg-[#1F1F1F] md:hidden"> | ||
<ul className="w-full"> | ||
<button | ||
className="btn btn-square btn-ghost drawer-button" | ||
onClick={() => { | ||
if (drawer.current) { | ||
drawer.current.checked = false; | ||
} | ||
}} | ||
> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
> | ||
<path | ||
fill="currentColor" | ||
fillRule="evenodd" | ||
d="m6.5 17.5l8.25-5.5L6.5 6.5l1-1.5L18 12L7.5 19z" | ||
/> | ||
</svg> | ||
</button> | ||
{pageTabs?.map(({ pageName, link }, i) => ( | ||
<li key={i}> | ||
<Link className="mx-2 my-2 text-base font-bold" href={link}> | ||
{pageName} | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
|
||
<div className="mx-1 mb-2 flex w-full items-center justify-between "> | ||
<ThemeToggle /> | ||
{session ? ( | ||
<div> | ||
<a className="font-sub mx-2.5 text-sm"> | ||
Hi,{" "} | ||
<strong className="font-bold">{session?.user?.name}</strong> | ||
</a> | ||
<button | ||
onClick={() => signOut()} | ||
className="font-sub rounded bg-primary px-2.5 py-2.5 text-sm font-bold text-white dark:text-gray-300" | ||
> | ||
Sign Out | ||
</button> | ||
</div> | ||
) : ( | ||
<button | ||
className="btn btn-primary text-white" | ||
onClick={() => router.push("/login")} | ||
> | ||
Sign In | ||
</button> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Drawer; | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well-structured Drawer component with effective use of React features.
The component is well-structured, making good use of React hooks, refs, and conditional rendering. The use of
useSession
for session management anduseRouter
for navigation is appropriate. The ref usage for controlling the drawer's state is a good practice.Suggestion for Improvement:
Consider adding
aria-labels
to interactive elements like buttons for better accessibility.