lbry-desktop/src/renderer/component/copyableText/view.jsx
Sean Yesmunt 174bfbc8fb
0.27.0 cleanup (#2182)
* fix: channel navigation from suggested subscriptions

* fix: move subscribe/share buttons below name on channel page

* fix: images with weird media type

* fix: increase tx amount size on tx table

* change: add icons to nav bar

* fix: move filewatcher-webpack-plugin into dev dependencies

* fix: upgrade button styling

* improvement: modal consistency

* change: increase svg stroke inside button

* fix: more descriptive title on header for wallet balance

* fix: minor color/alignment

* chore: update lbry-redux
2019-01-14 13:40:06 -05:00

55 lines
1.2 KiB
JavaScript

// @flow
import * as ICONS from 'constants/icons';
import * as React from 'react';
import { clipboard } from 'electron';
import { FormRow } from 'component/common/form';
import Button from 'component/button';
type Props = {
copyable: string,
doToast: ({ message: string }) => void,
};
export default class CopyableText extends React.PureComponent<Props> {
constructor() {
super();
this.input = null;
}
input: ?HTMLInputElement;
render() {
const { copyable, doToast } = this.props;
return (
<FormRow verticallyCentered stretch>
<input
className="input-copyable form-field__input"
readOnly
value={copyable || ''}
ref={input => {
this.input = input;
}}
onFocus={() => {
if (this.input) {
this.input.select();
}
}}
/>
<Button
noPadding
button="secondary"
icon={ICONS.CLIPBOARD}
onClick={() => {
clipboard.writeText(copyable);
doToast({
message: __('Text copied'),
});
}}
/>
</FormRow>
);
}
}