-
-
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.
feat: almost abstracted interact component
I am submitting a pull request to remerge with main and start a new branch now that Redux has been integrated. The state was feeling a little too convoluded in the way I was managing it before, so hopefully this provides some needed clarity so that animation can flow smoothly.
- Loading branch information
1 parent
6951024
commit 572193b
Showing
9 changed files
with
41 additions
and
40 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
client/src/components/Common/Interactive/InteractiveBox/styles.ts
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,7 @@ | ||
import styled from "styled-components"; | ||
import { StyledBox } from 'components/Elements/Box/styles'; | ||
import { InteractiveProps } from "../interface"; | ||
|
||
export const InteractiveBox = styled(StyledBox)<InteractiveProps>` | ||
display: flex; | ||
`; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export interface InteractiveProps { | ||
border?: boolean; | ||
wipe?: boolean; | ||
interact?: boolean; | ||
} |
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,26 +1,20 @@ | ||
import { handleInteract } from 'components/Common/Interactive/handlers'; | ||
import Wipe from 'components/Common/Interactive/Wipe'; | ||
import React, { HTMLAttributes, useState } from 'react'; | ||
import React, { HTMLAttributes } from 'react'; | ||
import { ButtonProps } from './interface'; | ||
import { StyledButton } from './styles'; | ||
import * as tokens from 'style-dictionary-dist/variables'; | ||
|
||
// TODO: Animate button with React-spring | ||
export default (props: HTMLAttributes<HTMLButtonElement> & ButtonProps) => { | ||
const [interact, setBorder] = useState(false); | ||
const handleClick = () => { | ||
setWipe(false); | ||
setWipe(true); | ||
const int = setInterval(() => { | ||
setWipe(false); | ||
clearInterval(int); | ||
}, tokens.AnimationSpeedInteractiveHyper * 1000); | ||
}; | ||
const { label, primary } = props; | ||
|
||
const { click, interact } = handleInteract(); | ||
return ( | ||
<StyledButton border={border} wipe={wipe} primary={primary} onClick={handleClick}> | ||
<StyledButton | ||
interact={interact} | ||
primary={primary} | ||
onClick={click} | ||
> | ||
{label} | ||
<Wipe border={border} wipe={wipe} /> | ||
<Wipe interact={interact} /> | ||
</StyledButton> | ||
); | ||
}; |
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