design: createArticle 버튼추가, 구조 변경

This commit is contained in:
정기영 2024-07-23 12:40:13 +09:00
parent d2b421cea8
commit 2a7b8a475a
2 changed files with 34 additions and 24 deletions

View File

@ -1,8 +1,10 @@
import { useState } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import styles from './CreateArticle.module.css';
import EditIcon from '/src/assets/icons/edit.svg?react';
import BackIcon from '/src/assets/icons/back.svg?react';
export default function CreateArticle({ topic, title, backPath = '/' }) {
export default function CreateArticle({ topic, title }) {
const navigate = useNavigate();
const [articleTitle, setArticleTitle] = useState('');
@ -12,29 +14,25 @@ export default function CreateArticle({ topic, title, backPath = '/' }) {
e.preventDefault();
// TODO:
if (articleTitle && articleContent) {
navigate(backPath);
navigate('..');
}
};
// TODO: textarea
const handleInput = (e) => {
setArticleContent(e.target.value);
//
e.target.style.height = 'auto';
e.target.style.height = e.target.scrollHeight + 'px';
};
return (
<div className={styles.createArticle}>
<header>
<div>
<Link
to={backPath}
className={styles.backButton}
>
<div>-</div>
<div className={styles.backText}>{title}</div>
</Link>
</div>
<header className={styles.header}>
<Link
to={'..'}
className={styles.goBack}
>
<BackIcon />
<span>{title}</span>
</Link>
<div className={styles.title}>{topic}</div>
</header>
<form
@ -66,7 +64,7 @@ export default function CreateArticle({ topic, title, backPath = '/' }) {
onClick={handleSubmit}
disabled={!articleTitle || !articleContent}
>
<div>i</div>
<EditIcon className={styles.icon} />
<div> 쓰기</div>
</button>
</form>

View File

@ -2,18 +2,22 @@
width: 100%;
}
.backButton {
.header {
display: flex;
color: var(--text-color-secondary);
flex-wrap: nowrap;
line-height: 1.2;
font-weight: 400;
font-size: 20px;
padding-bottom: 8px;
flex-direction: column;
align-items: start;
gap: 8px;
}
.backText {
padding-left: 4px;
.goBack {
display: flex;
align-items: center;
gap: 4px;
font-size: 20px;
line-height: 1.2;
font-weight: 400;
color: var(--text-color-secondary);
stroke: var(--text-color-secondary);
}
.title {
@ -85,6 +89,7 @@
line-height: 1.4;
font-weight: 700;
align-self: end;
align-items: center;
border-radius: 8px;
cursor: pointer;
transition:
@ -93,10 +98,17 @@
color 0.25s;
}
.icon {
stroke: var(--on-primary);
}
.button:disabled,
.button[disabled] {
border-color: var(--border-color);
background-color: var(--background-tertiary);
color: var(--text-color-tertiary);
cursor: not-allowed;
.icon {
stroke: var(--text-color-tertiary);
}
}