mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
feature(components): prop-type CopyButton
This commit is contained in:
parent
72b91899b3
commit
2ff91389e0
1 changed files with 12 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue