Skip to content

Commit f87bfe1

Browse files
committed
feat: added loading skeleton for notes page
1 parent 6cc22ef commit f87bfe1

File tree

5 files changed

+81
-11
lines changed

5 files changed

+81
-11
lines changed

design/src/styles/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
@import './layout/cv-nav.css';
2121
@import './layout/cv-history.css';
2222
@import './layout/notes.css';
23+
@import './layout/skeleton.css';

design/src/styles/layout/skeleton.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.skeleton-loader {
2+
width: 100%;
3+
height: 15px;
4+
display: block;
5+
background: linear-gradient(
6+
to right,
7+
rgba(255, 255, 255, 0),
8+
rgba(255, 255, 255, 0.5) 50%,
9+
rgba(255, 255, 255, 0) 80%
10+
),
11+
lightgray;
12+
background-repeat: repeat-y;
13+
background-size: 50px 500px;
14+
background-position: 0 0;
15+
animation: shine 1s infinite;
16+
}
17+
18+
@keyframes shine {
19+
to {
20+
background-position: 100% 0, /* move highlight to right */ 0 0;
21+
}
22+
}

site/src/components/dynamic/Note.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export default function NoteList({ item }) {
1111

1212
return (
1313
<li class="note-list-item">
14-
<a href={`#${item.id}`} target="_blank">
15-
<h3 id={item.id}>{item.title}</h3>
16-
</a>
17-
<p class="note-list-item--time">{getFormattedDate(item.date_created)}</p>
18-
<p dangerouslySetInnerHTML={{__html: md.render(item.text)}}>
19-
</p>
20-
<hr>
21-
</hr>
22-
</li>
14+
<a href={`#${item.id}`} target="_blank">
15+
<h3 id={item.id}>{item.title}</h3>
16+
</a>
17+
<p class="note-list-item--time">{getFormattedDate(item.date_created)}</p>
18+
<p dangerouslySetInnerHTML={{__html: md.render(item.text)}}>
19+
</p>
20+
<hr>
21+
</hr>
22+
</li>
2323
);
2424
}

site/src/components/dynamic/NoteList.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { useState, useEffect } from 'preact/hooks';
22
import Note from "./Note";
3-
import markdownit from 'markdown-it';
3+
import SkeletonList from "./SkeletonList";
44
import { fetchNotes } from '../../functions/notes.func';
5-
const md = markdownit();
65

76
export default function NoteList() {
87
const [items, setItems] = useState([]);
@@ -14,6 +13,9 @@ export default function NoteList() {
1413

1514
return (
1615
<ol class="note-list">
16+
{
17+
items.length === 0 ? <SkeletonList /> : null
18+
}
1719
{
1820
items.map(item => (
1921
<Note item={item} />
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
export default function SkeletonList() {
2+
return (
3+
<>
4+
<li class="note-list-item">
5+
<h3 class="skeleton-loader" style="max-width: 300px"></h3>
6+
<p class="note-list-item--time skeleton-loader" style="max-width: 160px"></p>
7+
<p>
8+
<span class="skeleton-loader" style="margin-bottom: 4px"></span>
9+
<span class="skeleton-loader" style="margin-bottom: 4px; max-width: 92%"></span>
10+
<span class="skeleton-loader" style="margin-bottom: 4px"></span>
11+
<span class="skeleton-loader" style="margin-bottom: 4px; max-width: 93%"></span>
12+
<span class="skeleton-loader" style="margin-bottom: 4px; max-width: 72%"></span>
13+
<span class="skeleton-loader" style="margin-bottom: 4px"></span>
14+
</p>
15+
<hr></hr>
16+
</li>
17+
<li class="note-list-item">
18+
<h3 class="skeleton-loader" style="max-width: 300px"></h3>
19+
<p class="note-list-item--time skeleton-loader" style="max-width: 160px"></p>
20+
<p>
21+
<span class="skeleton-loader" style="margin-bottom: 4px"></span>
22+
<span class="skeleton-loader" style="margin-bottom: 4px; max-width: 92%"></span>
23+
<span class="skeleton-loader" style="margin-bottom: 4px"></span>
24+
<span class="skeleton-loader" style="margin-bottom: 4px; max-width: 93%"></span>
25+
<span class="skeleton-loader" style="margin-bottom: 4px; max-width: 72%"></span>
26+
<span class="skeleton-loader" style="margin-bottom: 4px"></span>
27+
</p>
28+
<hr></hr>
29+
</li>
30+
<li class="note-list-item">
31+
<h3 class="skeleton-loader" style="max-width: 300px"></h3>
32+
<p class="note-list-item--time skeleton-loader" style="max-width: 160px"></p>
33+
<p>
34+
<span class="skeleton-loader" style="margin-bottom: 4px"></span>
35+
<span class="skeleton-loader" style="margin-bottom: 4px; max-width: 92%"></span>
36+
<span class="skeleton-loader" style="margin-bottom: 4px"></span>
37+
<span class="skeleton-loader" style="margin-bottom: 4px; max-width: 93%"></span>
38+
<span class="skeleton-loader" style="margin-bottom: 4px; max-width: 72%"></span>
39+
<span class="skeleton-loader" style="margin-bottom: 4px"></span>
40+
</p>
41+
<hr></hr>
42+
</li>
43+
</>
44+
)
45+
}

0 commit comments

Comments
 (0)