-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from manh-t/feature/10-ui-shimmer-loading-on-d…
…ashboard [#10] [UI] As a user, I can see the shimmer loading on Dashboard page
- Loading branch information
Showing
8 changed files
with
144 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
|
||
import { render, screen } from '@testing-library/react'; | ||
|
||
import DashboardContent, { dashboardDataTestIds } from '.'; | ||
|
||
describe('DashboardContent', () => { | ||
it('renders DashboardContent and its components', () => { | ||
render(<DashboardContent />); | ||
|
||
const dashboardContent = screen.getByTestId(dashboardDataTestIds.content); | ||
|
||
expect(dashboardContent).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
|
||
import Shimmer from 'components/Shimmer'; | ||
|
||
export const dashboardDataTestIds = { | ||
content: 'dashboard__content', | ||
}; | ||
|
||
const DashboardContent = (): JSX.Element => { | ||
return ( | ||
<div className="flex flex-col w-full" data-test-id={dashboardDataTestIds.content}> | ||
<Shimmer classAttributes="h-[302px] rounded-[12px]" /> | ||
<div className="flex flex-row justify-between mt-[38px]"> | ||
<div className="flex flex-col justify-between"> | ||
<Shimmer classAttributes="w-[318px] h-[18px] rounded-[14px]" /> | ||
<Shimmer classAttributes="w-[212px] h-[18px] rounded-[14px]" /> | ||
</div> | ||
<Shimmer classAttributes="w-[56px] h-[56px] rounded-full" /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DashboardContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
|
||
import { render, screen } from '@testing-library/react'; | ||
|
||
import Shimmer, { shimmerDataTestIds } from '.'; | ||
|
||
describe('Shimmer', () => { | ||
it('renders Shimmer and its components', () => { | ||
const testClass = 'test-class'; | ||
render(<Shimmer classAttributes={testClass} />); | ||
|
||
const shimmer = screen.getByTestId(shimmerDataTestIds.content); | ||
|
||
expect(shimmer).toBeVisible(); | ||
expect(shimmer).toHaveClass(testClass); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
|
||
import classNames from 'classnames'; | ||
|
||
interface ShimmerProps { | ||
classAttributes: string; | ||
} | ||
|
||
export const shimmerDataTestIds = { | ||
content: 'shimmer__content', | ||
}; | ||
|
||
// Ref: https://delba.dev/blog/animated-loading-skeletons-with-tailwind | ||
const Shimmer = ({ classAttributes }: ShimmerProps): JSX.Element => { | ||
const DEFAULT_CLASSNAME_ATTRIBUTES = | ||
'relative before:absolute before:inset-0 before:-translate-x-full before:animate-[shimmer_2s_infinite] before:bg-gradient-to-r before:from-transparent before:from-30% before:via-white/50 before:to-transparent before:to-70% isolate overflow-hidden shadow-xl shadow-black/5'; | ||
return ( | ||
<div className={classNames(DEFAULT_CLASSNAME_ATTRIBUTES, classAttributes)} data-test-id={shimmerDataTestIds.content}> | ||
<div className={classNames('bg-white bg-opacity-[.12]', classAttributes)}></div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Shimmer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters