-
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
Avatar Selector for RSVP Page #276
Merged
+150
−11
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
42fa613
Added temporary RSVP component testing page
miguelaenlle 499a8df
Merge branch 'main' into ma/rsvp-profile-picture-selector
miguelaenlle 76fadf9
Implemented the avatar selector component
miguelaenlle 061f3bc
Removed preset background color for icons
miguelaenlle d1fb375
Linted files
miguelaenlle 8e712de
Modified to use meta
miguelaenlle 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use client"; | ||
import AvatarSelector from "@/components/AvatarSelector/AvatarSelector"; | ||
import styles from "./styles.module.scss"; | ||
import { Formik } from "formik"; | ||
|
||
const RSVPTestingPage: React.FC = () => { | ||
return ( | ||
<div className={styles.screen}> | ||
<h1>RSVP Testing Page</h1> | ||
<p>This page will be removed shortly.</p> | ||
<br /> | ||
<Formik | ||
initialValues={{ | ||
avatar: null | ||
}} | ||
onSubmit={() => {}} | ||
> | ||
<AvatarSelector name="avatar" label="Select your avatar:" /> | ||
</Formik> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RSVPTestingPage; |
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,8 @@ | ||
.screen { | ||
background-size: cover; | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
width: 100vw; | ||
min-height: 100vh; | ||
padding-top: 150px; | ||
} |
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,38 @@ | ||
.avatarSelector { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
|
||
.avatarSelector .avatarIcon { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 90px; | ||
height: 90px; | ||
margin: 5px; | ||
cursor: pointer; | ||
border-radius: 50%; | ||
border: 3px solid transparent; | ||
transition: border 0.2s ease-in-out; | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
.avatarSelector .avatarIcon.selected { | ||
border-color: #dfad72; | ||
} | ||
|
||
.avatarSelector .avatarIconImage { | ||
width: 65px; | ||
height: 65px; | ||
:hover { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.5rem; | ||
} |
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,57 @@ | ||
"use client"; | ||
import { avatars } from "@/modules/avatars"; | ||
import { useField } from "formik"; | ||
import Image from "next/image"; | ||
import styles from "./AvatarSelector.module.scss"; | ||
import clsx from "clsx"; | ||
|
||
export type AvatarSelectorProps = { | ||
name: string; | ||
label: string; | ||
required?: boolean; | ||
}; | ||
|
||
const AvatarSelector: React.FC<AvatarSelectorProps> = ({ | ||
name, | ||
label, | ||
required | ||
}) => { | ||
const [field, meta, helpers] = useField(name); | ||
const { setValue } = helpers; | ||
const { value } = field; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<label htmlFor={name}> | ||
{label} | ||
{required && "*"} | ||
</label> | ||
<div className={styles.avatarSelector}> | ||
{avatars.map(avatar => ( | ||
<div | ||
style={{ | ||
backgroundColor: | ||
avatar.backgroundColor ?? "transparent" | ||
}} | ||
className={clsx( | ||
styles.avatarIcon, | ||
avatar.name === value && styles.selected | ||
)} | ||
key={avatar.name} | ||
onClick={() => { | ||
setValue(avatar.name); | ||
}} | ||
> | ||
<Image | ||
className={styles.avatarIconImage} | ||
src={avatar.icon} | ||
alt={avatar.name} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AvatarSelector; |
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.
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.
The AvatarSelector component uses the
backgroundColor
. I left it atf0f0f0
for all icons for now because, if I recall correctly, these are the HackIllinois 2024 avatar icons, so we can set new background colors (if preferred) once the new icons are ready.