mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 11:59:51 +08:00
fix: button style error (#3396)
This commit is contained in:
@@ -6,10 +6,7 @@ import {
|
|||||||
} from '@affine/component/app-sidebar';
|
} from '@affine/component/app-sidebar';
|
||||||
import { AddPageButton } from '@affine/component/app-sidebar';
|
import { AddPageButton } from '@affine/component/app-sidebar';
|
||||||
import { CategoryDivider } from '@affine/component/app-sidebar';
|
import { CategoryDivider } from '@affine/component/app-sidebar';
|
||||||
import {
|
import { navHeaderStyle } from '@affine/component/app-sidebar';
|
||||||
navHeaderStyle,
|
|
||||||
sidebarButtonStyle,
|
|
||||||
} from '@affine/component/app-sidebar';
|
|
||||||
import { MenuLinkItem } from '@affine/component/app-sidebar';
|
import { MenuLinkItem } from '@affine/component/app-sidebar';
|
||||||
import { QuickSearchInput } from '@affine/component/app-sidebar';
|
import { QuickSearchInput } from '@affine/component/app-sidebar';
|
||||||
import {
|
import {
|
||||||
@@ -54,7 +51,7 @@ const Main = () => {
|
|||||||
<div className={navHeaderStyle}>
|
<div className={navHeaderStyle}>
|
||||||
{!open && (
|
{!open && (
|
||||||
<IconButton
|
<IconButton
|
||||||
className={sidebarButtonStyle}
|
size="large"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -83,12 +83,6 @@ export const navBodyStyle = style({
|
|||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const sidebarButtonStyle = style({
|
|
||||||
height: '32px',
|
|
||||||
color: 'var(--affine-icon-color)',
|
|
||||||
zIndex: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const sidebarFloatMaskStyle = style({
|
export const sidebarFloatMaskStyle = style({
|
||||||
transition: 'opacity .15s',
|
transition: 'opacity .15s',
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { SidebarIcon } from '@blocksuite/icons';
|
|||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
|
|
||||||
import { IconButton, Tooltip } from '../../../';
|
import { IconButton, Tooltip } from '../../../';
|
||||||
import { sidebarButtonStyle } from '../index.css';
|
|
||||||
import { appSidebarOpenAtom } from '../index.jotai';
|
import { appSidebarOpenAtom } from '../index.jotai';
|
||||||
|
|
||||||
export const SidebarSwitch = () => {
|
export const SidebarSwitch = () => {
|
||||||
@@ -20,11 +19,14 @@ export const SidebarSwitch = () => {
|
|||||||
zIndex={1000}
|
zIndex={1000}
|
||||||
>
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
size="large"
|
||||||
data-testid={`app-sidebar-arrow-button-${open ? 'collapse' : 'expand'}`}
|
data-testid={`app-sidebar-arrow-button-${open ? 'collapse' : 'expand'}`}
|
||||||
className={sidebarButtonStyle}
|
style={{
|
||||||
|
zIndex: 1,
|
||||||
|
}}
|
||||||
onClick={() => setOpen(open => !open)}
|
onClick={() => setOpen(open => !open)}
|
||||||
>
|
>
|
||||||
<SidebarIcon width={24} height={24} />
|
<SidebarIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -133,19 +133,7 @@ export const groupStyle = style({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const buttonStyle = style({
|
export const buttonStyle = style({
|
||||||
minWidth: '24px',
|
|
||||||
height: '24px',
|
|
||||||
margin: '10px 6px',
|
margin: '10px 6px',
|
||||||
padding: '0 0',
|
|
||||||
':hover': {
|
|
||||||
backgroundColor: 'var(--affine-background-error-color)',
|
|
||||||
backgroundSize: '24px 24px',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export const buttonIconStyle = style({
|
|
||||||
width: '20px',
|
|
||||||
height: '20px',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const scaleIndicatorButtonStyle = style({
|
export const scaleIndicatorButtonStyle = style({
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import '@blocksuite/blocks';
|
import '@blocksuite/blocks';
|
||||||
|
|
||||||
import { Button, Tooltip } from '@affine/component';
|
|
||||||
import type { ImageBlockModel } from '@blocksuite/blocks';
|
import type { ImageBlockModel } from '@blocksuite/blocks';
|
||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
import {
|
import {
|
||||||
@@ -24,9 +23,10 @@ import type { FallbackProps } from 'react-error-boundary';
|
|||||||
import { ErrorBoundary } from 'react-error-boundary';
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
import { Button, IconButton } from '../../ui/button';
|
||||||
|
import { Tooltip } from '../../ui/tooltip';
|
||||||
import { useZoomControls } from './hooks/use-zoom';
|
import { useZoomControls } from './hooks/use-zoom';
|
||||||
import {
|
import {
|
||||||
buttonIconStyle,
|
|
||||||
buttonStyle,
|
buttonStyle,
|
||||||
captionStyle,
|
captionStyle,
|
||||||
groupStyle,
|
groupStyle,
|
||||||
@@ -339,9 +339,9 @@ const ImagePreviewModalImpl = (
|
|||||||
<div className={imagePreviewActionBarStyle}>
|
<div className={imagePreviewActionBarStyle}>
|
||||||
<div>
|
<div>
|
||||||
<Tooltip content={'Previous'} disablePortal={false}>
|
<Tooltip content={'Previous'} disablePortal={false}>
|
||||||
<Button
|
<IconButton
|
||||||
data-testid="previous-image-button"
|
data-testid="previous-image-button"
|
||||||
icon={<ArrowLeftSmallIcon className={buttonIconStyle} />}
|
icon={<ArrowLeftSmallIcon />}
|
||||||
type="plain"
|
type="plain"
|
||||||
className={buttonStyle}
|
className={buttonStyle}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -351,9 +351,9 @@ const ImagePreviewModalImpl = (
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={'Next'} disablePortal={false}>
|
<Tooltip content={'Next'} disablePortal={false}>
|
||||||
<Button
|
<IconButton
|
||||||
data-testid="next-image-button"
|
data-testid="next-image-button"
|
||||||
icon={<ArrowRightSmallIcon className={buttonIconStyle} />}
|
icon={<ArrowRightSmallIcon />}
|
||||||
className={buttonStyle}
|
className={buttonStyle}
|
||||||
type="plain"
|
type="plain"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -369,18 +369,18 @@ const ImagePreviewModalImpl = (
|
|||||||
disablePortal={true}
|
disablePortal={true}
|
||||||
showArrow={false}
|
showArrow={false}
|
||||||
>
|
>
|
||||||
<Button
|
<IconButton
|
||||||
data-testid="fit-to-screen-button"
|
data-testid="fit-to-screen-button"
|
||||||
icon={<ViewBarIcon className={buttonIconStyle} />}
|
icon={<ViewBarIcon />}
|
||||||
type="plain"
|
type="plain"
|
||||||
className={buttonStyle}
|
className={buttonStyle}
|
||||||
onClick={() => resetZoom()}
|
onClick={() => resetZoom()}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={'Zoom out'} disablePortal={false}>
|
<Tooltip content={'Zoom out'} disablePortal={false}>
|
||||||
<Button
|
<IconButton
|
||||||
data-testid="zoom-out-button"
|
data-testid="zoom-out-button"
|
||||||
icon={<MinusIcon className={buttonIconStyle} />}
|
icon={<MinusIcon />}
|
||||||
className={buttonStyle}
|
className={buttonStyle}
|
||||||
type="plain"
|
type="plain"
|
||||||
onClick={zoomOut}
|
onClick={zoomOut}
|
||||||
@@ -398,9 +398,9 @@ const ImagePreviewModalImpl = (
|
|||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={'Zoom in'} disablePortal={false}>
|
<Tooltip content={'Zoom in'} disablePortal={false}>
|
||||||
<Button
|
<IconButton
|
||||||
data-testid="zoom-in-button"
|
data-testid="zoom-in-button"
|
||||||
icon={<PlusIcon className={buttonIconStyle} />}
|
icon={<PlusIcon />}
|
||||||
className={buttonStyle}
|
className={buttonStyle}
|
||||||
type="plain"
|
type="plain"
|
||||||
onClick={() => zoomIn()}
|
onClick={() => zoomIn()}
|
||||||
@@ -408,9 +408,9 @@ const ImagePreviewModalImpl = (
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div className={groupStyle}></div>
|
<div className={groupStyle}></div>
|
||||||
<Tooltip content={'Download'} disablePortal={false}>
|
<Tooltip content={'Download'} disablePortal={false}>
|
||||||
<Button
|
<IconButton
|
||||||
data-testid="download-button"
|
data-testid="download-button"
|
||||||
icon={<DownloadIcon className={buttonIconStyle} />}
|
icon={<DownloadIcon />}
|
||||||
type="plain"
|
type="plain"
|
||||||
className={buttonStyle}
|
className={buttonStyle}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -422,9 +422,9 @@ const ImagePreviewModalImpl = (
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={'Copy to clipboard'} disablePortal={false}>
|
<Tooltip content={'Copy to clipboard'} disablePortal={false}>
|
||||||
<Button
|
<IconButton
|
||||||
data-testid="copy-to-clipboard-button"
|
data-testid="copy-to-clipboard-button"
|
||||||
icon={<CopyIcon className={buttonIconStyle} />}
|
icon={<CopyIcon />}
|
||||||
type="plain"
|
type="plain"
|
||||||
className={buttonStyle}
|
className={buttonStyle}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -463,9 +463,9 @@ const ImagePreviewModalImpl = (
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div className={groupStyle}></div>
|
<div className={groupStyle}></div>
|
||||||
<Tooltip content={'Delete'} disablePortal={false}>
|
<Tooltip content={'Delete'} disablePortal={false}>
|
||||||
<Button
|
<IconButton
|
||||||
data-testid="delete-button"
|
data-testid="delete-button"
|
||||||
icon={<DeleteIcon className={buttonIconStyle} />}
|
icon={<DeleteIcon />}
|
||||||
type="plain"
|
type="plain"
|
||||||
className={buttonStyle}
|
className={buttonStyle}
|
||||||
onClick={() => blockId && deleteHandler(blockId)}
|
onClick={() => blockId && deleteHandler(blockId)}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
iconPosition,
|
iconPosition,
|
||||||
block,
|
block,
|
||||||
loading,
|
loading,
|
||||||
|
className,
|
||||||
...otherProps
|
...otherProps
|
||||||
} = {
|
} = {
|
||||||
...defaultProps,
|
...defaultProps,
|
||||||
@@ -93,21 +94,25 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={clsx(button, {
|
className={clsx(
|
||||||
primary: type === 'primary',
|
button,
|
||||||
plain: type === 'plain',
|
{
|
||||||
error: type === 'error',
|
primary: type === 'primary',
|
||||||
warning: type === 'warning',
|
plain: type === 'plain',
|
||||||
success: type === 'success',
|
error: type === 'error',
|
||||||
processing: type === 'processing',
|
warning: type === 'warning',
|
||||||
large: size === 'large',
|
success: type === 'success',
|
||||||
extraLarge: size === 'extraLarge',
|
processing: type === 'processing',
|
||||||
disabled,
|
large: size === 'large',
|
||||||
circle: shape === 'circle',
|
extraLarge: size === 'extraLarge',
|
||||||
round: shape === 'round',
|
disabled,
|
||||||
block,
|
circle: shape === 'circle',
|
||||||
loading,
|
round: shape === 'round',
|
||||||
})}
|
block,
|
||||||
|
loading,
|
||||||
|
},
|
||||||
|
className
|
||||||
|
)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
data-disabled={disabled}
|
data-disabled={disabled}
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef, type ReactElement } from 'react';
|
||||||
|
|
||||||
import { Loading } from '../loading';
|
import { Loading } from '../loading';
|
||||||
import type { ButtonType } from './button';
|
import type { ButtonType } from './button';
|
||||||
@@ -15,6 +15,7 @@ export type IconButtonProps = PropsWithChildren &
|
|||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
withoutPadding?: boolean;
|
withoutPadding?: boolean;
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
|
icon?: ReactElement;
|
||||||
};
|
};
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
type: 'plain',
|
type: 'plain',
|
||||||
@@ -35,6 +36,8 @@ export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|||||||
disabled,
|
disabled,
|
||||||
loading,
|
loading,
|
||||||
active,
|
active,
|
||||||
|
icon: propsIcon,
|
||||||
|
className,
|
||||||
...otherProps
|
...otherProps
|
||||||
} = {
|
} = {
|
||||||
...defaultProps,
|
...defaultProps,
|
||||||
@@ -44,29 +47,33 @@ export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={clsx(iconButton, {
|
className={clsx(
|
||||||
'without-padding': withoutPadding,
|
iconButton,
|
||||||
|
{
|
||||||
|
'without-padding': withoutPadding,
|
||||||
|
|
||||||
primary: type === 'primary',
|
primary: type === 'primary',
|
||||||
plain: type === 'plain',
|
plain: type === 'plain',
|
||||||
error: type === 'error',
|
error: type === 'error',
|
||||||
warning: type === 'warning',
|
warning: type === 'warning',
|
||||||
success: type === 'success',
|
success: type === 'success',
|
||||||
processing: type === 'processing',
|
processing: type === 'processing',
|
||||||
|
|
||||||
large: size === 'large',
|
large: size === 'large',
|
||||||
small: size === 'small',
|
small: size === 'small',
|
||||||
'extra-small': size === 'extraSmall',
|
'extra-small': size === 'extraSmall',
|
||||||
|
|
||||||
disabled,
|
disabled,
|
||||||
loading,
|
loading,
|
||||||
active,
|
active,
|
||||||
})}
|
},
|
||||||
|
className
|
||||||
|
)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
data-disabled={disabled}
|
data-disabled={disabled}
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
>
|
>
|
||||||
{loading ? <Loading /> : children}
|
{loading ? <Loading /> : children || propsIcon}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { CloseIcon } from '@blocksuite/icons';
|
import { CloseIcon } from '@blocksuite/icons';
|
||||||
import type { HTMLAttributes } from 'react';
|
import type { HTMLAttributes } from 'react';
|
||||||
|
|
||||||
import { styled } from '../../styles';
|
|
||||||
import type { IconButtonProps } from '../button/icon-button';
|
import type { IconButtonProps } from '../button/icon-button';
|
||||||
import { IconButton } from '../button/icon-button';
|
import { IconButton } from '../button/icon-button';
|
||||||
export type ModalCloseButtonProps = {
|
export type ModalCloseButtonProps = {
|
||||||
@@ -11,27 +10,27 @@ export type ModalCloseButtonProps = {
|
|||||||
} & Omit<IconButtonProps, 'children'> &
|
} & Omit<IconButtonProps, 'children'> &
|
||||||
HTMLAttributes<HTMLButtonElement>;
|
HTMLAttributes<HTMLButtonElement>;
|
||||||
|
|
||||||
const StyledIconButton = styled(IconButton)<
|
|
||||||
Pick<ModalCloseButtonProps, 'top' | 'right'>
|
|
||||||
>(({ top, right }) => {
|
|
||||||
return {
|
|
||||||
position: 'absolute',
|
|
||||||
top: top ?? 24,
|
|
||||||
right: right ?? 40,
|
|
||||||
zIndex: 1,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const ModalCloseButton = ({
|
export const ModalCloseButton = ({
|
||||||
absolute = true,
|
absolute = true,
|
||||||
|
right,
|
||||||
|
top,
|
||||||
...props
|
...props
|
||||||
}: ModalCloseButtonProps) => {
|
}: ModalCloseButtonProps) => {
|
||||||
return absolute ? (
|
return (
|
||||||
<StyledIconButton data-testid="modal-close-button" {...props}>
|
<IconButton
|
||||||
<CloseIcon />
|
style={
|
||||||
</StyledIconButton>
|
absolute
|
||||||
) : (
|
? {
|
||||||
<IconButton data-testid="modal-close-button" {...props}>
|
position: 'absolute',
|
||||||
|
top: top ?? 24,
|
||||||
|
right: right ?? 40,
|
||||||
|
zIndex: 1,
|
||||||
|
}
|
||||||
|
: {}
|
||||||
|
}
|
||||||
|
data-testid="modal-close-button"
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
<CloseIcon />
|
<CloseIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user