Skip to content

Commit

Permalink
Merge pull request #58 from Na-o-man/feat/#48
Browse files Browse the repository at this point in the history
Feat: addgroup state추가
  • Loading branch information
E-hyeon authored Aug 5, 2024
2 parents ac814a9 + 54e7684 commit 5fd2139
Show file tree
Hide file tree
Showing 16 changed files with 475 additions and 249 deletions.
4 changes: 1 addition & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import { RecoilRoot } from 'recoil';
import { ThemeProvider } from 'styled-components';
import { theme } from 'styles/colors';
import AddGroupInputCount from './pages/AddGroupMain/AddGroupInputCount';
import AddGroupSpace from './pages/AddGroupMain/AddGroupSpace';
import AddGroupMemberName from './pages/AddGroupMain/AddGroupMemberName';
import AddGroupType from './pages/AddGroupMain/AddGroupType';
Expand Down Expand Up @@ -42,7 +41,6 @@ function App() {
<Route path="group" element={<ShareGroupMain />} />
<Route path="group/:id" element={<ShareGroupFolder />} />
<Route path="group/detail" element={<ShareGroupDetailPage />} />
<Route path="group/add/count" element={<AddGroupInputCount />} />
<Route path="group/add/member" element={<AddGroupMemberName />} />
<Route path="group/add/space" element={<AddGroupSpace />} />
<Route path="group/add/grouptype" element={<AddGroupType />} />
Expand All @@ -65,4 +63,4 @@ function App() {
);
}

export default App;
export default App;
25 changes: 0 additions & 25 deletions src/components/AddGroup/AddGroupHeadCount/HeadCount.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import * as S from './Styles';
import { useNavigate } from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import { namesState } from '../state';
import MembernameList from './membernameList/membernameList';

