Enhance CopyButton component to support customizable button type
- Added a new 'type' prop to the CopyButton component, allowing users to specify the button type. - Updated the component's prop types to include the new 'type' prop for better type checking and documentation. - Improved code readability by restructuring the component's props definition.
This commit is contained in:
parent
b45df50da5
commit
b74a4bb174
@ -3,7 +3,12 @@ import PropTypes from 'prop-types'
|
||||
import { Button, Tooltip, message } from 'antd'
|
||||
import CopyIcon from '../../Icons/CopyIcon'
|
||||
|
||||
const CopyButton = ({ text, tooltip = 'Copy', size = 'small' }) => {
|
||||
const CopyButton = ({
|
||||
text,
|
||||
tooltip = 'Copy',
|
||||
size = 'small',
|
||||
type = 'text'
|
||||
}) => {
|
||||
const [messageApi, contextHolder] = message.useMessage()
|
||||
|
||||
const doCopy = (copyText) => {
|
||||
@ -49,7 +54,7 @@ const CopyButton = ({ text, tooltip = 'Copy', size = 'small' }) => {
|
||||
style={{ minWidth: 25 }}
|
||||
width={20}
|
||||
size={size}
|
||||
type={'text'}
|
||||
type={type}
|
||||
onClick={() => doCopy(text)}
|
||||
/>
|
||||
</Tooltip>
|
||||
@ -61,7 +66,8 @@ CopyButton.propTypes = {
|
||||
text: PropTypes.string.isRequired,
|
||||
style: PropTypes.object,
|
||||
tooltip: PropTypes.string,
|
||||
size: PropTypes.string
|
||||
size: PropTypes.string,
|
||||
type: PropTypes.string
|
||||
}
|
||||
|
||||
export default CopyButton
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user