Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…IRVANA_Gidong into feat/profile/followButton
  • Loading branch information
nayeon-hub committed Sep 23, 2023
2 parents 69a1af0 + 7174a7c commit ea81301
Show file tree
Hide file tree
Showing 25 changed files with 433 additions and 189 deletions.
19 changes: 15 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@
name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>NIRVANA</title>
<link rel="icon" href="/assets/favicon.ico">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reset-css@5.0.2/reset.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,300,0,-25" />
<link rel="stylesheet" as="style" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.8/dist/web/variable/pretendardvariable.css" />
<link
rel="icon"
href="/assets/favicon.ico" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/reset-css@5.0.2/reset.min.css" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,300,0,-25" />
<link
rel="stylesheet"
as="style"
crossorigin
href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.8/dist/web/variable/pretendardvariable.css" />
</head>
<body>
<div id="root"></div>
<div id="modal-root"></div>
<script
type="module"
src="/src/main.tsx"></script>
Expand Down
62 changes: 35 additions & 27 deletions src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
import {
StyledDeemBackground,
Expand Down Expand Up @@ -32,40 +32,48 @@ const Alert = ({
nextPageLink
}: Partial<AlertProps>) => {
const [disabled, setDisabled] = useState(false);
const [domReady, setDomReady] = useState(false);

return createPortal(
<StyledDeemBackground disabled={disabled}>
<StyledAlertBackground
width={width}
height={height}>
<IconContainer emojiSize={emojiSize}>{emoji}</IconContainer>
<ContentContainer contentFontSize={contentFontSize}>
<p>{content}</p>
<NavButtonContainer onClick={() => setDisabled(true)}>
{nextPageLink ? (
<Link pageLink={nextPageLink}>
useEffect(() => {
setDomReady(true);
}, []);

return (
domReady &&
createPortal(
<StyledDeemBackground disabled={disabled}>
<StyledAlertBackground
width={width}
height={height}>
<IconContainer emojiSize={emojiSize}>{emoji}</IconContainer>
<ContentContainer contentFontSize={contentFontSize}>
{content}
<NavButtonContainer onClick={() => setDisabled(true)}>
{nextPageLink ? (
<Link pageLink={nextPageLink}>
<Button
width={300}
height={50}
dark={true}
bold={true}
label={buttonLabel}
/>
</Link>
) : (
<Button
width={300}
height={50}
dark={true}
bold={true}
label={buttonLabel}
/>
</Link>
) : (
<Button
width={300}
height={50}
dark={true}
bold={true}
label={buttonLabel}
/>
)}
</NavButtonContainer>
</ContentContainer>
</StyledAlertBackground>
</StyledDeemBackground>,
document.getElementById('root-modal')
)}
</NavButtonContainer>
</ContentContainer>
</StyledAlertBackground>
</StyledDeemBackground>,
document.getElementById('root-modal')
)
);
};
export default Alert;
52 changes: 29 additions & 23 deletions src/components/Confirm/Confirm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
import { Link } from '../Link';
import {
Expand Down Expand Up @@ -30,32 +30,38 @@ const Confirm = ({
ConfirmButton
}: Partial<ConfirmProps>) => {
const [disabled, setDisabled] = useState(false);
const [domReady, setDomReady] = useState(false);

const FormedCancelButton =
typeof CancelButton === 'function' ? CancelButton() : CancelButton;
const FormedConfirmlButton =
typeof ConfirmButton === 'function' ? ConfirmButton() : ConfirmButton;
return createPortal(
<StyledDeemBackground disabled={disabled}>
<StyledConfirmBackground
width={330}
height={390}>
<IconContainer emojiSize={80}>{emoji}</IconContainer>
<ContentContainer contentFontSize={contentFontSize}>
{content}
<NavButtonContainer>
<CancelButtonDefaultEvent onClick={() => setDisabled(true)}>
{FormedCancelButton}
</CancelButtonDefaultEvent>
<Link
pageLink={nextPageLink}
state={{ ...linkState }}>
{FormedConfirmlButton}
</Link>
</NavButtonContainer>
</ContentContainer>
</StyledConfirmBackground>
</StyledDeemBackground>,
document.getElementById('root-modal')

useEffect(() => {
setDomReady(true);
}, []);

return (
domReady &&
createPortal(
<StyledDeemBackground disabled={disabled}>
<StyledConfirmBackground
width={330}
height={390}>
<IconContainer emojiSize={80}>{emoji}</IconContainer>
<ContentContainer contentFontSize={contentFontSize}>
{content}
<NavButtonContainer>
<CancelButtonDefaultEvent onClick={() => setDisabled(true)}>
{CancelButton}
</CancelButtonDefaultEvent>
<Link pageLink={nextPageLink}>{ConfirmButton}</Link>
</NavButtonContainer>
</ContentContainer>
</StyledConfirmBackground>
</StyledDeemBackground>,
document.getElementById('root-modal')
)
);
};
export default Confirm;
4 changes: 2 additions & 2 deletions src/components/PostPreview/PostHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const PostHeader = ({
totalComments,
noneProfile
}: PostHeaderProps) => {
const { image, author, createdAt } = post;
const { author, createdAt } = post;
const iconDescription = [
{ name: 'favorite', size: 12, total: totalLikes },
{ name: 'chat', size: 12, total: totalComments }
Expand All @@ -37,7 +37,7 @@ const PostHeader = ({
color='black'>
<Avatar
alt={'유저 프로필'}
src={image}
src={author.image}
size={35}
/>
</Link>
Expand Down
10 changes: 7 additions & 3 deletions src/hooks/useSessionStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useState, useEffect } from 'react';

function useSessionStorage<T>(
key: string,
initialValue?: T
): [T, React.Dispatch<React.SetStateAction<T>>] {
initialValue: T
): [T, React.Dispatch<React.SetStateAction<T>>, () => void] {
const storedValue = sessionStorage.getItem(key);
const initial = storedValue ? JSON.parse(storedValue) : initialValue;
const [value, setValue] = useState<T>(initial);
Expand All @@ -12,7 +12,11 @@ function useSessionStorage<T>(
sessionStorage.setItem(key, JSON.stringify(value));
}, [key, value]);

return [value, setValue];
const removeValue = () => {
sessionStorage.removeItem(key);
};

return [value, setValue, removeValue];
}

export default useSessionStorage;
37 changes: 37 additions & 0 deletions src/pages/NotFound/NotFound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Link } from '@components/Link';
import { Button } from '@components/Button';
import { LandingMain } from '@pages/landing/Landing.style';
import {
StyledAlertBackground,
IconContainer,
ContentContainer,
NavButtonContainer
} from '@components/Alert/Alert.style';

const NotFound = () => {
return (
<LandingMain>
<StyledAlertBackground
width={330}
height={390}>
<IconContainer emojiSize={80}>{'😢'}</IconContainer>
<ContentContainer contentFontSize={16}>
{'404! 잘못된 페이지 접근이에요!'}
<NavButtonContainer>
<Link pageLink={'/'}>
<Button
width={300}
height={50}
dark={true}
bold={true}
label={'메인화면으로 이동하기'}
/>
</Link>
</NavButtonContainer>
</ContentContainer>
</StyledAlertBackground>
</LandingMain>
);
};

export default NotFound;
3 changes: 3 additions & 0 deletions src/pages/NotFound/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import NotFound from './NotFound';

export default NotFound;
3 changes: 3 additions & 0 deletions src/pages/profile/Profile.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import styled from '@emotion/styled';

export const ProfilePage = styled.div`
display: flex;
position: relative;
flex-direction: column;
width: 100%;
height: 100%;
overflow: hidden;
`;

export const ProfileInfoContainer = styled.div`
Expand Down
25 changes: 22 additions & 3 deletions src/pages/profile/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import createTabItems from './utils/createTabItems';
import { useEffect } from 'react';
import { useEffect, useState } from 'react';
import { getUser } from '@apis/user';
import { useLocation, useParams } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query';
Expand All @@ -10,12 +10,14 @@ import {
ProfileInfo,
ProfileCover,
ProfileMain,
ProfileEdit
ProfileEdit,
SettingSideBar
} from '@pages/profile/components';

const Profile = () => {
const { userId } = useParams<{ userId: string }>();
const location = useLocation();
const [sideBarOpened, setSideBarOpened] = useState(false);
const [editMode, setEditMode] = useRecoilState(editModeState);
useEffect(() => {
setEditMode(location.hash === '#edit');
Expand All @@ -27,10 +29,23 @@ const Profile = () => {
{ enabled: !!userId }
);

const openSidebar = () => {
setSideBarOpened(true);
};

const closeSidebar = () => {
console.log('close');
setSideBarOpened(false);
};

const tabItems = createTabItems(data, isLoading);

return (
<ProfilePage>
<SettingSideBar
sideBarOpened={sideBarOpened}
closeSidebar={closeSidebar}
/>
<ProfileCover
refetch={() => refetch()}
src={isLoading ? '' : data.coverImage}
Expand All @@ -46,7 +61,11 @@ const Profile = () => {
{editMode ? (
<ProfileEdit refetch={() => refetch()} />
) : (
<ProfileMain tabItems={tabItems} />
<ProfileMain
tabItems={tabItems}
openSidebar={openSidebar}
fullName={isLoading ? '' : data.fullName}
/>
)}
</ProfileInfoContainer>
</ProfilePage>
Expand Down
17 changes: 6 additions & 11 deletions src/pages/profile/components/MeditationInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@ import { MeditationInfoSection } from './MeditationInfo.style';
import { MeditationInfoItem } from '@pages/profile/components';

interface MeditationInfoProps {
totalMeditationCount: number;
totalMeditationTime: number;
data: number[];
fullName: string;
}

const MeditationInfo = ({
totalMeditationCount,
totalMeditationTime,
fullName
}: MeditationInfoProps) => {
const MeditationInfo = ({ data, fullName }: MeditationInfoProps) => {
return (
<MeditationInfoSection>
<MeditationInfoItem icon='🧘🏻'>
<p>
<strong>{fullName}</strong> 님은 총 <b>{totalMeditationCount}</b>번의
명상을 진행했어요.
<strong>{fullName}</strong> 님은 총 <b>{data[0]}</b>번의 명상을
진행했어요.
</p>
</MeditationInfoItem>
<MeditationInfoItem icon='⏰'>
<p>
<strong>{fullName}</strong> 님은 총 <b>{totalMeditationTime}</b>분의
명상을 하셨어요.
<strong>{fullName}</strong> 님은 총 <b>{data[1]}</b>분의 명상을
하셨어요.
</p>
</MeditationInfoItem>
</MeditationInfoSection>
Expand Down
1 change: 0 additions & 1 deletion src/pages/profile/components/ProfileCarousel.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ export const ProfileCarouselContainer = styled.div`
`;

export const ProfileCarouselItem = styled.div`
border: 1px solid #ccc;
flex: 1 0 100%;
`;
Loading

0 comments on commit ea81301

Please sign in to comment.