function MemberNameHead() {
Expand All @@ -22,9 +24,16 @@ function MemberNameContent() {

const AddGroupMembername = () => {
const navigate = useNavigate();
const names = useRecoilValue(namesState);

const handleNextClick = () => {
navigate('/group/add/grouptype');
// 배열이 비어 있는지 확인
if (names.length > 0) {
console.log(`이름: ${names.join(', ')}`);
navigate('/group/add/grouptype');
} else {
alert('이름을 입력해주세요');
}
};

return (
Expand Down
11 changes: 0 additions & 11 deletions src/components/AddGroup/AddGroupMembername/Styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@ export const Text = styled.p`
text-underline-offset: 5px;
`;

export const InportNameContainer = styled.div`
display: absolute;
justify-content: center;
z-index: 10;
`;

export const InportNameBox = styled.div`
top: -110px;
left: 40px;
`;

export const ListLayout = styled.div`
position: relative;
width: 350px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,33 @@ export const nameLayout = styled.div`
flex-direction: column;
min-height: 30px;
align-items: center;
/* 전체 스크롤바 */
::-webkit-scrollbar {
width: 12px;
}
/* 스크롤바의 트랙 */
::-webkit-scrollbar-track {
background: none;
}
/* 스크롤바 핸들 */
::-webkit-scrollbar-thumb {
background: ${({ theme }) => theme.colors.backgroundPrimary};
border-radius: 10px;
}
/* 스크롤바 핸들 호버 */
::-webkit-scrollbar-thumb:hover {
background: ${({ theme }) => theme.colors.primary};
}
`;

export const nameList = styled.div`
position: relative;
display: flex;
flex-direction: row;
width: 180px;
width: 190px;
height: 140px;
overflow-y: auto;
align-items: center;
Expand All @@ -40,6 +60,9 @@ export const nameContainer = styled.div`
margin: 1px;
width: 58px; /* 고정된 너비 */
height: 20px; /* 고정된 높이 */
&:hover .nameButton {
display: inline;
}
`;

export const NowImportName = styled(I.NowInportName)`
Expand Down Expand Up @@ -68,6 +91,7 @@ export const nameButton = styled(I.xCircle)`
font-size: 10;
color: black;
cursor: pointer;
display: none;
`;

/*입력 영역 */
Expand All @@ -93,12 +117,16 @@ export const inputname = styled.input`
background: none;
z-index: 30;
align-items: center;
&::placeholder {
color: ${({ theme }) => theme.colors.tertiary};
opacity: 1;
}
`;

export const inputplus = styled(I.PlusCircle)`
position: absolute;
top: 50%;
right: 20px;
right: 25px;
margin-top: -10px;
width: 26px;
height: 26px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,78 @@
import { useState } from 'react';
import React, { useState } from 'react';
import * as S from './Styles';
import { useRecoilState } from 'recoil';
import { namesState } from '../../state'; // Recoil 상태가 정의된 파일을 import

interface MembernameCreateProps {
addName: (name: string) => void;
}

const MembernameCreate: React.FC<MembernameCreateProps> = ({ addName }) => {
const [newName, setNewName] = useState<string>(''); /*상태타입 정의 */

const handleAddName = () => {
if (newName.trim() !== '') {
addName(newName.trim()); /*새로운 이름 추가함수 호출 */
setNewName(''); /*입력 필드 초기화 */
}
};

const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter') {
handleAddName(); // Enter 키로 이름 추가
}
};

function MembernameCreate() {
return (
<S.nameCreatelayout>
<S.MemberInput />
<S.inputname type="text" placeholder="이름"></S.inputname>
<S.inputplus />
<S.inputname
type="text"
placeholder="이름"
value={newName}
onChange={(e) => setNewName(e.target.value)}
onKeyDown={handleKeyDown}
/>
<S.inputplus onClick={handleAddName}>추가</S.inputplus>
</S.nameCreatelayout>
);
}
};

const MembernameList: React.FC = () => {
const [names, setNames] = useRecoilState(namesState); // Recoil 상태 사용

const addName = (name: string) => {
const newNames = [...names, name];
setNames(newNames);
console.log(`이름: ${newNames.join(', ')}`); // 콘솔에 이름 리스트 출력
};

const removeName = (index: number) => {
const newNames = names.filter((_, i) => i !== index); /*이름 제거*/
setNames(newNames);
console.log(`이름: ${newNames.join(', ')}`); // 콘솔에 이름 리스트 출력
};

const membernameList = () => {
return (
<S.nameLayout>
<S.nameFolder />
<S.nameList>
<S.nameContainer>
<S.NowImportName />
<S.name>황지원</S.name>
<S.nameButton></S.nameButton>
</S.nameContainer>
<S.nameContainer>
<S.NowImportName />
<S.name>박을순</S.name>
<S.nameButton></S.nameButton>
</S.nameContainer>
<S.nameContainer>
<S.NowImportName />
<S.name>김똘똘</S.name>
</S.nameContainer>
{names.map((name, index) => (
<S.nameContainer key={index}>
<S.NowImportName />
<S.name>{name}</S.name>
<S.nameButton
className="nameButton"
onClick={() => removeName(index)}
>
</S.nameButton>
</S.nameContainer>
))}
</S.nameList>
<MembernameCreate />
<MembernameCreate addName={addName} />
</S.nameLayout>
);
};

export default membernameList;
export default MembernameList;
6 changes: 5 additions & 1 deletion src/components/AddGroup/AddGroupShare/AddGroupshare.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import React from 'react';
import * as S from './Styles';
import { useRecoilValue } from 'recoil';
import { placeState } from '../state';

const AddGroupshare = () => {
const place = useRecoilValue(placeState);

return (
<S.Layout>
<S.AddFileContainer>
<S.File />
<S.AddFileText>제주도 2024</S.AddFileText>
<S.AddFileText>{place}</S.AddFileText>
</S.AddFileContainer>
<S.CopyCloudContainer>
<S.Cloud />
Expand Down
Loading

0 comments on commit 5fd2139

Please sign in to comment.