Skip to content

Commit

Permalink
Check icon and create to do icon animated
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammed-Rahif committed Aug 16, 2021
1 parent 1a15c6b commit 7cb2c79
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "todo-app",
"version": "0.1.0",
"version": "2.1.0",
"homepage": "https://muhammed-rahif.github.io/ToDo-App",
"private": true,
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ function App({ background = "" }) {
easing: easeBackInOut.overshoot(2.5),
}}
>
{styles => (
{style => (
<FAB
changeIcon={createToDoModel}
style={styles}
createToDoActive={createToDoModel}
style={style}
onClick={() => setCreateToDoModel(!createToDoModel)}
/>
)}
Expand Down
21 changes: 18 additions & 3 deletions src/components/FAB/FAB.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import React from "react";
import "./FAB.css";
import { animated } from "react-spring";
import { animated, Spring } from "react-spring";
import { easeBackInOut } from "d3-ease";

function FAB({ onClick, style = {}, changeIcon = false }) {
function FAB({ onClick, style = {}, createToDoActive = false }) {
return (
<animated.button style={style} className="button fab box is-primary" onClick={onClick}>
<i className={`fas fa-${changeIcon ? "chevron-down" : "plus"}`}></i>
<Spring
from={{ rotate: 0 }}
to={{ rotate: createToDoActive ? 180 : 0 }}
config={{
duration: 1500,
easing: easeBackInOut.overshoot(2.5),
}}
>
{style => (
<animated.i
style={style}
className={`fas fa-${createToDoActive ? "chevron-down" : "plus"}`}
></animated.i>
)}
</Spring>
</animated.button>
);
}
Expand Down
24 changes: 19 additions & 5 deletions src/components/ToDoCard/ToDoCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,25 @@ function ToDoCard({
}}
key={indx}
>
<i
className={`fas fa-${
indx === 0 ? "trash" : toDoFinished ? "undo" : "check"
}`}
></i>
{indx === 0 ? (
<i className="fas fa-trash"></i>
) : (
<Spring
from={{ rotate: 0 }}
to={{ rotate: toDoFinished ? 360 : 0 }}
config={{
duration: 1500,
easing: easeBackInOut.overshoot(2.5),
}}
>
{style => (
<animated.i
style={style}
className={`fas fa-${toDoFinished ? "undo" : "check"}`}
></animated.i>
)}
</Spring>
)}
</animated.button>
))}
</animated.div>
Expand Down

0 comments on commit 7cb2c79

Please sign in to comment.