Skip to content

Commit 4ea830f

Browse files
authored
✨ - Updates UI loading component
1 parent 6059a90 commit 4ea830f

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

__test__/_app/Loading.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, it, describe } from 'vitest'
2-
import { render, screen } from '@testing-library/react'
2+
import { render } from '@testing-library/react'
33
import Loading from '../../src/app/loading'
44

55
describe('Loading', () => {
@@ -8,7 +8,7 @@ describe('Loading', () => {
88
expect(component).toBeDefined()
99
})
1010
it('should display loading label', () => {
11-
render(<Loading />)
12-
expect(screen.getByText('Loading...')).toBeTruthy()
11+
const { container } = render(<Loading />)
12+
expect(container.getElementsByClassName('loader').length).toBe(1)
1313
})
1414
})

src/app/loading.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
export default function Loading() {
22
// You can add any UI inside Loading, including a Skeleton.
3-
return <div>Loading...</div>
3+
return (
4+
<div className='w-full h-[90vh] flex items-center justify-center'>
5+
<span className='loader'></span>
6+
</div>
7+
)
48
}

src/styles/globals.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
5+
.loader {
6+
width: 48px;
7+
height: 48px;
8+
border: 3px solid #1a1a1a;
9+
border-radius: 50%;
10+
display: inline-block;
11+
position: relative;
12+
box-sizing: border-box;
13+
animation: rotation 1s linear infinite;
14+
}
15+
16+
.loader::after {
17+
content: '';
18+
box-sizing: border-box;
19+
position: absolute;
20+
left: 50%;
21+
top: 50%;
22+
transform: translate(-50%, -50%);
23+
width: 40px;
24+
height: 40px;
25+
border-radius: 50%;
26+
border: 3px solid;
27+
border-color: #1a1a1a transparent;
28+
}
29+
30+
@keyframes rotation {
31+
0% {
32+
transform: rotate(0deg);
33+
}
34+
100% {
35+
transform: rotate(360deg);
36+
}
37+
}

0 commit comments

Comments
 (0)