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] feat: 형광펜 메뉴 및 툴팁 구현 #874

Merged
merged 39 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
68438f6
refactor: line 관련 변수명 변경 (blockElement -> lineElement)
BadaHertz52 Oct 18, 2024
a0b692a
feat: HighlightMenu 컴포넌트 훅 생성 및 기존 관련 코드 변경
BadaHertz52 Oct 18, 2024
04f04fb
fix: 하이라이트 적용과 미적용 같이 있을 때, isForwardDrag 값 오류 수정
BadaHertz52 Oct 18, 2024
462bb03
refactor: 하이라이트 메뉴 사이즈 관련 변수 수정
BadaHertz52 Oct 18, 2024
d817bdd
design: 하이라이트 메뉴 버튼 스타일 변경 (사이즈 조정 및 hover시 배경색 변경)
BadaHertz52 Oct 18, 2024
f97f414
fix: 모아보기 페이지- 주관식 답변 개행에도 li marker 표시되는 오류 수정
BadaHertz52 Oct 18, 2024
77f76c2
refactor: 하이라이트 메뉴 위치 초기화하는 함수명 변경
BadaHertz52 Oct 18, 2024
973daf0
fix: 길게 눌렀을 때 삭제되는 버튼 안 뜨는 오류 수정 및 상태명 변경
BadaHertz52 Oct 18, 2024
9eb233e
feat: 형광펜 기능 알려주는 툴팁 구현
BadaHertz52 Oct 18, 2024
461f270
chore: 불필요한 콘솔 삭제
BadaHertz52 Oct 18, 2024
c1e8346
fix: useMutateHighlight 테스트 오류 수정
BadaHertz52 Oct 18, 2024
6228290
design: 형광펜 스위치 버튼 디자인 수정
BadaHertz52 Oct 18, 2024
52ca34e
fix: 리뷰 모아보기 데이터 타입 차이로 인한, 형광펜 적용 안되는 오류 수정
BadaHertz52 Oct 19, 2024
cd6d8ec
design: EditorLineBlock 스타일 컴포넌트 삭제
BadaHertz52 Oct 19, 2024
1ba7d4b
chore: 리뷰 모아보기 목 데이터 변경(형광펜 적용 추가)
BadaHertz52 Oct 19, 2024
e92c960
chore: 불필요한 코드 삭제
BadaHertz52 Oct 19, 2024
a0bc79a
feat: 리뷰 모아보기- 주관식 답변 Dot 선택되지 않게 처리 및 UndraggableWrapper에 min-width 적용
BadaHertz52 Oct 20, 2024
ff817ba
feat: 형광펜 메뉴 위치 - 에디터 상단 넘는지 확인하는 기능 추가
BadaHertz52 Oct 20, 2024
067de8d
design: 툴팁 그림자, 문자 졍렬 변경
BadaHertz52 Oct 20, 2024
54a3be7
chore: 주석처리 제거
BadaHertz52 Oct 20, 2024
cebd3da
chore: sr-only 삭제
BadaHertz52 Oct 20, 2024
1447d44
chore: 답변 항목 구문자 alt 빈문자열로 변경
BadaHertz52 Oct 20, 2024
693e38a
design: 그림자 폭 수정
BadaHertz52 Oct 20, 2024
178f3f6
fix:span 자동 줄넘김 오류 수정
BadaHertz52 Oct 20, 2024
04d1129
fix : list 마크와 답변 정렬 안되는 오류 수정 및 마크 이미지 삭제
BadaHertz52 Oct 20, 2024
733e4bc
chore: 불필요한 콘솔 삭제
BadaHertz52 Oct 20, 2024
aab8168
refactor: block -> line으로 변경
BadaHertz52 Oct 20, 2024
465b5bc
fix: 형광펜 더하기 시, endIndex 오류 수정
BadaHertz52 Oct 20, 2024
e36b1ae
docs: 리뷰 모아보기 페이지 하이라이트 목 데이터 변경
BadaHertz52 Oct 20, 2024
8829c36
style: Syntax에 prettier 적용
BadaHertz52 Oct 20, 2024
6a1f189
fix: 글자의 마지막에만 형광펜 칠해지지 않는 오류 수정
BadaHertz52 Oct 20, 2024
83e0473
fix: 형광펜 있는 영역을 포함한 여러 답변에서 형광펜 더할 때 offset 오류 수정
BadaHertz52 Oct 20, 2024
e133509
refactor: block -> line으로 변경
BadaHertz52 Oct 20, 2024
5127a70
chore: 하이라이트 목 핸들러 필요 없는 response 삭제
BadaHertz52 Oct 20, 2024
7af6617
fix: 하이라이트 API오류 시, fallback 실행으로 isEditable 세션스토리지 값 삭제되는 오류 수정
BadaHertz52 Oct 20, 2024
043d35b
chore: 불필요한 타입(Highlight 삭제)
BadaHertz52 Oct 21, 2024
b124bbc
fix: 같은 답변 다른 줄, 드래그 방향 오류 수정
BadaHertz52 Oct 21, 2024
2842694
Merge branch 'develop' of https://github.com/woowacourse-teams/2024-r…
BadaHertz52 Oct 21, 2024
ec4db4e
fix: 같은 답변 다른 줄 드래그 방향 계산 오류 수정
BadaHertz52 Oct 21, 2024
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
9 changes: 9 additions & 0 deletions frontend/src/assets/dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions frontend/src/assets/grayHighlighter.svg

