mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { absoluteCenter, displayInlineFlex, styled } from '@/styles';
|
|
import { CSSProperties } from 'react';
|
|
|
|
export const StyledIconButton = styled.button<{
|
|
width: number;
|
|
height: number;
|
|
borderRadius: number;
|
|
disabled?: boolean;
|
|
hoverBackground?: string;
|
|
hoverColor?: string;
|
|
hoverStyle?: CSSProperties;
|
|
}>(
|
|
({
|
|
theme,
|
|
width,
|
|
height,
|
|
disabled,
|
|
hoverBackground,
|
|
hoverColor,
|
|
hoverStyle,
|
|
}) => {
|
|
return {
|
|
width,
|
|
height,
|
|
color: theme.colors.iconColor,
|
|
...displayInlineFlex('center', 'center'),
|
|
position: 'relative',
|
|
...(disabled ? { cursor: 'not-allowed', pointerEvents: 'none' } : {}),
|
|
transition: 'background .15s',
|
|
|
|
// TODO: we need to add @emotion/babel-plugin
|
|
'::after': {
|
|
content: '""',
|
|
width,
|
|
height,
|
|
borderRadius: width / 5,
|
|
transition: 'background .15s',
|
|
...absoluteCenter({ horizontal: true, vertical: true }),
|
|
},
|
|
|
|
svg: {
|
|
position: 'relative',
|
|
zIndex: 1,
|
|
},
|
|
|
|
':hover': {
|
|
color: hoverColor ?? theme.colors.primaryColor,
|
|
'::after': {
|
|
background: hoverBackground ?? theme.colors.hoverBackground,
|
|
},
|
|
...(hoverStyle ?? {}),
|
|
},
|
|
};
|
|
}
|
|
);
|