Skip to content

Commit

Permalink
feat: moon loader animation (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasprima authored Mar 21, 2024
1 parent a5c7d30 commit 123a232
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"react-dom": "^18.2.0",
"react-redux": "^8.1.3",
"react-scripts": "5.0.1",
"react-spinners": "^0.13.8",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/apiSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
export const apiSlice = createApi({
// https://todolistapi-kcjj.onrender.com
reducerPath: 'api',
baseQuery: fetchBaseQuery({ baseUrl: 'http://localhost:8080' }),
baseQuery: fetchBaseQuery({ baseUrl: 'https://todolistapi-kcjj.onrender.com' }),
tagTypes: ['Todos'],
endpoints: (builder) => ({
getTodos: builder.query({
Expand Down
11 changes: 10 additions & 1 deletion src/features/todos/TodoList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faPlus, faXmark } from '@fortawesome/free-solid-svg-icons'
import { useState, useEffect, useRef } from 'react'
import MoonLoader from 'react-spinners/MoonLoader'
import {
useGetTodosQuery,
useAddTodoMutation,
Expand Down Expand Up @@ -142,7 +143,15 @@ const TodoList = () => {

let content;
if (isLoading) {
content = <p>Loading ...</p>
content = (
<div className="loader">
<MoonLoader
color="#92aafa"
loading
size={100}
/>
</div>
)
} else if (isSuccess){
let sortedTodos = todos;
if (todos.length> 1){
Expand Down
6 changes: 6 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,10 @@ input:checked + .slider:before {
::-webkit-scrollbar-thumb:hover {
background: #92aafa;
border-radius: 10px
}

.loader{
display: flex;
justify-content: center;
align-items: center;
}

0 comments on commit 123a232

Please sign in to comment.