Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-kallavus committed Nov 30, 2023
1 parent 407f800 commit da3fa57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions workspaces/core/src/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useCallback, useState } from 'react';
import type ButtonProps from './private/types/ButtonProps';
import AnimationContent from './private/utils/buttonAnimations/AnimationContent';
import ButtonComponent from './styles/ButtonComponent';
Expand Down Expand Up @@ -29,6 +29,9 @@ const Button = <C extends React.ElementType = 'button'>({
const [isHover, setIsHover] = useState(false);
const hasAnimationContent =
animation === 'progress' || animation === 'success';
const onMouseEnter = useCallback(() => setIsHover(true), [setIsHover]);
const onMouseLeave = useCallback(() => setIsHover(false), [setIsHover]);

return (
<ButtonComponent
size={size}
Expand All @@ -41,8 +44,8 @@ const Button = <C extends React.ElementType = 'button'>({
disabled={disabled}
animation={animation}
as={as}
onMouseEnter={() => setIsHover(true)}
onMouseLeave={() => setIsHover(false)}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
customClassName={className}
{...rest}
>
Expand Down
2 changes: 1 addition & 1 deletion workspaces/core/src/button/styles/Hover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Hover = ({
className={mergeClassnames(
'z-[-1] block absolute inset-0 pointer-events-none',
'transition-[background-color_0.2s_ease-in-out]',
isHover && hoverBackground
isHover ? hoverBackground : '',
)}
/>
);
Expand Down

0 comments on commit da3fa57

Please sign in to comment.