Skip to content

Commit dac79ef

Browse files
change display system menu
1 parent a833095 commit dac79ef

3 files changed

Lines changed: 69 additions & 20 deletions

File tree

frontend/src/components/DisplayTableStatisticsReact.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FC, useCallback, useMemo } from 'react';
22
import DataTable, { TableColumn, TableStyles } from 'react-data-table-component';
33
import { CSSObject } from 'styled-components';
4-
import { useAppContext } from '../core/context';
4+
import { useAppContext } from '../core/useAppContext';
55
import { reorderLabels } from '../core/utils';
66
import { MLStatisticsModel } from '../types';
77

frontend/src/pages/HomePage.tsx

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { FC } from 'react';
1+
import { marked } from 'marked';
2+
import { FC, useMemo } from 'react';
23
import { FaGithub } from 'react-icons/fa';
34
import { IoMdLogOut } from 'react-icons/io';
45
import { Link, useNavigate } from 'react-router-dom';
@@ -10,6 +11,38 @@ import { useGetActiveUsers, useGetServer } from '../core/api';
1011
import { useAuth } from '../core/useAuth';
1112
import { LoginParams } from '../types';
1213

14+
const MessageCard: FC<{ content: string; time?: string }> = ({ content, time }) => {
15+
const html = useMemo(() => {
16+
marked.setOptions({ breaks: true });
17+
return marked.parse(content) as string;
18+
}, [content]);
19+
20+
return (
21+
<div
22+
style={{
23+
background: '#f8f9fa',
24+
border: '1px solid #e9ecef',
25+
borderLeft: '4px solid #ff9a3c',
26+
borderRadius: '0.5rem',
27+
padding: '0.75rem 1rem',
28+
marginBottom: '0.75rem',
29+
textAlign: 'left',
30+
}}
31+
>
32+
<div
33+
className="message-content"
34+
style={{ fontSize: '0.9rem', color: '#333', lineHeight: '1.5' }}
35+
dangerouslySetInnerHTML={{ __html: html }}
36+
/>
37+
{time && (
38+
<div style={{ fontSize: '0.75rem', color: '#999', marginTop: '0.25rem' }}>
39+
{new Date(time).toLocaleString()}
40+
</div>
41+
)}
42+
</div>
43+
);
44+
};
45+
1346
export const HomePage: FC = () => {
1447
const { authenticatedUser, logout } = useAuth();
1548
const { n_users } = useGetActiveUsers();
@@ -127,24 +160,13 @@ export const HomePage: FC = () => {
127160
🐯 Go to your projects
128161
</Link>
129162
</div>
130-
<div style={{ maxWidth: '600px', margin: '1rem auto' }}>
131-
{(messages || []).map((msg) => (
132-
<div
133-
key={msg.id}
134-
style={{
135-
fontSize: '0.9rem',
136-
color: '#333',
137-
}}
138-
>
139-
<div style={{ color: '#777' }}>
140-
{msg.content}{' '}
141-
<span style={{ fontSize: '0.5rem' }}>
142-
{new Date(msg.time || Date.now()).toLocaleString()}
143-
</span>
144-
</div>
145-
</div>
146-
))}
147-
</div>
163+
{(messages || []).length > 0 && (
164+
<div style={{ maxWidth: '600px', margin: '1.5rem auto' }}>
165+
{(messages || []).map((msg) => (
166+
<MessageCard key={msg.id} content={msg.content} time={msg.time} />
167+
))}
168+
</div>
169+
)}
148170
</div>
149171
</div>
150172
)}

frontend/src/styles/_general.scss

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,33 @@ table {
217217
font-weight: bold;
218218
}
219219

220+
// Message cards on homepage
221+
.message-content {
222+
p {
223+
margin: 0 0 0.25rem;
224+
&:last-child {
225+
margin-bottom: 0;
226+
}
227+
}
228+
a {
229+
color: $primary;
230+
text-decoration: underline;
231+
}
232+
code {
233+
background: #e9ecef;
234+
padding: 0.1rem 0.3rem;
235+
border-radius: 3px;
236+
font-size: 0.85em;
237+
}
238+
ul, ol {
239+
margin: 0.25rem 0;
240+
padding-left: 1.5rem;
241+
}
242+
strong {
243+
font-weight: 600;
244+
}
245+
}
246+
220247
// hide internal links in MDeditor
221248
.wmde-markdown h1 a,
222249
.wmde-markdown h2 a,

0 commit comments

Comments
 (0)