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] refactor: 리뷰 폼 웹 접근성 개선 #11

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion frontend/src/components/Recipe/CommentForm/CommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ const Form = styled.form`
const CommentTextarea = styled(Textarea)`
height: 50px;
padding: 8px;
font-size: 1.4rem;
`;

const SubmitButton = styled(Button)`
Expand Down
24 changes: 1 addition & 23 deletions frontend/src/components/Review/ReviewTagList/ReviewTagList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ import styled from 'styled-components';

import ReviewTagItem from '../ReviewTagItem/ReviewTagItem';

import { SvgIcon } from '@/components/Common';
import { MIN_DISPLAYED_TAGS_LENGTH, TAG_TITLE } from '@/constants';
import { useReviewTagsQuery } from '@/hooks/queries/review';
import { useDisplayTag } from '@/hooks/review';

interface ReviewTagListProps {
selectedTags: number[];
}

const ReviewTagList = ({ selectedTags }: ReviewTagListProps) => {
const { data: tagsData } = useReviewTagsQuery();
const { minDisplayedTags, canShowMore, showMoreTags } = useDisplayTag(tagsData, MIN_DISPLAYED_TAGS_LENGTH);

return (
<ReviewTagListContainer>
Expand All @@ -31,7 +28,7 @@ const ReviewTagList = ({ selectedTags }: ReviewTagListProps) => {
</TagTitle>
<Spacing size={20} />
<ul>
{tags.slice(0, minDisplayedTags).map(({ id, name }) => (
{tags.map(({ id, name }) => (
<>
<li key={id}>
<ReviewTagItem id={id} name={name} variant={tagType} isSelected={selectedTags.includes(id)} />
Expand All @@ -43,20 +40,6 @@ const ReviewTagList = ({ selectedTags }: ReviewTagListProps) => {
</TagItemWrapper>
))}
</TagListWrapper>
<Spacing size={26} />
{canShowMore && (
<Button
type="button"
customHeight="fit-content"
variant="transparent"
onClick={showMoreTags}
aria-label="태그 더보기"
>
<SvgWrapper>
<SvgIcon variant="arrow" width={15} />
</SvgWrapper>
</Button>
)}
</ReviewTagListContainer>
);
};
Expand Down Expand Up @@ -107,8 +90,3 @@ const TagItemWrapper = styled.div`
const TagTitle = styled(Heading)`
text-align: center;
`;

const SvgWrapper = styled.span`
display: inline-block;
transform: rotate(270deg);
`;
3 changes: 3 additions & 0 deletions frontend/src/contexts/ReviewFormContext.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useToastActionContext } from '@fun-eat/design-system';
import type { PropsWithChildren } from 'react';
import { createContext, useState } from 'react';

Expand Down Expand Up @@ -27,13 +28,15 @@ export const ReviewFormActionContext = createContext<ReviewFormAction | null>(nu

const ReviewFormProvider = ({ children }: PropsWithChildren) => {
const [reviewFormValue, setReviewFormValue] = useState(initialReviewFormValue);
const { toast } = useToastActionContext();

const handleReviewFormValue = ({ target, value, isSelected }: ReviewFormActionParams) => {
setReviewFormValue((prev) => {
const targetValue = prev[target];

if (Array.isArray(targetValue)) {
if (targetValue.length >= MIN_DISPLAYED_TAGS_LENGTH && !isSelected) {
toast.success(`태그는 ${MIN_DISPLAYED_TAGS_LENGTH}개까지 선택할 수 있습니다`);
return prev;
}

Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/review/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as useDisplayTag } from './useDisplayTag';
export { default as useStarRatingHover } from './useStarRatingHover';
21 changes: 0 additions & 21 deletions frontend/src/hooks/review/useDisplayTag.ts

This file was deleted.