Merge pull request #3930 from tylershuster/copy-base-hash

launch: click to copy base hash
This commit is contained in:
matildepark 2020-11-16 15:31:32 -05:00 committed by GitHub
commit 5399d76052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import Helmet from 'react-helmet';
import styled from 'styled-components';
@ -10,6 +10,7 @@ import Tiles from './components/tiles';
import Tile from './components/tiles/tile';
import Welcome from './components/welcome';
import Groups from './components/Groups';
import { writeText } from '~/logic/lib/util';
const ScrollbarLessBox = styled(Box)`
scrollbar-width: none !important;
@ -19,9 +20,8 @@ const ScrollbarLessBox = styled(Box)`
}
`;
export default class LaunchApp extends React.Component {
render() {
const { props } = this;
export default function LaunchApp(props) {
const [hashText, setHashText] = useState(props.baseHash);
return (
<>
@ -78,11 +78,17 @@ export default class LaunchApp extends React.Component {
borderRadius={2}
fontSize={0}
p={2}
cursor="pointer"
onClick={() => {
writeText(props.baseHash);
setHashText('copied');
setTimeout(() => {
setHashText(props.baseHash);
}, 2000);
}}
>
{props.baseHash}
{hashText || props.baseHash}
</Box>
</>
);
}
}