Skip to content

Commit

Permalink
🚸 add feedback for refreshing notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ulisesantana committed Aug 31, 2023
1 parent 9588f76 commit b473cce
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/views/PendingNotesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Props {
}

export const PendingNotesView: FC<Props> = ({notes, onCreateNote, onSearchNote, onRefreshNotes}) => {
const [isLoading, setIsLoading] = useState(false)
const [items, setItems] = useState(notes)
const generateOnClick: (n: string) => MouseEventHandler<HTMLAnchorElement> = (note: string) => (event) => {
onCreateNote(note, event.nativeEvent).then(setItems)
Expand All @@ -18,13 +19,21 @@ export const PendingNotesView: FC<Props> = ({notes, onCreateNote, onSearchNote,
onSearchNote(title).then()
}
const refreshNotes = () => {
onRefreshNotes().then(setItems)
setIsLoading(true)
onRefreshNotes().then((notes) => {
setTimeout(() => {
setIsLoading(false)
setItems(notes)
}, 1000)
})
}
return (
<div className="pending-notes-view-container">
<div className="title">
<h1>Pending notes</h1>
<button onClick={refreshNotes}>🔄</button>
<button onClick={refreshNotes}>
{isLoading ? <div className="dots"></div> : "🔄"}
</button>
</div>
<span><strong>{items.length}</strong> notes linked, but not created yet. Times the note is linked is shown in parentheses.</span>
<ul>
Expand Down
93 changes: 93 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,97 @@
}


.dots {
position: relative;
width: 20px;
height: 20px;
font-size: 10px;
line-height: 10px;
display: flex;
align-items: center;
justify-content: center;
color: white;
}

.dots:after {
position: absolute;
content: "";
color: white;
-webkit-animation: display-dots steps(1, end) 1s infinite;
-moz-animation: display-dots steps(1, end) 1s infinite;
-o-animation: display-dots steps(1, end) 1s infinite;
animation: display-dots steps(1, end) 1s infinite;
}

@-webkit-keyframes display-dots {
0% {
content: "";
}
25% {
content: "\2022\00A0\2022\00A0\2022";
}
50% {
content: "\2022\00A0\2022";
}
75% {
content: "\2022";
}
100% {
content: "";
}
}
@-moz-keyframes display-dots {
0% {
content: "";
}
25% {
content: "\2022";
}
50% {
content: "\2022\00A0\2022";
}
75% {
content: "\2022\00A0\2022\00A0\2022";
}
100% {
content: "";
}
}
@-o-keyframes display-dots {
0% {
content: "";
}
25% {
content: "\2022";
}
50% {
content: "\2022\00A0\2022";
}
75% {
content: "\2022\00A0\2022\00A0\2022";
}
100% {
content: "";
}
}
@keyframes display-dots {
0% {
content: "";
}
25% {
content: "\2022";
}
50% {
content: "\2022\00A0\2022";
}
75% {
content: "\2022\00A0\2022\00A0\2022";
}
100% {
content: "";
}
}




0 comments on commit b473cce

Please sign in to comment.