-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement avatar section (#153)
* feat: implement avatar section * fiex failing ci * Update README.md * fix: failing ci * fix: failing test * fix: warning of any --------- Co-authored-by: “Akshola00” <“akinniyishola07@gmail.com”> Co-authored-by: Strong Force <64266194+princeibs@users.noreply.github.com>
- Loading branch information
1 parent
22ec84b
commit 1c7e6a1
Showing
11 changed files
with
279 additions
and
171 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export default function AvatarCard({ | ||
avatar, | ||
active, | ||
onSelect, | ||
}: { | ||
avatar: string; | ||
active: boolean; | ||
onSelect: () => void; | ||
}) { | ||
return ( | ||
<button | ||
className={`option-container ${active ? "active" : ""}`} | ||
onClick={onSelect} | ||
> | ||
<div className="option"> | ||
<img src={avatar} alt="avatar" className="avatar" /> | ||
</div> | ||
</button> | ||
); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { createContext, useState, useContext } from "react"; | ||
|
||
type Avatar = "avatar1" | "avatar2" | "avatar3" | "avatar4"; | ||
|
||
interface AvatarContextType { | ||
avatar: Avatar; | ||
changeAvatar: (newAvatar: Avatar) => void; | ||
} | ||
|
||
const AvatarContext = createContext<AvatarContextType>({ | ||
avatar: "avatar1", | ||
changeAvatar: () => {}, | ||
}); | ||
|
||
// eslint-disable-next-line react-refresh/only-export-components | ||
export const useAvatar = () => useContext(AvatarContext); | ||
|
||
export const AvatarProvider: React.FC<{ children: React.ReactNode }> = ({ | ||
children, | ||
}) => { | ||
const [avatar, setAvatar] = useState<Avatar>("avatar1"); | ||
|
||
const changeAvatar = (newAvatar: Avatar) => { | ||
setAvatar(newAvatar); | ||
}; | ||
|
||
return ( | ||
<AvatarContext.Provider value={{ avatar, changeAvatar }}> | ||
{children} | ||
</AvatarContext.Provider> | ||
); | ||
}; | ||
|
||
export { AvatarContext }; |
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
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.