-
Notifications
You must be signed in to change notification settings - Fork 18
Feature/note detail page #172
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
Open
SXT230118
wants to merge
22
commits into
develop
Choose a base branch
from
feature/note-detail-page
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5520e66
Clicking a note now navigates to /notes/[id] instead of opening the P…
SXT230118 e71ca92
It only kind of matches the Figma, but progress!
SXT230118 f26fc80
Pretty :D
SXT230118 abce9d1
Revert package.json and package-lock.json
SXT230118 bd0824d
Reverting bundler to node
SXT230118 88c7e2d
Added a little bit of padding to make sure the info bar doesn't cove …
SXT230118 26350f9
I haven't reverted back to iFrame yet because of that pdf formatting,…
SXT230118 74792de
Not iFrame, but the notes page should load in FireFox now
SXT230118 0ce4af9
Forgot about pretty formatting
SXT230118 7666cc2
Merge branch 'develop' of https://github.com/UTDNebula/utd-notebook i…
SXT230118 37d8d55
Added the comments back into SaveButton.tsx
SXT230118 ca855f3
Dark mode colors
SXT230118 db28987
Forgot to pretty
SXT230118 975a63f
Switched from css grid for panel on top of note to mui collapse. The …
SXT230118 7b7715a
Author and professor hyperlinked!
SXT230118 14bb133
Restored iframe
SXT230118 6bb5e4f
Fixed save button
SXT230118 f87a0ab
Slight clean-up of divs on NoteInfoPanel
SXT230118 ce3364d
Small fixes, top panel finally works!
SXT230118 d8876a8
Forgot to run prettier
SXT230118 60b0d08
Add 2 buttons and style changes
TyHil 327acc0
Merge branch 'develop' into feature/note-detail-page
TyHil 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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| 'use client'; | ||
|
|
||
| import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; | ||
| import OpenInNewIcon from '@mui/icons-material/OpenInNew'; | ||
| import { Collapse, IconButton, Typography } from '@mui/material'; | ||
| import Link from 'next/link'; // To link back to specific profiles | ||
| import { useState } from 'react'; | ||
| import Panel from '@src/components/common/Panel'; | ||
| import NoteDeleteButton from '@src/components/sections/NoteDeleteButton'; | ||
| import NoteEditButton from '@src/components/sections/NoteEditButton'; | ||
|
TyHil marked this conversation as resolved.
|
||
| import RatingWidget from '@src/components/sections/RatingWidget'; | ||
| import ReportButton from '@src/components/sections/ReportButton'; | ||
| import SaveButton from '@src/components/sections/SaveButton'; | ||
| import type { SelectFileWithUserMetadataAndSection } from '@src/server/db/models'; | ||
| import { authClient } from '@src/utils/auth-client'; | ||
|
|
||
| type NoteInfoPanelProps = { | ||
| file: SelectFileWithUserMetadataAndSection; | ||
| }; | ||
|
|
||
| export default function NoteInfoPanel({ file }: NoteInfoPanelProps) { | ||
| const [expanded, setExpanded] = useState(true); | ||
| const { data: session } = authClient.useSession(); | ||
| const isAuthor = session?.user?.id === file.authorId; | ||
|
|
||
| return ( | ||
| <Panel | ||
| className="w-full py-2 border-l-4 border-royal dark:border-cornflower-300 rounded-t-none gap-0" | ||
| smallPadding | ||
| > | ||
| <div className="flex flex-col"> | ||
| {/* Top piece, always visible, has the name and buttons */} | ||
| <div className="flex flex-wrap items-center gap-2"> | ||
| <div className="flex items-center w-full md:w-auto flex-grow gap-2"> | ||
| <IconButton | ||
| onClick={() => setExpanded((v) => !v)} | ||
| aria-label={ | ||
| expanded ? 'Collapse info panel' : 'Expand info panel' | ||
| } | ||
| size="large" | ||
| > | ||
| <KeyboardArrowUpIcon | ||
| fontSize="inherit" | ||
| className={`transition ${expanded ? 'rotate-180' : 'rotate-90'}`} | ||
| /> | ||
| </IconButton> | ||
| <Typography variant="h2" className="text-xl font-bold"> | ||
| {file.name} | ||
| </Typography> | ||
| </div> | ||
| <div className="w-full md:w-auto flex-shrink-0 flex md:ml-auto justify-end flex-wrap items-center gap-3"> | ||
| <RatingWidget fileId={file.id} /> | ||
| {isAuthor && <NoteEditButton fileId={file.id} />} | ||
| {isAuthor && <NoteDeleteButton fileId={file.id} />} | ||
| {!isAuthor && <ReportButton fileId={file.id} />} | ||
| <SaveButton fileId={file.id} /> | ||
| <IconButton | ||
| LinkComponent={Link} | ||
| href={file.publicUrl} | ||
| target="_blank" | ||
| size="small" | ||
| > | ||
| <OpenInNewIcon fontSize="small" /> | ||
| </IconButton> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Bottom piece, collapsible, has author, professor, description, and last modified date */} | ||
| <Collapse in={expanded}> | ||
| <div className="pb-2 px-3 flex flex-col gap-1"> | ||
| <p className="text-sm font-medium text-slate-800 dark:text-slate-200"> | ||
| By{' '} | ||
| { | ||
| file.author.username ? ( | ||
| <Link | ||
| href={`/profile/${file.author.username}`} | ||
| className="underline hover:text-slate-900 dark:hover:text-slate-200" | ||
| > | ||
| {file.author.username} | ||
| </Link> | ||
| ) : ( | ||
| `${file.author.firstName} ${file.author.lastName}` | ||
| ) // Render as plain text if no username to link to | ||
| } | ||
| </p> | ||
| {file.section && ( | ||
| <p className="text-sm font-medium text-slate-800 dark:text-slate-200"> | ||
| <Link | ||
| href={`/notes/${file.section.prefix}/${file.section.number}`} | ||
| className="underline hover:text-slate-900 dark:hover:text-slate-200" | ||
| > | ||
| {file.section.prefix} {file.section.number} | ||
| </Link> | ||
| .{file.section.sectionCode}{' '} | ||
| <Link | ||
| href={`/notes/${file.section.profFirst}/${file.section.profLast}`} | ||
| className="underline hover:text-slate-900 dark:hover:text-slate-200" | ||
| > | ||
| {file.section.profFirst} {file.section.profLast} | ||
| </Link>{' '} | ||
| {file.section.term} {file.section.year} | ||
| </p> | ||
| )} | ||
| {file.description ? ( | ||
| <p className="text-sm text-slate-600 dark:text-slate-400 leading-relaxed mt-1"> | ||
| {file.description} | ||
| </p> | ||
| ) : ( | ||
| <p className="text-sm text-slate-400 italic mt-1"> | ||
| No provided description. | ||
| </p> | ||
| )} | ||
| <span className="text-xs text-slate-600 dark:text-slate-400 mt-1"> | ||
| Last modified{' '} | ||
| {file.updatedAt.toLocaleDateString('en-US', { | ||
| day: 'numeric', | ||
| month: 'short', | ||
| year: 'numeric', | ||
| })} | ||
| </span> | ||
| </div> | ||
| </Collapse> | ||
| </div> | ||
| </Panel> | ||
| ); | ||
| } | ||
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
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.