This file was deleted.

9 changes: 9 additions & 0 deletions frontend/src/assets/helper.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions frontend/src/assets/primaryHighlighter.svg

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const EditSwitchButton = styled.button<EditorSwitchProps>`
`;

export const Circle = styled.div<EditorSwitchProps>`
transform: translateX(${({ $isEditable }) => ($isEditable ? 0 : '1.5rem')});
transform: translateX(${({ $isEditable }) => ($isEditable ? '1.5rem' : 0)});

width: 1rem;
height: 1rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { EDITOR_LINE_CLASS_NAME } from '@/constants';
import { EditorLine, HighlightRange } from '@/types';

import Syntax from '../Syntax';

import * as S from './style';

interface EditorLineBlockProps {
line: EditorLine;
lineIndex: number;
Expand Down Expand Up @@ -62,9 +59,9 @@ const EditorLineBlock = ({ line, lineIndex }: EditorLineBlockProps) => {
};

return (
<S.EditorLineBlock className={EDITOR_LINE_CLASS_NAME} data-index={lineIndex}>
<p className={EDITOR_LINE_CLASS_NAME} data-index={lineIndex}>
{renderSentenceList()}
</S.EditorLineBlock>
</p>
);
};

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,49 +1,30 @@
import EraserIcon from '@/assets/eraser.svg';
import HighlighterIcon from '@/assets/highlighter.svg';
import TrashIcon from '@/assets/trash.svg';
import {
HIGHLIGHT__TOGGLE_BUTTON_CLASS_NAME,
HIGHLIGHT_BUTTON_SIZE,
HIGHLIGHT_REMOVER_CLASS_NAME,
SR_ONLY,
} from '@/constants';
import { Position } from '@/types';
import { SR_ONLY } from '@/constants';

import * as S from './style';

interface DragHighlightAddButtonProps {
position: Position;
addHighlightByDrag: () => void;
}

const DragHighlightAddButton = ({ addHighlightByDrag, position }: DragHighlightAddButtonProps) => {
const DragHighlightAddButton = ({ addHighlightByDrag }: DragHighlightAddButtonProps) => {
return (
<S.Button
className={HIGHLIGHT__TOGGLE_BUTTON_CLASS_NAME}
onClick={addHighlightByDrag}
$position={position}
$width={HIGHLIGHT_BUTTON_SIZE.width.buttonWidthColor}
>
<S.Button onClick={addHighlightByDrag}>
<span className={SR_ONLY}>하이라이트 추가 버튼</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

뒷북이지만 😅 aria-label 등을 사용하는 대신 SR_ONLY 클래스를 별도로 설정한 이유가 궁금해용

Copy link
Contributor Author

Choose a reason for hiding this comment

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

당시에 접근성에 대한 합의가 이루어지지 않고 구조상 해당 버튼에 대한 설명이 안에 들어있는게 좋지 않나 생각했어서, 별로도 관리하는 방향으로 진행했어요.
지금은 aria-label만으로 충분하다고 생각해 이를 사용하는 것으로 변경되었어요.

<S.ButtonIcon src={HighlighterIcon} alt="" />
<S.Color aria-label="하이라이트 색상" />
</S.Button>
);
};

interface DragHighlightRemoveButtonProps {
removeHighlightByDrag: () => void;
position: Position;
}

const DragHighlightRemoveButton = ({ removeHighlightByDrag, position }: DragHighlightRemoveButtonProps) => {
const DragHighlightRemoveButton = ({ removeHighlightByDrag }: DragHighlightRemoveButtonProps) => {
return (
<S.Button
className={HIGHLIGHT__TOGGLE_BUTTON_CLASS_NAME}
onClick={removeHighlightByDrag}
$position={position}
$width={HIGHLIGHT_BUTTON_SIZE.width.basic}
>
<S.Button onClick={removeHighlightByDrag}>
<span className={SR_ONLY}>하이라이트 삭제 버튼</span>
<S.ButtonIcon src={EraserIcon} alt="" />
</S.Button>
Expand All @@ -52,20 +33,11 @@ const DragHighlightRemoveButton = ({ removeHighlightByDrag, position }: DragHigh

interface LongPressHighlightRemoveButtonProps {
removeHighlightByLongPress: () => void;
position: Position;
}

const LongPressHighlightRemoveButton = ({
removeHighlightByLongPress,
position,
}: LongPressHighlightRemoveButtonProps) => {
const LongPressHighlightRemoveButton = ({ removeHighlightByLongPress }: LongPressHighlightRemoveButtonProps) => {
return (
<S.Button
className={HIGHLIGHT_REMOVER_CLASS_NAME}
onClick={removeHighlightByLongPress}
$position={position}
$width={HIGHLIGHT_BUTTON_SIZE.width.basic}
>
<S.Button onClick={removeHighlightByLongPress}>
<span className={SR_ONLY}>하이라이트 삭제 버튼</span>
<S.ButtonIcon src={TrashIcon} alt="" />
</S.Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
import styled from '@emotion/styled';

import { HIGHLIGHT_BUTTON_SIZE } from '@/constants';
import { Position } from '@/types';

export const Button = styled.button<{ $position: Position; $width: number }>`
position: absolute;
top: ${(props) => props.$position.top};
left: ${(props) => props.$position.left};
import { HIGHLIGHT_BUTTON_WIDTH } from '@/constants';

