mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
feature(components): prop-type CopyButton
This commit is contained in:
parent
72b91899b3
commit
2ff91389e0
@ -1,4 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import Button from './Button';
|
import Button from './Button';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
@ -6,7 +7,7 @@ const defaultText = (
|
|||||||
<FormattedMessage id="label.copy-to-clipboard" defaultMessage="Copy to clipboard" />
|
<FormattedMessage id="label.copy-to-clipboard" defaultMessage="Copy to clipboard" />
|
||||||
);
|
);
|
||||||
|
|
||||||
export default function CopyButton({ element, ...props }) {
|
function CopyButton({ element, ...props }) {
|
||||||
const [text, setText] = useState(defaultText);
|
const [text, setText] = useState(defaultText);
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
@ -24,3 +25,13 @@ export default function CopyButton({ element, ...props }) {
|
|||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CopyButton.propTypes = {
|
||||||
|
element: PropTypes.shape({
|
||||||
|
current: PropTypes.shape({
|
||||||
|
select: PropTypes.func.isRequired,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CopyButton;
|
||||||
|
Loading…
Reference in New Issue
Block a user