Change component name of CopyButton

This commit is contained in:
sienori 2019-02-23 20:02:06 +09:00
parent 53509a149a
commit 8b4c12a7b3
4 changed files with 47 additions and 40 deletions

View file

@ -2,7 +2,7 @@ import React, { Component } from "react";
import browser from "webextension-polyfill";
import { CopyToClipboard } from "react-copy-to-clipboard";
import CopyIcon from "../icons/copy.svg";
import "../styles/CopyButton.scss";
import "../styles/MediaButtons.scss";
export default class CopyButton extends Component {
constructor(props) {
@ -22,15 +22,17 @@ export default class CopyButton extends Component {
const { resultText } = this.props;
return (
resultText && (
<div className="row">
{this.state.isCopied && (
<span className="copiedText">{browser.i18n.getMessage("copiedLabel")}</span>
)}
<CopyToClipboard text={resultText} onCopy={this.handleCopy}>
<button className="copyButton" title={browser.i18n.getMessage("copyLabel")}>
<CopyIcon />
</button>
</CopyToClipboard>
<div className="mediaButtons">
<div className="copy">
{this.state.isCopied && (
<span className="copiedText">{browser.i18n.getMessage("copiedLabel")}</span>
)}
<CopyToClipboard text={resultText} onCopy={this.handleCopy}>
<button className="copyButton" title={browser.i18n.getMessage("copyLabel")}>
<CopyIcon />
</button>
</CopyToClipboard>
</div>
</div>
)
);

View file

@ -4,7 +4,7 @@ import getErrorMessage from "src/common/getErrorMessage";
import { getSettings } from "src/settings/settings";
import openUrl from "src/common/openUrl";
import "../styles/ResultArea.scss";
import CopyButton from "./CopyButton";
import MediaButtons from "./MediaButtons";
const splitLine = text => {
const regex = /(\n)/g;
@ -33,7 +33,7 @@ export default props => {
<a onClick={handleLinkClick}>{browser.i18n.getMessage("openInGoogleLabel")}</a>
</p>
)}
<CopyButton resultText={resultText} />
<MediaButtons resultText={resultText} />
</div>
);
};

View file

@ -1,28 +0,0 @@
.row {
display: flex;
flex-direction: row;
justify-content: flex-end;
.copiedText {
color: var(--sub-text);
font-size: 12px;
margin-right: 5px;
-moz-user-select: none;
-webkit-user-select: none;
}
.copyButton {
padding: 0;
border: 0;
background-color: var(--main-bg);
cursor: pointer;
svg {
height: 16px;
width: 16px;
fill: var(--sub-text);
&:hover {
fill: var(--highlight);
}
}
}
}

View file

@ -0,0 +1,33 @@
.mediaButtons {
display: flex;
flex-direction: row;
justify-content: flex-end;
.copy {
display: flex;
justify-content: center;
.copiedText {
color: var(--sub-text);
font-size: 12px;
margin-right: 5px;
-moz-user-select: none;
-webkit-user-select: none;
}
.copyButton {
padding: 0;
border: 0;
background-color: var(--main-bg);
cursor: pointer;
svg {
height: 16px;
width: 16px;
fill: var(--sub-text);
&:hover {
fill: var(--highlight);
}
}
}
}
}