diff --git a/client/src/components/_common/roadmapItem/RoadmapItem.tsx b/client/src/components/_common/roadmapItem/RoadmapItem.tsx index 7fdce7610..499802def 100644 --- a/client/src/components/_common/roadmapItem/RoadmapItem.tsx +++ b/client/src/components/_common/roadmapItem/RoadmapItem.tsx @@ -57,7 +57,6 @@ const RoadmapItem = ({ item, hasBorder = true, roadmapId }: RoadmapItemProps) => {item.tags.map((tag) => { return # {tag.name}; })} - diff --git a/client/src/components/roadmapCreatePage/description/Description.tsx b/client/src/components/roadmapCreatePage/description/Description.tsx index 4e5e0ed2a..97fb85c36 100644 --- a/client/src/components/roadmapCreatePage/description/Description.tsx +++ b/client/src/components/roadmapCreatePage/description/Description.tsx @@ -22,7 +22,9 @@ const Description = () => { name='introduction' data-valid={validateInput} /> - + + + {errorMessage} diff --git a/client/src/components/roadmapCreatePage/description/description.styles.ts b/client/src/components/roadmapCreatePage/description/description.styles.ts index b3379703d..78b51de4a 100644 --- a/client/src/components/roadmapCreatePage/description/description.styles.ts +++ b/client/src/components/roadmapCreatePage/description/description.styles.ts @@ -6,13 +6,20 @@ export const Container = styled.article` export const FieldWrapper = styled.div` display: flex; + align-items: center; justify-content: space-between; width: 80%; - height: 3rem; - padding-left: 2rem; + height: 10rem; + padding: 2rem; - border-bottom: 0.2rem solid ${({ theme }) => theme.colors.gray300}; + background-color: ${({ theme }) => theme.colors.gray100}; + border-radius: 2rem; +`; + +export const TextCountWrapper = styled.div` + height: 80%; + margin-right: 2rem; `; export const ErrorMessage = styled.div` diff --git a/client/src/components/roadmapCreatePage/input/inputField/inputField.styles.ts b/client/src/components/roadmapCreatePage/input/inputField/inputField.styles.ts index 2c25d5d72..7ee268df5 100644 --- a/client/src/components/roadmapCreatePage/input/inputField/inputField.styles.ts +++ b/client/src/components/roadmapCreatePage/input/inputField/inputField.styles.ts @@ -4,6 +4,7 @@ export const Input = styled.textarea` width: 80%; height: 80%; color: ${({ theme }) => theme.colors.gray300}; + &::placeholder { ${({ theme }) => theme.fonts.description4}; color: ${({ theme }) => theme.colors.gray200}; diff --git a/client/src/components/roadmapCreatePage/roadmap/RoadmapItem.tsx b/client/src/components/roadmapCreatePage/roadmap/RoadmapItem.tsx index 8bdcff660..b7044c476 100644 --- a/client/src/components/roadmapCreatePage/roadmap/RoadmapItem.tsx +++ b/client/src/components/roadmapCreatePage/roadmap/RoadmapItem.tsx @@ -1,4 +1,4 @@ -import { ChangeEvent } from 'react'; +import React, { ChangeEvent } from 'react'; import * as S from './roadmap.styles'; type RoadmapItemProps = { @@ -20,10 +20,13 @@ const RoadmapItem = ({ {roadmapNumber} - getRoadmapItemTitle(e, itemId)} + ) => + getRoadmapItemTitle(e, itemId) + } maxLength={40} name='title' + placeholder='로드맵의 제목을 입렵해주세요' /> @@ -34,6 +37,7 @@ const RoadmapItem = ({ } maxLength={2000} name='content' + placeholder='로드맵의 본문을 입렵해주세요' /> diff --git a/client/src/components/roadmapCreatePage/roadmap/roadmap.styles.ts b/client/src/components/roadmapCreatePage/roadmap/roadmap.styles.ts index bd3cdb609..e233ef615 100644 --- a/client/src/components/roadmapCreatePage/roadmap/roadmap.styles.ts +++ b/client/src/components/roadmapCreatePage/roadmap/roadmap.styles.ts @@ -45,8 +45,13 @@ export const BodyFieldWrapper = styled.div` border-radius: 2rem; `; +export const NodeTitleInputField = styled.input` + width: 80%; +`; + export const NodeBodyInputField = styled.textarea` width: 80%; + height: 10rem; `; export const AddButton = styled.button` diff --git a/client/src/components/roadmapCreatePage/tag/Tag.tsx b/client/src/components/roadmapCreatePage/tag/Tag.tsx index 6086a2cef..e8339b75d 100644 --- a/client/src/components/roadmapCreatePage/tag/Tag.tsx +++ b/client/src/components/roadmapCreatePage/tag/Tag.tsx @@ -9,7 +9,8 @@ type TagProps = { getTags: (tags: string[]) => void; }; const Tag = ({ getTags }: TagProps) => { - const { tags, ref, getAddedTagText, checkIsTagCountMax } = useCreateTag(); + const { tags, ref, addTagByButton, addTagByEnter, checkIsTagCountMax, deleteTag } = + useCreateTag(); useEffect(() => { getTags(tags); @@ -21,10 +22,15 @@ const Tag = ({ getTags }: TagProps) => { {tags.map((item) => ( - {item} + <> + # {item} + + X + + ))} - - {checkIsTagCountMax() && +} + + {checkIsTagCountMax() && +} ); diff --git a/client/src/components/roadmapCreatePage/tag/TagItem.tsx b/client/src/components/roadmapCreatePage/tag/TagItem.tsx index da48ee8d1..c96e3da56 100644 --- a/client/src/components/roadmapCreatePage/tag/TagItem.tsx +++ b/client/src/components/roadmapCreatePage/tag/TagItem.tsx @@ -1,22 +1,27 @@ import { TAG_MAX_LENGTH } from '@/constants/roadmap/regex'; import { TAG_ITEM_MAX_LENGTH } from '@/constants/roadmap/tag'; import { useValidateInput } from '@/hooks/_common/useValidateInput'; -import { forwardRef, InputHTMLAttributes } from 'react'; +import React, { forwardRef, InputHTMLAttributes } from 'react'; import * as S from './tag.styles'; -type TagItemProps = InputHTMLAttributes; +type TagItemProps = { + addTagByEnter: (e: React.KeyboardEvent) => void; +} & InputHTMLAttributes; const TagItem = forwardRef((props, ref) => { + const { addTagByEnter, placeholder } = props; const { handleInputChange, value } = useValidateInput(TAG_MAX_LENGTH); return ( ); diff --git a/client/src/components/roadmapCreatePage/tag/tag.styles.ts b/client/src/components/roadmapCreatePage/tag/tag.styles.ts index 77608a0aa..b84a4746b 100644 --- a/client/src/components/roadmapCreatePage/tag/tag.styles.ts +++ b/client/src/components/roadmapCreatePage/tag/tag.styles.ts @@ -18,7 +18,6 @@ export const AddedTagItem = styled.article` justify-content: center; height: 4.7rem; - margin-right: 2rem; padding: 0 1rem; border: 0.2rem solid ${({ theme }) => theme.colors.main_dark}; @@ -32,7 +31,6 @@ export const TagItem = styled.article<{ width: number }>` width: ${({ width }) => (width > 4 ? width * 2 : 10)}rem; height: 4.7rem; - margin-right: 2rem; border: 0.2rem solid ${({ theme }) => theme.colors.main_dark}; border-radius: 100px; @@ -49,3 +47,8 @@ export const AddButton = styled.button` width: 5rem; height: 5rem; `; + +export const DeleteButton = styled.button` + margin-right: 2rem; + color: ${({ theme }) => theme.colors.main_dark}; +`; diff --git a/client/src/hooks/roadmap/useCreateTag.ts b/client/src/hooks/roadmap/useCreateTag.ts index e3b5aba12..913ec80c8 100644 --- a/client/src/hooks/roadmap/useCreateTag.ts +++ b/client/src/hooks/roadmap/useCreateTag.ts @@ -5,8 +5,7 @@ export const useCreateTag = () => { const [tags, setTags] = useState([]); const ref = useRef(null); - const getAddedTagText = (e: React.MouseEvent) => { - e.preventDefault(); + const getAddedTagText = () => { if (ref.current === null) return; if (ref.current.value === '') return; @@ -16,9 +15,30 @@ export const useCreateTag = () => { ref.current.value = ''; }; + const addTagByButton = (e: React.MouseEvent) => { + e.preventDefault(); + getAddedTagText(); + }; + + const addTagByEnter = (e: React.KeyboardEvent) => { + if (e.code === 'Enter') { + e.preventDefault(); + getAddedTagText(); + } + }; + const checkIsTagCountMax = () => { return tags.length < TAG_LIMIT; }; - return { tags, ref, getAddedTagText, checkIsTagCountMax }; + const deleteTag = (e: React.MouseEvent) => { + e.preventDefault(); + + const target = e.target as HTMLButtonElement; + + setTags((prev) => { + return prev.filter((tag) => tag !== target.value); + }); + }; + return { tags, ref, addTagByButton, addTagByEnter, checkIsTagCountMax, deleteTag }; };