Skip to content

Commit

Permalink
feat :: 조건부핸들링 #15
Browse files Browse the repository at this point in the history
  • Loading branch information
kyumin7487 committed Aug 1, 2024
1 parent 70c8706 commit bf0b28c
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 8 deletions.
23 changes: 23 additions & 0 deletions src/components/home/profile/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { useState } from "react";
import Profile from "src/components/home/profile/profile";
import ProfileEdit from "src/components/home/profile/profileEdit";

const MainProfile: React.FC = () => {
const [isEditing, setIsEditing] = useState(false);

const handleEditToggle = () => {
setIsEditing(!isEditing);
};

return (
<div>
{isEditing ? (
<ProfileEdit onCancel={handleEditToggle} />
) : (
<Profile onEdit={handleEditToggle} />
)}
</div>
);
};

export default MainProfile;
10 changes: 7 additions & 3 deletions src/components/home/profile/profile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React, {useState} from "react";
import React, { useState } from "react";
import * as S from "./style";
import AvatarImg from "src/assets/imgs/header/AvatarImg.svg";
import Pencil from "src/assets/imgs/profile/write.svg";
import Empty from "src/assets/imgs/profile/Empty.svg";

const Profile = () => {
interface ProfileProps {
onEdit: () => void;
}

const Profile: React.FC<ProfileProps> = ({ onEdit }) => {
const [selected, setSelected] = useState(0);

const handleSelect = (index: number) => {
Expand Down Expand Up @@ -39,7 +43,7 @@ const Profile = () => {
<S.ProfileInfo>
<S.UserName>이해준</S.UserName>
<S.ButtonContainer>
<S.EditButton>프로필 수정</S.EditButton>
<S.EditButton onClick={onEdit}>프로필 수정</S.EditButton>
<S.SettingsButton>프로필 설정</S.SettingsButton>
</S.ButtonContainer>
</S.ProfileInfo>
Expand Down
19 changes: 19 additions & 0 deletions src/components/home/profile/profileEdit/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import * as S from "src/components/home/profile/profileEdit/style";
interface ProfileEditProps {
onCancel: () => void;
}

const ProfileEdit: React.FC<ProfileEditProps> = ({ onCancel }) => {
return (
<S.profileWrap>
<S.mainWrap>
<h1>프로필 수정</h1>
<button onClick={onCancel}>취소</button>
</S.mainWrap>
</S.profileWrap>
)
;
};

export default ProfileEdit;
23 changes: 23 additions & 0 deletions src/components/home/profile/profileEdit/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import styled from 'styled-components';

export const profileWrap = styled.main`
display: flex;
flex-direction: column;
margin-top: 4.44vh;
width: 100%;
height: calc(100% - 4.44vh);
align-items: center;
justify-content: center;
`;

export const mainWrap = styled.main`
width: 72vw;
height: 80vh;
border-radius: 13px;
background: #fff;
box-shadow: 0px 3px 9px 0px rgba(0, 0, 0, 0.12);
display: flex;
flex-direction: column;
align-items: center;
padding: 15px;
`;
1 change: 1 addition & 0 deletions src/components/home/profile/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import styled from 'styled-components';
11 changes: 6 additions & 5 deletions src/pages/profile/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";
import Profile from "src/components/home/profile/profile";
import MainProfile from "src/components/home/profile/index";

const ProfilePage=()=>{
return <Profile/>
}
export default ProfilePage;
const ProfilePage: React.FC = () => {
return <MainProfile />;
};

export default ProfilePage;

0 comments on commit bf0b28c

Please sign in to comment.