export const Button = styled.button`
display: flex;
gap: 0.8rem;
align-items: center;
justify-content: center;

width: ${(props) => `${props.$width / 10}rem`};
height: ${() => `${HIGHLIGHT_BUTTON_SIZE.height / 10}rem`};
padding: 0.5rem 0.8rem;
width: ${`${HIGHLIGHT_BUTTON_WIDTH / 10}rem`};
padding: 0.5rem;

background-color: ${({ theme }) => theme.colors.white};
border-radius: ${({ theme }) => theme.borderRadius.basic};
-webkit-box-shadow: 0 0 ${() => `${HIGHLIGHT_BUTTON_SIZE.shadow / 10}rem`} -0.2rem #343434b8;
box-shadow: 0 0 ${() => `${HIGHLIGHT_BUTTON_SIZE.shadow / 10}rem`} -0.2rem #343434b8;

&:hover {
background-color: ${({ theme }) => theme.colors.palePurple};
background-color: ${({ theme }) => theme.colors.lightPurple};
}
`;

export const ButtonIcon = styled.img`
width: 1.5rem;
height: 1.5rem;
`;

export const Color = styled.div`
width: 1.5rem;
height: 1.5rem;
background-color: ${({ theme }) => theme.colors.primary};
border-radius: 50%;
width: 1.6rem;
height: 1.6rem;
`;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { default as useHighlight } from './useHighlight';
export { default as useDragHighlightButtonPosition } from './useDragHighlightButtonPosition';
export { default as useDragHighlightButtonPosition } from './useDragHighlightPosition';
export { default as useCheckHighlight } from './useCheckHighlight';
export { default as useLongPressHighlightButtonPosition } from './useLongPressHighlightButtonPosition';
export { default as useLongPressHighlightButtonPosition } from './useLongPressHighlightPosition';
export { default as useLongPress } from './useLongPress';
export { default as useMutateHighlight } from './useMutateHighlight';
export { default as useEditableState } from './useEditableState';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@ import { useState } from 'react';
import { HIGHLIGHT_SPAN_CLASS_NAME, SYNTAX_BASIC_CLASS_NAME } from '@/constants';
import { SelectionInfo } from '@/utils';

export type HighlightArea = 'full' | 'partial' | 'none';

const useCheckHighlight = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

이 훅이 단순히 형광펜이 쳐진 영역을 리턴하는 게 아니라 형광펜이 쳐진 영역의 범위를 체크하는 훅이라, 이름에 부가적으로 Range 같은 정보가 들어가면 좋겠...지만 지금도 이해하는 데 어려움은 없습니다ㅎㅎ

const [isAddingHighlight, setIsAddingHighlight] = useState(false);
const [highlightArea, setHighlightArea] = useState<HighlightArea>('none');

const checkHighlight = (info: SelectionInfo) => {
const selectedAllSpanList = getAllSpanInSelection(info.selection);
const isNoneHighlight = selectedAllSpanList.some((span) => !span.classList.contains(HIGHLIGHT_SPAN_CLASS_NAME));
let highlightedSpanLength = 0;

selectedAllSpanList.forEach((span) => {
if (span.classList.contains(HIGHLIGHT_SPAN_CLASS_NAME)) highlightedSpanLength += 1;
});

const newHighlightArea: HighlightArea = highlightedSpanLength
? selectedAllSpanList.length === highlightedSpanLength
? 'full'
: 'partial'
: 'none';

setIsAddingHighlight(isNoneHighlight);
setHighlightArea(newHighlightArea);

return isNoneHighlight;
return newHighlightArea;
};

const getAllSpanInSelection = (selection: Selection) => {
Expand All @@ -23,7 +35,7 @@ const useCheckHighlight = () => {
};

return {
isAddingHighlight,
highlightArea,
checkHighlight,
};
};
Expand Down
Loading