Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Preview/CloseBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import classnames from 'classnames';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classNames 这个库已经删掉了

import * as React from 'react';

export interface CloseBtnProps {
prefixCls: string;
icon?: React.ReactNode;
onClick: React.MouseEventHandler<HTMLButtonElement>;
className?: string;
style?: React.CSSProperties;
}

export default function CloseBtn(props: CloseBtnProps) {
const { prefixCls, icon, onClick } = props;
const { prefixCls, icon, onClick, className, style } = props;

return (
<button className={`${prefixCls}-close`} onClick={onClick}>
<button
className={classnames(`${prefixCls}-close`, className)}
style={style}
onClick={onClick}
>
{icon}
</button>
Comment on lines 16 to 22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's a good practice to explicitly set the type of a <button> to "button". The default type is "submit", which can cause unexpected form submissions if this component is rendered within a <form> element. Adding type="button" prevents this behavior.

    <button
      type="button"
      className={classnames(`${prefixCls}-close`, className)}
      style={style}
      onClick={onClick}
    >
      {icon}
    </button>

);
Expand Down
4 changes: 3 additions & 1 deletion src/Preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import PrevNext from './PrevNext';

// Note: if you want to add `action`,
// pls contact @zombieJ or @thinkasany first.
export type PreviewSemanticName = 'root' | 'mask' | 'body' | FooterSemanticName;
export type PreviewSemanticName = 'root' | 'mask' | 'body' | 'close' | FooterSemanticName;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

补一下测试用例


export interface OperationIcons {
rotateLeft?: React.ReactNode;
Expand Down Expand Up @@ -440,6 +440,8 @@ const Preview: React.FC<PreviewProps> = props => {
prefixCls={prefixCls}
icon={closeIcon === true ? icons.close : closeIcon || icons.close}
onClick={onClose}
className={classNames.close}
style={styles.close}
/>
)}

Expand Down