Skip to content

Commit

Permalink
Voting: animate card's voted indicator on focus / blur (aragon#1034)
Browse files Browse the repository at this point in the history
  • Loading branch information
sohkai authored Nov 22, 2019
1 parent 1df0ac0 commit 2ee52b5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/voting/app/src/components/VoteCard/VoteCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ function VoteCard({ vote, onOpen }) {
const handleOpen = useCallback(() => {
onOpen(voteId)
}, [voteId, onOpen])
const handleStartHighlight = useCallback(() => setHighlighted(true), [])
const handleEndHighlight = useCallback(() => setHighlighted(false), [])

// “highlighted” means either focused or hovered
const [highlighted, setHighlighted] = useState(false)

return (
<Card
onClick={handleOpen}
onMouseEnter={() => setHighlighted(true)}
onMouseLeave={() => setHighlighted(false)}
onMouseEnter={handleStartHighlight}
onMouseLeave={handleEndHighlight}
onFocus={handleStartHighlight}
onBlur={handleEndHighlight}
css={`
display: grid;
grid-template-columns: 100%;
Expand Down

0 comments on commit 2ee52b5

Please sign in to comment.