Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] fix: 꿀조합 이름, 닉네임 글자수 제한 #625

Merged
merged 5 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* tslint:disable */

/**
* Mock Service Worker (1.2.3).
* Mock Service Worker (1.3.0).
* @see https://github.com/mswjs/msw
* - Please do NOT modify this file.
* - Please do NOT serve this file on production.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Heading, Spacing, Text, useTheme } from '@fun-eat/design-system';
import type { ChangeEventHandler } from 'react';
import styled from 'styled-components';

import { Input } from '@/components/Common';

const MIN_LENGTH = 1;
const MAX_LENGTH = 10;

interface MemberModifyInputProps {
nickname: string;
modifyNickname: ChangeEventHandler<HTMLInputElement>;
}

const MemberModifyInput = ({ nickname, modifyNickname }: MemberModifyInputProps) => {
const theme = useTheme();

return (
<MemberModifyInputContainer>
<Heading as="h2" size="xl" tabIndex={0}>
닉네임
</Heading>
<NicknameStatusText color={theme.textColors.info} tabIndex={0}>
{nickname.length} / {MAX_LENGTH}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'자'를 추가해주실 수 있나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

옙!

</NicknameStatusText>
<Spacing size={12} />
<Input
value={nickname}
customWidth="100%"
onChange={modifyNickname}
minLength={MIN_LENGTH}
maxLength={MAX_LENGTH}
/>
</MemberModifyInputContainer>
);
};

export default MemberModifyInput;

const MemberModifyInputContainer = styled.div`
position: relative;
`;

const NicknameStatusText = styled(Text)`
position: absolute;
top: 0;
right: 0;
`;
Comment on lines +40 to +48
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flex box 를 쓸 수도 있을 것 같은데 왜 position으로 했나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title을 따로 두고 싶었습니다!
container -> div -> h2보다 container -> h2 느낌??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아! 하!

1 change: 1 addition & 0 deletions frontend/src/components/Members/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as MembersInfo } from './MembersInfo/MembersInfo';
export { default as MemberReviewList } from './MemberReviewList/MemberReviewList';
export { default as MemberRecipeList } from './MemberRecipeList/MemberRecipeList';
export { default as MemberModifyInput } from './MemberModifyInput/MemberModifyInput';
32 changes: 28 additions & 4 deletions frontend/src/components/Recipe/RecipeNameInput/RecipeNameInput.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,59 @@
import { Heading, Spacing } from '@fun-eat/design-system';
import { Heading, Spacing, Text, useTheme } from '@fun-eat/design-system';
import type { ChangeEventHandler } from 'react';
import styled from 'styled-components';

import { Input } from '@/components/Common';
import { useRecipeFormActionContext } from '@/hooks/context';

const MIN_LENGTH = 1;
const MAX_LENGTH = 15;
interface RecipeNameInputProps {
recipeName: string;
}

const RecipeNameInput = ({ recipeName }: RecipeNameInputProps) => {
const { handleRecipeFormValue } = useRecipeFormActionContext();
const theme = useTheme();

const handleRecipeName: ChangeEventHandler<HTMLInputElement> = (e) => {
handleRecipeFormValue({ target: 'title', value: e.currentTarget.value });
};

return (
<>
<RecipeNameInputContainer>
<Heading as="h2" size="xl" tabIndex={0}>
꿀조합 이름
<RequiredMark aria-label="필수 작성">*</RequiredMark>
</Heading>
<RecipeNameStatusText color={theme.textColors.info} tabIndex={0}>
{recipeName.length} / {MAX_LENGTH}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 '자'를 추가해주세요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

옙!

</RecipeNameStatusText>
<Spacing size={12} />
<Input placeholder="재치있는 이름을 지어주세요!" value={recipeName} onChange={handleRecipeName} />
</>
<Input
placeholder="재치있는 이름을 지어주세요!"
value={recipeName}
onChange={handleRecipeName}
minLength={MIN_LENGTH}
maxLength={MAX_LENGTH}
/>
</RecipeNameInputContainer>
);
};

export default RecipeNameInput;

const RecipeNameInputContainer = styled.div`
position: relative;
width: 300px;
`;

const RequiredMark = styled.sup`
color: ${({ theme }) => theme.colors.error};
`;

const RecipeNameStatusText = styled(Text)`
position: absolute;
top: 0;
right: 0;
line-height: 28px;
`;
11 changes: 4 additions & 7 deletions frontend/src/pages/MemberModifyPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Button, Heading, Spacing } from '@fun-eat/design-system';
import { Button, Spacing } from '@fun-eat/design-system';
import type { ChangeEventHandler, FormEventHandler } from 'react';
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import styled from 'styled-components';

import { Input, SectionTitle, SvgIcon } from '@/components/Common';
import { SectionTitle, SvgIcon } from '@/components/Common';
import { MemberModifyInput } from '@/components/Members';
import { IMAGE_MAX_SIZE } from '@/constants';
import { useFormData, useImageUploader } from '@/hooks/common';
import { useMemberModifyMutation, useMemberQuery } from '@/hooks/queries/members';
Expand Down Expand Up @@ -85,11 +86,7 @@ const MemberModifyPage = () => {
</MemberImageUploaderWrapper>
</MemberImageUploaderContainer>
<Spacing size={44} />
<Heading as="h2" size="xl" tabIndex={0}>
닉네임
</Heading>
<Spacing size={12} />
<Input value={nickname} customWidth="100%" onChange={modifyNickname} />
<MemberModifyInput nickname={nickname} modifyNickname={modifyNickname} />
</div>
<FormButton customWidth="100%" customHeight="60px" size="xl" weight="bold">
수정하기
Expand Down