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: 형광펜 모드 on/off 표시 메세지 추가 #823

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
9 changes: 9 additions & 0 deletions frontend/src/assets/grayHighlighter.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: 9 additions & 0 deletions frontend/src/assets/primaryHighlighter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions frontend/src/components/highlight/EditSwitchButton/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ interface EditorSwitchProps {
export const EditSwitchButton = styled.button<EditorSwitchProps>`
cursor: pointer;

width: 4rem;
width: 3.5rem;
height: 2rem;
padding: 0.5rem;

background-color: ${({ theme, $isEditable }) => ($isEditable ? theme.colors.primary : theme.colors.gray)};
Expand All @@ -18,8 +19,8 @@ export const EditSwitchButton = styled.button<EditorSwitchProps>`
export const Circle = styled.div<EditorSwitchProps>`
transform: translateX(${({ $isEditable }) => ($isEditable ? 0 : '1.5rem')});

width: 1.5rem;
height: 1.5rem;
width: 1rem;
height: 1rem;

background-color: ${({ theme }) => theme.colors.white};
border-radius: 50%;
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/components/highlight/HighlightEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useEffect, useRef, useState } from 'react';

import GrayHighlighterIcon from '@/assets/grayHighlighter.svg';
import PrimaryHighlighterIcon from '@/assets/primaryHighlighter.svg';
import {
EDITOR_ANSWER_CLASS_NAME,
EDITOR_LINE_CLASS_NAME,
Expand All @@ -22,6 +24,16 @@ import HighlightToggleButtonContainer from '../HighlightToggleButtonContainer';

import * as S from './style';

const MODE_ICON = {
on: {
icon: PrimaryHighlighterIcon,
alt: '형광펜 기능 켜짐',
},
off: {
icon: GrayHighlighterIcon,
alt: '형광펜 기능 꺼짐',
},
};
interface HighlightEditorProps {
questionId: number;
answerList: ReviewAnswerResponseData[];
Expand Down Expand Up @@ -94,6 +106,11 @@ const HighlightEditor = ({ questionId, answerList }: HighlightEditorProps) => {
return (
<div ref={editorRef} style={{ position: 'relative' }}>
<S.SwitchButtonWrapper>
<S.HighlightText $isEditable={isEditable}>형광펜</S.HighlightText>
<S.SwitchModIcon
src={MODE_ICON[isEditable ? 'on' : 'off'].icon}
alt={MODE_ICON[isEditable ? 'on' : 'off'].alt}
/>
<EditSwitchButton isEditable={isEditable} handleEditToggleButton={handleEditToggleButton} />
</S.SwitchButtonWrapper>
{[...editorAnswerMap.values()].map(({ answerId, answerIndex, lineList }) => (
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/components/highlight/HighlightEditor/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@ import styled from '@emotion/styled';

export const SwitchButtonWrapper = styled.div`
display: flex;
gap: 0.5rem;
align-items: center;
justify-content: end;

width: 100%;
margin-bottom: 1rem;
`;

export const SwitchModIcon = styled.img`
width: 1.6rem;
height: 1.6rem;
`;

export const HighlightText = styled.span<{ $isEditable: boolean }>`
display: inline-block;
color: ${({ $isEditable, theme }) => ($isEditable ? theme.colors.primary : theme.colors.gray)};
`;