Skip to content
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

Implement profile page #117

Merged
merged 25 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions public/assets/icons/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/assets/icons/facebook-icon.svg
raymosun marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/assets/icons/github-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/assets/icons/ig-icon.svg

This file was deleted.

2 changes: 1 addition & 1 deletion public/assets/icons/instagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/assets/icons/leaderboard-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/assets/icons/linkedin-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions public/assets/icons/major-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/assets/icons/profile-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/components/common/GifSafeImage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { isSrcAGif } from '@/lib/utils';
import Image, { ImageProps } from 'next/image';

/**
* A next/image Image that is automatically unoptimized when `src` is a gif
* @param props - props for Next Image component
* @returns image component
*/
const GifSafeImage = ({ src, alt, ...restProps }: ImageProps) => {
farisashai marked this conversation as resolved.
Show resolved Hide resolved
return <Image src={src} alt={alt} unoptimized={isSrcAGif(src)} {...restProps} />;
};

export default GifSafeImage;
1 change: 1 addition & 0 deletions src/components/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as Carousel } from './Carousel';
export { default as CommunityLogo } from './CommunityLogo';
export { default as Cropper } from './Cropper';
export { default as Dropdown } from './Dropdown';
export { default as GifSafeImage } from './GifSafeImage';
export { default as LinkButton } from './LinkButton';
export { default as Modal } from './Modal';
export { default as PaginationControls } from './PaginationControls';
Expand Down
4 changes: 4 additions & 0 deletions src/components/events/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export { default as CalendarButtons } from './CalendarButtons';
export { default as EventCard } from './EventCard';
export { default as EventCarousel } from './EventCarousel';
export { default as EventDisplay } from './EventDisplay';
export { default as EventModal } from './EventModal';
export { default as PointsDisplay } from './PointsDisplay';
5 changes: 5 additions & 0 deletions src/components/home/Hero/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@
&:hover {
box-shadow: 0 5px 10px var(--theme-shadow);
}

svg {
height: 24px;
width: 24px;
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/components/layout/Navbar/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
.iconLink {
color: var(--theme-text-on-background-1);
cursor: pointer;
height: 24px;
width: 24px;
}
}
}
Expand Down Expand Up @@ -150,6 +152,11 @@
&:hover {
background-color: var(--theme-surface-1);
}

svg {
height: 24px;
width: 24px;
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/components/leaderboard/LeaderboardRow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isSrcAGif } from '@/lib/utils';
import Image from 'next/image';
import GifSafeImage from '@/components/common/GifSafeImage';
import Link from 'next/link';
import { useEffect, useRef } from 'react';
import styles from './style.module.scss';
Expand Down Expand Up @@ -52,14 +51,13 @@ const LeaderboardRow = ({
return (
<Link href={url} className={styles.row} ref={ref}>
<span className={styles.position}>{position}</span>
<Image
<GifSafeImage
src={image}
width={36}
height={36}
quality={10}
alt={`Profile picture for ${name}`}
className={styles.profilePicture}
unoptimized={isSrcAGif(image)}
/>
<div className={styles.nameRank}>
<span className={styles.name}>
Expand Down
7 changes: 3 additions & 4 deletions src/components/leaderboard/TopThreeCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isSrcAGif, trim } from '@/lib/utils';
import Image from 'next/image';
import GifSafeImage from '@/components/common/GifSafeImage';
import { trim } from '@/lib/utils';
import Link from 'next/link';
import styles from './style.module.scss';

Expand All @@ -18,13 +18,12 @@ const TopThreeCard = ({ position, rank, name, url, points, image }: UserCardProp
<Link href={url} className={styles.leaderboardCard} data-position={positionNames[position - 1]}>
<div className={styles.cardLeft}>{position}</div>
<div className={styles.cardRight}>
<Image
<GifSafeImage
className={styles.profileImage}
src={image}
alt="User Profile Pic"
width={80}
height={80}
unoptimized={isSrcAGif(image)}
/>
<span className={styles.cardText}>{trim(name, 25)}</span>
<span className={styles.cardText}>{rank}</span>
Expand Down
18 changes: 18 additions & 0 deletions src/components/profile/HandleNotFound/index.tsx
raymosun marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { SignInButton } from '@/components/auth';
import { Typography, VerticalForm } from '@/components/common';
import Cat404 from '@/public/assets/graphics/cat404.png';
import Image from 'next/image';

export interface HandleNotFoundProps {
handle: string;
}

export const HandleNotFound = ({ handle }: HandleNotFoundProps) => (
<VerticalForm style={{ alignItems: 'center', margin: 'auto' }}>
<Typography variant="h1/medium" style={{ textAlign: 'center' }}>
No user with handle &lsquo;{handle}&rsquo; was found.
</Typography>
<Image src={Cat404} width={256} height={256} alt="Sad Cat" />
<SignInButton type="link" display="button1" href="/" text="Return to Home" />
</VerticalForm>
);
7 changes: 3 additions & 4 deletions src/components/profile/Preview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Typography } from '@/components/common';
import GifSafeImage from '@/components/common/GifSafeImage';
raymosun marked this conversation as resolved.
Show resolved Hide resolved
import SocialMediaIcon from '@/components/profile/SocialMediaIcon';
import { PublicProfile } from '@/lib/types/apiResponses';
import { SocialMediaType } from '@/lib/types/enums';
import { getLevel, getProfilePicture, isSrcAGif } from '@/lib/utils';
import Image from 'next/image';
import { getLevel, getProfilePicture } from '@/lib/utils';
import styles from './style.module.scss';

const fixUrl = (url: string) => (url.includes('://') ? url : `http://${url}`);
Expand Down Expand Up @@ -31,13 +31,12 @@ interface PreviewProps {
const Preview = ({ user, pfpCacheBust }: PreviewProps) => {
return (
<div className={styles.wrapper}>
<Image
<GifSafeImage
className={styles.pfp}
src={getProfilePicture(user) + (pfpCacheBust !== -1 ? `?_=${pfpCacheBust}` : '')}
alt="Profile picture"
width={90}
height={90}
unoptimized={isSrcAGif(user.profilePicture)}
/>
<Typography variant="h2/bold" component="p">
{user.firstName} {user.lastName}
Expand Down
2 changes: 2 additions & 0 deletions src/components/profile/Preview/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
align-items: center;
display: flex;
flex-direction: column;
position: sticky;
raymosun marked this conversation as resolved.
Show resolved Hide resolved
text-align: center;
top: 4rem;

.pfp {
border-radius: 50%;
Expand Down
Loading