fix and finish #391

This commit is contained in:
Cassie Tarakajian 2017-10-30 17:24:43 -04:00
parent d48d9349a8
commit d121c2c882
3 changed files with 65 additions and 21 deletions

View file

@ -2,16 +2,31 @@ import React, { PropTypes } from 'react';
import Clipboard from 'clipboard'; import Clipboard from 'clipboard';
class CopyableInput extends React.Component { class CopyableInput extends React.Component {
constructor(props) {
super(props);
this.onMouseLeaveHandler = this.onMouseLeaveHandler.bind(this);
}
componentDidMount() { componentDidMount() {
this.clipboard = new Clipboard(this.input, { this.clipboard = new Clipboard(this.input, {
target: () => this.input target: () => this.input
}); });
this.clipboard.on('success', (e) => {
this.tooltip.classList.add('tooltipped');
this.tooltip.classList.add('tooltipped-n');
});
} }
componentWillUnmount() { componentWillUnmount() {
this.clipboard.destroy(); this.clipboard.destroy();
} }
onMouseLeaveHandler() {
this.tooltip.classList.remove('tooltipped');
this.tooltip.classList.remove('tooltipped-n');
}
render() { render() {
const { const {
label, label,
@ -20,19 +35,20 @@ class CopyableInput extends React.Component {
return ( return (
<div className="copyable-input"> <div className="copyable-input">
<label className="copyable-input__label" htmlFor="copyable-input__value">{label}</label> <label className="copyable-input__label" htmlFor="copyable-input__value">{label}</label>
<div className="copyable-input__value-container"> <div
className="copyable-input__value-container"
aria-label="Copied to Clipboard!"
ref={(element) => { this.tooltip = element; }}
onMouseLeave={this.onMouseLeaveHandler}
>
<input <input
type="text" type="text"
className="copyable-input__value" className="copyable-input__value"
id="copyable-input__value" id="copyable-input__value"
value={value} value={value}
ref={(element) => { this.input = element; }} ref={(element) => { this.input = element; }}
readOnly
/> />
<span
className="copyable-input__tooltip tooltipped tooltipped-n"
aria-label="Copyied to Clipboard!"
>
</span>
</div> </div>
</div> </div>
); );

View file

@ -9,3 +9,45 @@
bottom: 0; bottom: 0;
right: 0; right: 0;
} }
.copyable-input__value {
width: 100%;
font-size: #{16 / $base-font-size}rem;
}
.copyable-input__label {
width: 100%;
font-size: #{12 / $base-font-size}rem;
padding-bottom: #{5 / $base-font-size}rem;
@include themify() {
color: getThemifyVariable('inactive-text-color');
}
}
.copyable-input {
padding-bottom: #{30 / $base-font-size}rem;
display: flex;
flex-wrap: wrap;
}
.copyable-input__value-container {
width: 100%;
}
.tooltipped::after {
@include themify() {
background-color: getThemifyVariable('button-background-hover-color');
color: getThemifyVariable('button-hover-color');
}
font-family: Montserrat, sans-serif;
font-size: #{14 / $base-font-size}rem;
}
.tooltipped-n::before,
.tooltipped::before,
{
@include themify() {
color: getThemifyVariable('button-background-hover-color');
border-top-color: getThemifyVariable('button-background-hover-color');
}
}

View file

@ -5,7 +5,7 @@
} }
.share-modal__project-name { .share-modal__project-name {
padding-bottom: #{20 / $base-font-size}rem; padding-bottom: #{30 / $base-font-size}rem;
font-size: #{16 / $base-font-size}rem; font-size: #{16 / $base-font-size}rem;
} }
@ -20,17 +20,3 @@
flex-wrap: wrap; flex-wrap: wrap;
padding: #{10 / $base-font-size}rem 0; padding: #{10 / $base-font-size}rem 0;
} }
.share-modal__label {
width: 100%;
font-size: #{12 / $base-font-size}rem;
padding-bottom: #{3 / $base-font-size}rem;
@include themify() {
color: getThemifyVariable('inactive-text-color');
}
}
.share-modal__input {
width: 100%;
font-size: #{16 / $base-font-size}rem;
}