Added the Article Detail component
This commit is contained in:
parent
95a3f100a3
commit
05a5d41574
@ -3,6 +3,7 @@ import './App.css'
|
||||
import Header from './components/Header'
|
||||
import SearchBar from './components/SearchBar'
|
||||
import ArticleList from './components/ArticleList'
|
||||
import ArticleDetail from './components/ArticleDetail'
|
||||
|
||||
function App() {
|
||||
const [currentView, setCurrentView] = useState('list');
|
||||
@ -49,7 +50,7 @@ function App() {
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{/*<ArticleDetail article={selectedArticle} onBack={handleBack} />*/}
|
||||
<ArticleDetail article={selectedArticle} onBack={handleBack} />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
35
client/kb-frontend/src/components/ArticleDetail.css
Normal file
35
client/kb-frontend/src/components/ArticleDetail.css
Normal file
@ -0,0 +1,35 @@
|
||||
.article-detail {
|
||||
padding: 2rem;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.back-button {
|
||||
background: none;
|
||||
border: 1px solid #333;
|
||||
padding: 0.5rem 1rem;
|
||||
cursor: pointer;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.back-button:hover {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.ka-number {
|
||||
background-color: #3498db;
|
||||
color: white;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.article-meta {
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.article-content {
|
||||
margin-top: 2rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
import './ArticleDetail.css'
|
||||
|
||||
function ArticleDetail({ article, onBack }) {
|
||||
if (!article) {
|
||||
return <div>No article selected</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='article-detail'>
|
||||
<button className='back-button' onClick={onBack}>
|
||||
← Back
|
||||
</button>
|
||||
|
||||
<div className='article-header'>
|
||||
<span className='ka-number'>{article.ka_number}</span>
|
||||
<h1>{article.title}</h1>
|
||||
<p className='article-meta'>
|
||||
Created: {new Date(article.created_at).toLocaleDateString()}
|
||||
{article.updated_at && ` | Updated: ${new Date(article.updated_at).toLocaleDateString()}`}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className='article-content'
|
||||
dangerouslySetInnerHTML={{ __html: article.content }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ArticleDetail
|
||||
Loading…
x
Reference in New Issue
Block a user