-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avatar Selector for RSVP Page (#276)
* Added temporary RSVP component testing page * Implemented the avatar selector component * Removed preset background color for icons * Linted files * Modified to use meta
- Loading branch information
1 parent
0cfe031
commit 84445d6
Showing
6 changed files
with
150 additions
and
11 deletions.
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,61 @@ | ||
"use client"; | ||
import { avatars } from "@/modules/avatars"; | ||
import clsx from "clsx"; | ||
import { useField } from "formik"; | ||
import Image from "next/image"; | ||
import styles from "./AvatarSelector.module.scss"; | ||
|
||
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; | ||
|
||
const showFeedback = meta.error && meta.touched; | ||
|
||
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> | ||
|
||
<h4>{showFeedback && meta.error}</h4> | ||
</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
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