Skip to content

Commit

Permalink
Fix shimmer card component in mine page (#1284)
Browse files Browse the repository at this point in the history
* fix: remove dev flag and related test and old UI code

* fix: change received value

* chore: change component name

* fix: change shimmer card ui

* fix: change shimmer card style and made it similar to task card
  • Loading branch information
pankajjs authored Nov 27, 2024
1 parent 8677a02 commit 406f2eb
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 4 deletions.
2 changes: 1 addition & 1 deletion __tests__/Unit/pages/Mine/Mine.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('Mine Page', () => {

await waitFor(() =>
expect(
getAllByTestId(/shimmer-card/i).length
getAllByTestId(/task-shimmer-card/i).length
).toBeGreaterThanOrEqual(1)
);
});
Expand Down
15 changes: 15 additions & 0 deletions src/components/Loaders/taskCardShimmer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styles from './taskCardShimmer.module.scss';

const TaskCardShimmer = () => (
<div className={`${styles.taskCard}`} data-testid="task-shimmer-card">
<div className={`${styles.title} ${styles.animate}`}></div>
<div className={`${styles.flexContainer}`}>
<div className={`${styles.estimated} ${styles.animate}`}></div>
<div className={`${styles.status} ${styles.animate}`}></div>
</div>
<div className={`${styles.started} ${styles.animate}`} />
<div className={`${styles.assignee} ${styles.animate}`} />
</div>
);

export default TaskCardShimmer;
79 changes: 79 additions & 0 deletions src/components/Loaders/taskCardShimmer/taskCardShimmer.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
@import '../../../styles/variables.scss';

.taskCard {
border: 2px solid $white;
box-shadow: 0px 0px 10px 0 $light-gray;
padding: 10px;
border-radius: 8px;

width: 55vw;
min-width: 300px;
min-height: 110px;

margin-bottom: 2rem;

& > * {
border-radius: 8px;
margin: 10px;
}

.title {
min-height: 25px;
width: 60%;
}

.estimated {
min-height: 25px;
width: 40%;
}

.started {
min-height: 25px;
width: 20%;
}

.status {
min-width: 25px;
width: 20%;
}

.assignee {
min-height: 25px;
width: 30%;
}
}

@keyframes fullView {
100% {
width: 100%;
}
}

.flexContainer {
display: flex;
justify-content: space-between;

& > * {
border-radius: 8px;
}
}

.animate {
animation: shimmer 2s infinite linear;
background: linear-gradient(
to right,
$shimmer-lighter 4%,
$shimmer-darker 25%,
$shimmer-lighter 36%
);
background-size: 1000px 100%;
}

@keyframes shimmer {
0% {
background-position: -1000px 0;
}
100% {
background-position: 1000px 0;
}
}
6 changes: 3 additions & 3 deletions src/pages/mine/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getActiveTab } from '@/utils/getActiveTab';
import TaskList from '@/components/tasks/TaskList/TaskList';
import getInputValueFromTaskField from '@/utils/getInputValueFromTaskField';
import getFilteredTasks from '@/utils/getFilteredTasks';
import CardShimmer from '@/components/Loaders/cardShimmer';
import TaskCardShimmer from '@/components/Loaders/taskCardShimmer';

export const searchTasks = (
setFilteredTasks: (tasks: task[]) => void,
Expand Down Expand Up @@ -57,9 +57,9 @@ const Content = () => {

if (isLoading)
return (
<div className={styles.tasksContainer}>
<div className={styles.mineTasksContainer}>
{[...Array(5)].map((n: number, index) => (
<CardShimmer key={index} />
<TaskCardShimmer key={index} />
))}
</div>
);
Expand Down

0 comments on commit 406f2eb

Please sign in to comment.