diff --git a/packages/app/src/ui/button/Button.tsx b/packages/app/src/ui/button/Button.tsx index 2af171b1f8..1e77b58f5a 100644 --- a/packages/app/src/ui/button/Button.tsx +++ b/packages/app/src/ui/button/Button.tsx @@ -15,16 +15,26 @@ export const Button = forwardRef( hoverStyle, shape = 'default', icon, + iconPosition = 'start', type = 'default', children, bold = false, loading = false, + noBorder = false, ...props }, ref ) => { const { iconSize } = getSize(size); + const iconElement = + icon && + cloneElement(Children.only(icon), { + width: iconSize, + height: iconSize, + className: `affine-button-icon ${icon.props.className ?? ''}`, + }); + return ( ( // @ts-ignore type={type} bold={bold} + noBorder={noBorder} {...props} > {loading ? ( ) : ( <> - {icon && - cloneElement(Children.only(icon), { - width: iconSize, - height: iconSize, - className: `affine-button-icon ${icon.props.className ?? ''}`, - })} + {iconPosition === 'start' && iconElement} {children && {children}} + {iconPosition === 'end' && iconElement} )} diff --git a/packages/app/src/ui/button/interface.ts b/packages/app/src/ui/button/interface.ts index 6b5a55996b..150afa648b 100644 --- a/packages/app/src/ui/button/interface.ts +++ b/packages/app/src/ui/button/interface.ts @@ -17,8 +17,10 @@ export type ButtonProps = PropsWithChildren & hoverColor?: CSSProperties['color']; hoverStyle?: CSSProperties; icon?: ReactElement; + iconPosition?: 'start' | 'end'; shape?: 'default' | 'round' | 'circle'; type?: 'primary' | 'warning' | 'danger' | 'default'; bold?: boolean; loading?: boolean; + noBorder?: boolean; }; diff --git a/packages/app/src/ui/button/styles.ts b/packages/app/src/ui/button/styles.ts index aceb22fddd..8310f3cfaa 100644 --- a/packages/app/src/ui/button/styles.ts +++ b/packages/app/src/ui/button/styles.ts @@ -149,6 +149,7 @@ export const StyledButton = styled('button', { 'hoverStyle', 'type', 'bold', + 'noBorder', ].includes(prop); }, })< @@ -162,6 +163,7 @@ export const StyledButton = styled('button', { | 'shape' | 'type' | 'bold' + | 'noBorder' > >( ({ @@ -174,6 +176,7 @@ export const StyledButton = styled('button', { bold = false, shape = 'default', type = 'default', + noBorder = false, }) => { const { fontSize, borderRadius, padding, height } = getSize(size); @@ -181,7 +184,7 @@ export const StyledButton = styled('button', { height, paddingLeft: padding, paddingRight: padding, - border: '1px solid', + border: noBorder ? 'none' : '1px solid', ...displayInlineFlex('center', 'center'), position: 'relative', // TODO: disabled color is not decided