-
Notifications
You must be signed in to change notification settings - Fork 0
Add Course Details Drawer #126
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6f38521
add vaul
mirmirmirr c09766b
initial drawer implementation
mirmirmirr c218d00
extract filter fetching into a store
mirmirmirr bf115a1
add tags to course details
mirmirmirr df465fd
filter/tag file reorganization
mirmirmirr add43d7
fix recusion depth problem
mirmirmirr ef9fe8f
Merge pull request #121 from Project-CARPI/main-preview
mirmirmirr f006960
Merge pull request #123 from Project-CARPI/main-preview
mirmirmirr 4306f28
drawer clean up
mirmirmirr 70b145b
change border color
mirmirmirr 28d26a9
Merge branch 'main' into info-drawer
mirmirmirr 9e5bcca
Delete HeaderButton.tsx
mirmirmirr d71dda8
Merge branch 'main-preview' into info-drawer
mirmirmirr 1deeb39
Update ButtonTray.tsx
mirmirmirr de5565f
fix import linting error
mirmirmirr e8b9210
change key format
mirmirmirr 45889ec
fix catalog course merge conflicts
mirmirmirr 6e073cb
fix provider merge conflicts overwrites
mirmirmirr ab03fe0
import react types
mirmirmirr dd78f43
add dedicated filter check
mirmirmirr 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,58 @@ | ||
| import type { ReactNode } from "react"; | ||
|
|
||
| import { cn } from "@/lib/classnames"; | ||
|
|
||
| interface ButtonProps { | ||
| onClick?: () => void; | ||
| children: ReactNode; | ||
| tooltip: string; | ||
| inverted?: boolean; // Optional prop to invert colors | ||
| } | ||
|
|
||
| export default function Button({ | ||
| onClick, | ||
| children, | ||
| tooltip, | ||
| inverted, | ||
| }: ButtonProps) { | ||
| return ( | ||
| <div className="relative group flex flex-col items-center"> | ||
| <button | ||
| onClick={onClick} | ||
| className={cn( | ||
| "p-3 rounded-full w-fit aspect-square flex items-center justify-center hover:cursor-pointer", | ||
| inverted | ||
| ? "bg-carpipink/20 text-carpipink hover:text-darkblue hover:bg-carpipink transition-colors" | ||
| : "bg-darkblue/20 hover:bg-darkblue hover:text-carpipink transition-colors", | ||
| )} | ||
| > | ||
| {children} | ||
| </button> | ||
|
|
||
| {/* Tooltip Container */} | ||
| <div | ||
| className={cn( | ||
| "absolute -bottom-7 z-50 hidden group-hover:flex flex-col items-center ", | ||
| inverted ? " text-darkblue" : " text-carpipink", | ||
| )} | ||
| > | ||
| <div | ||
| className={cn( | ||
| "w-2 h-2 rotate-45", | ||
| inverted ? "bg-carpipink" : "bg-darkblue", | ||
| )} | ||
| /> | ||
| <div | ||
| className={cn( | ||
| "bg-darkblue text-carpipink text-tiny! py-0.5 px-2 -mt-1 rounded-full whitespace-nowrap", | ||
| inverted | ||
| ? "bg-carpipink text-darkblue" | ||
| : "bg-darkblue text-carpipink", | ||
| )} | ||
| > | ||
| {tooltip} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or 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,91 @@ | ||
| import type { CSSProperties } from "react"; | ||
|
|
||
| import { BiX } from "react-icons/bi"; | ||
| import { Drawer } from "vaul"; | ||
|
|
||
| import Button from "@/components/Button"; | ||
| import Tag from "@/components/Tag"; | ||
| import { cn } from "@/lib/classnames"; | ||
| import useIsDesktop from "@/lib/hooks/useIsDesktop"; | ||
| import { useCourseFilters } from "@/lib/stores/useFilterStore"; | ||
| import { UserCourse } from "@/lib/types"; | ||
|
|
||
| interface CourseDetailsDrawerProps { | ||
| open: boolean; | ||
| onOpenChange: (open: boolean) => void; | ||
| course: UserCourse; | ||
| } | ||
|
|
||
| export function CourseDetailsDrawer({ | ||
| open, | ||
| onOpenChange, | ||
| course, | ||
| }: CourseDetailsDrawerProps) { | ||
| const isDesktop = useIsDesktop(); | ||
| const { attrFilters, semFilters } = useCourseFilters(course.data); | ||
|
|
||
| const direction = isDesktop ? "left" : "bottom"; | ||
|
mirmirmirr marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <Drawer.Root direction={direction} open={open} onOpenChange={onOpenChange}> | ||
| <Drawer.Portal> | ||
| <Drawer.Content | ||
| className={cn( | ||
| "md:left-2 md:top-2 bottom-2 fixed z-50", | ||
| "outline-none md:w-[calc(100%-16px)] lg:w-1/3 flex h-2/5 md:h-[calc(100%-16px)]", | ||
| )} | ||
| style={{ "--initial-transform": "calc(100% + 8px)" } as CSSProperties} | ||
| > | ||
| <div | ||
| className={cn( | ||
| " w-full relative grow p-8 flex flex-col rounded-2xl overflow-y-auto shadow-2xl shadow-darkblue", | ||
| "bg-darkblue md:border-[color-mix(in_oklab,var(--color-carpipink)_40%,white_60%)] md:border-2", | ||
| )} | ||
| > | ||
| <div className="flex items-start justify-between"> | ||
| <Drawer.Title | ||
| aria-label={course.name} | ||
| className="flex flex-col mb-2" | ||
| > | ||
| <span className="text-sm font-light text-carpipink"> | ||
| {course.name} | ||
| </span> | ||
| <span className="text-lg font-bold text-carpipink"> | ||
| {course.data.title} | ||
| </span> | ||
| </Drawer.Title> | ||
|
|
||
| <Drawer.Close> | ||
| <Button | ||
| inverted | ||
| tooltip="Close Drawer" | ||
| onClick={() => onOpenChange(false)} | ||
| > | ||
| <BiX className="w-5 h-5" /> | ||
| </Button> | ||
| </Drawer.Close> | ||
| </div> | ||
|
|
||
| <div className="flex flex-wrap gap-2 mb-4"> | ||
| {attrFilters.map((attr) => { | ||
| return <Tag key={`${attr.type}-${attr.code}`} filter={attr} />; | ||
| })} | ||
| {semFilters?.map((semester) => { | ||
| return ( | ||
| <Tag | ||
| key={`${semester.type}-${semester.code}`} | ||
| filter={semester} | ||
| /> | ||
| ); | ||
| })} | ||
| </div> | ||
|
|
||
| <Drawer.Description className="mb-4 text-carpipink"> | ||
| {course.data.desc_text || "No description available."} | ||
| </Drawer.Description> | ||
| </div> | ||
| </Drawer.Content> | ||
| </Drawer.Portal> | ||
| </Drawer.Root> | ||
| ); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.