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 browser from "webextension-polyfill";
import { CopyToClipboard } from "react-copy-to-clipboard"; import { CopyToClipboard } from "react-copy-to-clipboard";
import CopyIcon from "../icons/copy.svg"; import CopyIcon from "../icons/copy.svg";
import "../styles/CopyButton.scss"; import "../styles/MediaButtons.scss";
export default class CopyButton extends Component { export default class CopyButton extends Component {
constructor(props) { constructor(props) {
@ -22,7 +22,8 @@ export default class CopyButton extends Component {
const { resultText } = this.props; const { resultText } = this.props;
return ( return (
resultText && ( resultText && (
<div className="row"> <div className="mediaButtons">
<div className="copy">
{this.state.isCopied && ( {this.state.isCopied && (
<span className="copiedText">{browser.i18n.getMessage("copiedLabel")}</span> <span className="copiedText">{browser.i18n.getMessage("copiedLabel")}</span>
)} )}
@ -32,6 +33,7 @@ export default class CopyButton extends Component {
</button> </button>
</CopyToClipboard> </CopyToClipboard>
</div> </div>
</div>
) )
); );
} }

View file

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