-
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.
* add event on the button for animation * get the scroll from the window * update the steps context * add keyframe to the cards * add animation to the justCompletedTask * refactor style and progress animation logic #33 Co-authored-by: Ahmed Shatat <a.shatat@hotmail.com>
- Loading branch information
Showing
10 changed files
with
165 additions
and
98 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 |
---|---|---|
@@ -1,72 +1,83 @@ | ||
import { forwardRef } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import * as S from './style'; | ||
import * as T from '../Typography'; | ||
import Icon from '../Icon'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
const Card = ({ | ||
variant = 'primary', | ||
direction = 'right', | ||
content, | ||
children, | ||
title, | ||
isCompleted, | ||
to = '/', | ||
...props | ||
}) => { | ||
const bgColor = `${variant}Light`; | ||
const borderColor = `${variant}Mid`; | ||
const circleColor = `${variant}Main`; | ||
const renderChild = () => { | ||
if (isCompleted) { | ||
return ( | ||
<> | ||
<Icon icon="tick" color="white" /> | ||
<T.P | ||
weight="bold" | ||
color="white" | ||
mt="4" | ||
ta="center" | ||
style={{ maxWidth: 150 }} | ||
> | ||
{title} | ||
</T.P> | ||
</> | ||
); | ||
} | ||
const renderChild = (isCompleted, title) => { | ||
if (isCompleted) { | ||
return ( | ||
<T.H1 weight="bold" color="white" ta="center"> | ||
{title} | ||
</T.H1> | ||
<> | ||
<Icon icon="tick" color="white" /> | ||
<T.P | ||
weight="bold" | ||
color="white" | ||
mt="4" | ||
ta="center" | ||
style={{ maxWidth: 150 }} | ||
> | ||
{title} | ||
</T.P> | ||
</> | ||
); | ||
}; | ||
} | ||
return ( | ||
<S.Wrapper bgColor={bgColor} {...props}> | ||
<Link to={to}> | ||
<S.Container direction={direction}> | ||
{isCompleted && ( | ||
<T.P | ||
weight="bold" | ||
color="neutralTertiary" | ||
style={{ alignSelf: 'flex-start' }} | ||
mb="2" | ||
> | ||
Completed! | ||
</T.P> | ||
)} | ||
<T.P small color="neutralTertiary"> | ||
{content} | ||
</T.P> | ||
<S.Circle | ||
circleColor={circleColor} | ||
borderColor={borderColor} | ||
direction={direction} | ||
> | ||
{renderChild()} | ||
</S.Circle> | ||
</S.Container> | ||
</Link> | ||
</S.Wrapper> | ||
<T.H1 weight="bold" color="white" ta="center"> | ||
{title} | ||
</T.H1> | ||
); | ||
}; | ||
|
||
const Card = forwardRef( | ||
( | ||
{ | ||
variant = 'primary', | ||
direction = 'right', | ||
content, | ||
children, | ||
title, | ||
isCompleted, | ||
handleClick, | ||
isJustCompletedOne, | ||
to = '/', | ||
...props | ||
}, | ||
ref | ||
) => { | ||
const bgColor = `${variant}Light`; | ||
const borderColor = `${variant}Mid`; | ||
const circleColor = `${variant}Main`; | ||
return ( | ||
<S.Wrapper bgColor={bgColor} onClick={handleClick} {...props} ref={ref}> | ||
<Link to={to} style={{ color: 'transparent' }}> | ||
<S.Container direction={direction}> | ||
{isCompleted && ( | ||
<T.P | ||
weight="bold" | ||
color="neutralTertiary" | ||
style={{ alignSelf: 'flex-start' }} | ||
mb="2" | ||
> | ||
Completed! | ||
</T.P> | ||
)} | ||
<T.P isSmall color="neutralTertiary"> | ||
{content} | ||
</T.P> | ||
<S.Circle | ||
circleColor={circleColor} | ||
borderColor={borderColor} | ||
direction={direction} | ||
isJustCompletedOne={isJustCompletedOne} | ||
> | ||
{renderChild(isCompleted, title)} | ||
</S.Circle> | ||
</S.Container> | ||
</Link> | ||
</S.Wrapper> | ||
); | ||
} | ||
); | ||
|
||
export default Card; |
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
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
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
Oops, something went wrong.