From c98f4d46a51d98b23968075a872408e87cd01db4 Mon Sep 17 00:00:00 2001 From: Shinji-Li <1349021570@qq.com> Date: Mon, 27 Nov 2023 11:39:00 +0800 Subject: [PATCH] :bug: fix: fixed ActionIcon hover double mask (#15) Co-authored-by: ONLY-yours <1340921570@qq.com> --- src/ActionIcon/index.tsx | 124 ++++++++++++++++++++------------------- src/ActionIcon/style.ts | 28 +-------- 2 files changed, 65 insertions(+), 87 deletions(-) diff --git a/src/ActionIcon/index.tsx b/src/ActionIcon/index.tsx index d4aa8160..173239de 100644 --- a/src/ActionIcon/index.tsx +++ b/src/ActionIcon/index.tsx @@ -6,9 +6,8 @@ import Spotlight from '@/components/Spotlight'; import { DivProps } from '@/types'; import { type TooltipProps } from 'antd'; -import { useStyles } from './style'; - import { ActionIcon as ProEditorActionIcon } from '@ant-design/pro-editor'; +import { useStyles } from './style'; export type ActionIconSize = | 'large' @@ -116,63 +115,68 @@ export interface ActionIconProps extends DivProps { tooltipDelay?: number; } -const ActionIcon = forwardRef( - ( - { - color, - fill, - className, - active, - icon, - size = 'normal', - style, - glass, - spotlight, - onClick, - children, - loading, - ...props - }, - ref, - ) => { - const { styles, cx } = useStyles({ active: Boolean(active), glass: Boolean(glass) }); - - const { blockSize, borderRadius } = useMemo(() => calcSize(size), [size]); - - const content = ( - <> - {icon && ( - - )} - {children} - - ); - - const spin = ( - - ); - - const actionIconBlock = ( -
- {spotlight && } - {loading ? spin : content} -
- ); - - return ; - }, -); +const ActionIcon = forwardRef((props, ref) => { + const { + color, + fill, + className, + active, + icon, + size = 'normal', + style, + glass, + spotlight, + onClick, + children, + loading, + title, + placement, + arrow = false, + tooltipDelay = 0.5, + ...rest + } = props; + + const { styles, cx } = useStyles({ active: Boolean(active), glass: Boolean(glass) }); + + const { blockSize, borderRadius } = useMemo(() => calcSize(size), [size]); + + const content = ( + <> + {icon && ( + + )} + {children} + + ); + + const spin = ; + + const actionIconBlock = ( +
+ {spotlight && } + {loading ? spin : content} +
+ ); + + return ( + <> + + + ); +}); export default ActionIcon; diff --git a/src/ActionIcon/style.ts b/src/ActionIcon/style.ts index 557e8023..7dd47e29 100644 --- a/src/ActionIcon/style.ts +++ b/src/ActionIcon/style.ts @@ -1,7 +1,7 @@ import { createStyles } from 'antd-style'; export const useStyles = createStyles( - ({ css, token, stylish, cx }, { active, glass }: { active: boolean; glass: boolean }) => { + ({ css, stylish, cx }, { glass }: { active: boolean; glass: boolean }) => { return { block: cx( glass && stylish.blur, @@ -14,34 +14,8 @@ export const useStyles = createStyles( flex: none; align-items: center; justify-content: center; - - color: ${active ? token.colorText : token.colorTextTertiary}; - - background: ${active ? token.colorFillTertiary : 'transparent'}; - - transition: - color 600ms ${token.motionEaseOut}, - scale 400ms ${token.motionEaseOut}, - background-color 100ms ${token.motionEaseOut}; - - &:hover { - color: ${token.colorText}; - background-color: ${token.colorFillSecondary}; - } - - &:active { - color: ${token.colorText}; - background-color: ${token.colorFill}; - } `, ), - icon: css` - transition: scale 400ms ${token.motionEaseOut}; - - &:active { - scale: 0.8; - } - `, }; }, );