mirror of
https://github.com/strapi/strapi.git
synced 2025-10-26 15:41:49 +00:00
Add CopytoClipboard
This commit is contained in:
parent
85f3b5c6d2
commit
976ac68543
@ -6,11 +6,35 @@
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
||||
import cn from 'classnames';
|
||||
|
||||
import styles from './styles.scss';
|
||||
|
||||
class Li extends React.Component {
|
||||
state = { isOpen: false };
|
||||
state = { isOpen: false, copied: false };
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (prevState.copied !== this.state.copied && this.state.copied) {
|
||||
setTimeout(() => {
|
||||
this.setState({ copied: false });
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
renderLiCopied = () => (
|
||||
<li className={cn(styles.liWrapper, styles.copied)}>
|
||||
<div>
|
||||
<div className={styles.checked}>
|
||||
<div />
|
||||
</div>
|
||||
<div>
|
||||
<FormattedMessage id="upload.Li.linkCopied" />
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
|
||||
toggle = (e) => {
|
||||
e.preventDefault();
|
||||
@ -21,9 +45,13 @@ class Li extends React.Component {
|
||||
render() {
|
||||
const { item } = this.props;
|
||||
|
||||
if (this.state.copied) {
|
||||
return this.renderLiCopied();
|
||||
}
|
||||
|
||||
return (
|
||||
<CopyToClipboard text={item.url} onCopy={() => this.setState({copied: true})}>
|
||||
<li className={styles.liWrapper}>
|
||||
<input value={item.url} style={{ display: 'none' }} ref="inputCopy" />
|
||||
<div className={styles.liContainer}>
|
||||
<div />
|
||||
{Object.keys(item).map((value, key) => {
|
||||
@ -43,6 +71,7 @@ class Li extends React.Component {
|
||||
})}
|
||||
</div>
|
||||
</li>
|
||||
</CopyToClipboard>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,3 +46,42 @@
|
||||
.liIconContainer {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.copied {
|
||||
background-color: #FAFAFB;
|
||||
> div {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
padding-top: 1px;
|
||||
text-align: center;
|
||||
color: #868FA1;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 54px;
|
||||
}
|
||||
}
|
||||
|
||||
.checked {
|
||||
padding-top: 20px;
|
||||
line-height: 54px;
|
||||
position: relative;
|
||||
> div {
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
margin-right: 10px;
|
||||
background-color: #2DD210;
|
||||
border: 1px solid rgba(16,22,34,0.10);
|
||||
border-radius: 3px;
|
||||
&:after {
|
||||
content: '\f00c';
|
||||
position: absolute;
|
||||
top: 0; left: 2px;
|
||||
font-size: 10px;
|
||||
font-family: 'FontAwesome';
|
||||
font-weight: 100;
|
||||
color: #fff;
|
||||
transition: all .2s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ function List(props) {
|
||||
<ListHeader />
|
||||
{props.data.map((item, key) => (
|
||||
<Li
|
||||
key={item.hash || key}
|
||||
key={key}
|
||||
item={item}
|
||||
/>
|
||||
))}
|
||||
|
||||
@ -56,7 +56,6 @@ function* uploadFiles(action) {
|
||||
}),
|
||||
];
|
||||
|
||||
console.log('n', newFiles);
|
||||
yield put(dropSuccess(newFiles));
|
||||
|
||||
if (newFiles.length > 1) {
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
"HomePage.description": "Discover all the uploaded files",
|
||||
"HomePage.InputSearch.placeholder": "Search for a file...",
|
||||
|
||||
"Li.linkCopied": "LINK COPIED INTO THE CLIPBOARD",
|
||||
|
||||
"ListHeader.type": "Type",
|
||||
"ListHeader.hash": "Hash",
|
||||
"ListHeader.name": "Name",
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
"HomePage.description": "Découvrez tous les fichiers téléchargés",
|
||||
"HomePage.InputSearch.placeholder": "Rechercher un fichier...",
|
||||
|
||||
"Li.linkCopied": "LINK COPIÉ DANS LE PRESSE-PAPIER",
|
||||
|
||||
"ListHeader.type": "Type",
|
||||
"ListHeader.hash": "Hash",
|
||||
"ListHeader.name": "Nom",
|
||||
|
||||
@ -22,7 +22,9 @@
|
||||
"test": "npm run lint",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"react-copy-to-clipboard": "^5.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"strapi-helper-plugin": "3.0.0-alpha.10.1"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user