Skip to content

Commit 30f0283

Browse files
authored
♻️refactor: 에디터 폰트 적용 및 메시지 카드 칸 폰트 적용 완료
♻️refactor: 에디터 폰트 적용 및 메시지 카드 칸 폰트 적용 완료
2 parents 73d462b + 5189038 commit 30f0283

File tree

8 files changed

+33
-15
lines changed

8 files changed

+33
-15
lines changed

src/components/Card/Card.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default function Card({
1212
relationship,
1313
children,
1414
createdAt,
15+
font,
1516
empty = false,
1617
}) {
1718
const navigate = useNavigate();
@@ -21,6 +22,13 @@ export default function Card({
2122
navigate(`/post/${recipientId}/message/`);
2223
}
2324

25+
const fontFamilyMap = {
26+
'Noto Sans': '"Noto Sans", sans-serif',
27+
Pretendard: '"Pretendard", sans-serif',
28+
나눔명조: '"Nanum Myeongjo", serif',
29+
'나눔손글씨 손편지체': '"Nanum Sonpyeonji Ce", cursive',
30+
};
31+
2432
return (
2533
<article className={`${styles.card} ${empty ? styles['card--empty'] : ''}`}>
2634
{empty ? (
@@ -51,7 +59,10 @@ export default function Card({
5159
</header>
5260
<div className={styles['card__body']}>
5361
<div className={styles['card__content']}>
54-
<div dangerouslySetInnerHTML={{ __html: sanitizedHTML }} />
62+
<div
63+
style={{ fontFamily: fontFamilyMap[font] }}
64+
dangerouslySetInnerHTML={{ __html: sanitizedHTML }}
65+
/>
5566
</div>
5667
</div>
5768
<footer className={styles['card__footer']}>{createdAt}</footer>

src/components/Editor/Editor.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ const formats = [
1414
'background',
1515
];
1616

17+
const fontFamilyMap = {
18+
나눔명조: '"Nanum Myeongjo", serif',
19+
'나눔손글씨 손편지체': '"Nanum Sonpyeonji Ce", cursive',
20+
Pretendard: '"Pretendard", sans-serif',
21+
'Noto Sans': '"Noto Sans", sans-serif',
22+
};
23+
1724
export default function Editor({ value, onChange, font }) {
1825
const modules = useMemo(() => {
1926
return {
@@ -30,7 +37,7 @@ export default function Editor({ value, onChange, font }) {
3037
useEffect(() => {
3138
const editorElement = document.querySelector('.ql-editor');
3239
if (editorElement) {
33-
editorElement.style.fontFamily = font;
40+
editorElement.style.fontFamily = fontFamilyMap[font];
3441
editorElement.style.fontSize = '18px';
3542
}
3643
}, [font]);

src/components/FontSelect/FontSelect.jsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@ import { useState, useRef, useId } from 'react';
22
import useDetectClose from '../../hooks/useDetectClose';
33
import styles from './FontSelect.module.scss';
44

5-
const FONTS = ['Noto Sans', 'Pretendard', 'NanumMyeongjo', 'NanumSonPyeonjiCe'];
5+
const FONTS = ['Noto Sans', 'Pretendard', '나눔명조', '나눔손글씨 손편지체'];
66

77
const fontClassMap = {
8-
NotoSans: styles['font-noto'],
8+
'Noto Sans': styles['font-noto'],
99
Pretendard: styles['font-pretendard'],
10-
NanumMyeongjo: styles['font-nanum-myeongjo'],
11-
NanumSonPyeonjiCe: styles['font-naunm-hand'],
10+
나눔명조: styles['font-nanum-myeongjo'],
11+
'나눔손글씨 손편지체': styles['font-naunm-hand'],
1212
};
1313

14-
const formatFontName = (font) =>
15-
font
16-
.replace('NanumMyeongjo', '나눔명조')
17-
.replace('NanumSonPyeonjiCe', '나눔손글씨 손편지체');
18-
1914
export default function FontSelect({ defaultValue = 'Noto Sans', onChange }) {
2015
const dropdownRef = useRef(null);
2116
const id = useId();
@@ -40,7 +35,7 @@ export default function FontSelect({ defaultValue = 'Noto Sans', onChange }) {
4035
className={`${styles['dropdown__button']} ${fontClassMap[selected]}`}
4136
onClick={() => setIsOpen((prev) => !prev)}
4237
>
43-
{formatFontName(selected)}
38+
{selected}
4439
<span
4540
className={`${styles.dropdown__arrow} ${isOpen ? styles.open : ''}`}
4641
/>
@@ -53,7 +48,7 @@ export default function FontSelect({ defaultValue = 'Noto Sans', onChange }) {
5348
className={`${styles['dropdown__item']} ${fontClassMap[font]}`}
5449
onClick={() => handleSelect(font)}
5550
>
56-
{formatFontName(font)}
51+
{font}
5752
</li>
5853
))}
5954
</ul>

src/components/common/FormInput.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function FormInput({
88
onChange,
99
onBlur,
1010
isError,
11+
maxLength,
1112
}) {
1213
const id = useId();
1314
return (
@@ -22,6 +23,7 @@ export default function FormInput({
2223
value={value}
2324
onChange={onChange}
2425
onBlur={onBlur}
26+
maxLength={maxLength}
2527
className={`${styles['form-input__input']} ${isError ? styles['form-input__input--error'] : ''}`}
2628
/>
2729
{isError && (

src/pages/CreateRecipient/CreateRecipient.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export default function CreateRecipient() {
7474
value={value}
7575
onChange={handleInputChange}
7676
onBlur={handleBlur}
77+
maxLength={40}
7778
isError={isError}
7879
/>
7980
</div>

src/pages/MessageForm/MessageForm.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ export default function MessageForm() {
8080
<div className={styles['message-form__content']}>
8181
<div className={styles['message-form__input']}>
8282
<FormInput
83-
label="Form."
83+
label="From."
8484
placeholder="이름을 입력해 주세요."
8585
value={sender}
8686
onChange={handleInputChange}
8787
onBlur={handleBlur}
88+
maxLength={40}
8889
isError={isError}
8990
/>
9091
</div>

src/pages/Recipient/Recipient.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default function Recipient() {
9393
sender={msg.sender}
9494
relationship={msg.relationship}
9595
createdAt={msg.createdAt.slice(0, 10).split('-').join('.')}
96+
font={msg.font}
9697
>
9798
{msg.content}
9899
</Card>

src/pages/RecipientList/RecipientCard.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function RecipientCard({ Recipient }) {
2626
}
2727
: {}
2828
}
29-
onClick={() => navigate(`{/post/${id}`)}
29+
onClick={() => navigate(`/post/${id}`)}
3030
>
3131
{backgroundColor === 'blue' && <div className={styles.triangle} />}
3232
<h3 className={backgroundImageURL && styles.white}>{`To. ${name}`}</h3>

0 commit comments

Comments
 (0)