File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ const Page = () => {
119119 < ProfileSection
120120 className = "grid grid-cols-1 gap-4 md:grid-cols-3"
121121 profile = { profile }
122+ uid = { currentUser . uid }
122123 />
123124
124125 { /* 2-2. GraphSection */ }
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const ButtonSection = ({ onAddTodo }: ButtonSectionProps) => {
2424 onClick = { handleAddClick }
2525 className = "flex-1 rounded-xl border border-slate-300 bg-none py-4 text-center text-base font-semibold text-slate-700 transition hover:bg-slate-200 active:bg-slate-300 disabled:cursor-not-allowed disabled:opacity-60"
2626 >
27- 계획 추가하기
27+ 플랜 추가하기
2828 </ button >
2929 </ div >
3030 ) ;
Original file line number Diff line number Diff line change 11import { Profile } from '@/lib/home/profileService' ;
22import Card from './Card' ;
3-
3+ import { getRandomProfileIcon } from '@/utils/getRandomProfileIcon' ;
44interface ProfileSectionProps {
55 className ?: string ;
66 profile : Profile | null ;
7+ uid : string ;
78}
89
9- const ProfileSection = ( { className, profile } : ProfileSectionProps ) => {
10+ const ProfileSection = ( { className, profile, uid } : ProfileSectionProps ) => {
11+ const icon = getRandomProfileIcon ( uid ) ;
1012 return (
1113 < div className = { className } >
1214 < div className = "md:col-span-2" >
1315 < Card className = "flex items-center gap-4" >
14- < div className = "flex h-16 w-16 items-center justify-center overflow-hidden rounded-full border border-gray-100 bg-purple-100" >
15- < span className = "text-3xl" > 😈 </ span >
16+ < div className = "flex h-16 w-16 items-center justify-center overflow-hidden rounded-full border border-gray-100 bg-purple-100 pt-1 " >
17+ < span className = "text-3xl" > { icon } </ span >
1618 </ div >
1719
1820 < div >
Original file line number Diff line number Diff line change 1+ const PROFILE_ICONS = [
2+ '🌱' ,
3+ '🔥' ,
4+ '😎' ,
5+ '😈' ,
6+ '🖤' ,
7+ '💀' ,
8+ '⚡' ,
9+ '🌸' ,
10+ '🐣' ,
11+ ] as const ;
12+
13+ export type ProfileIcon = ( typeof PROFILE_ICONS ) [ number ] ;
14+
15+ export function getRandomProfileIcon ( seed : string ) : ProfileIcon {
16+ let hash = 0 ;
17+
18+ for ( let i = 0 ; i < seed . length ; i ++ ) {
19+ hash = ( hash << 5 ) - hash + seed . charCodeAt ( i ) ;
20+ hash |= 0 ; // 32bit
21+ }
22+
23+ const index = Math . abs ( hash ) % PROFILE_ICONS . length ;
24+ return PROFILE_ICONS [ index ] ;
25+ }
You can’t perform that action at this time.
0 commit comments