Newer
Older
import React, { Component } from "react";
import copy from "copy-to-clipboard";
import { WithHoverSound } from "./wrap-with-audio";
import styles from "../assets/stylesheets/invite-dialog.scss";
function pad(num, size) {
let s = `${num}`;
while (s.length < size) s = `0${s}`;
return s;
}
export default class InviteDialog extends Component {
copyButtonActive: false,
shareButtonActive: false
this.setState({ shareButtonActive: true });
share({ url, title: "Join me now in #hubs!" }).then(() => {
this.setState({ shareButtonActive: false });
});
this.setState({ copyButtonActive: true });
setTimeout(() => this.setState({ copyButtonActive: false }), 5000);
const { entryCode } = this.props;
const entryCodeString = pad(entryCode, 6);
const shortLinkText = `hub.link/${this.props.hubId}`;
const shortLink = "https://" + shortLinkText;
<div className={styles.dialog}>
<div className={styles.attachPoint} />
<WithHoverSound>
<div className={styles.close} onClick={() => this.props.onClose()}>
<span>×</span>
</WithHoverSound>
<div>
<FormattedMessage id="invite.enter_via" />
<WithHoverSound>
<a href="https://hub.link" target="_blank" className={styles.hubLinkLink} rel="noopener noreferrer">
hub.link
</a>
</WithHoverSound>
<FormattedMessage id="invite.and_enter_code" />
</div>
<div className={styles.code}>
{entryCodeString.split("").map((d, i) => (
<div className={classNames({ [styles.digit]: true, [styles[`digit_${i}`]]: true })} key={`link_code_${i}`}>
{d}
</div>
))}
</div>
<div>
<FormattedMessage id="invite.or_visit" />
</div>
<div className={styles.domain}>
<input type="text" readOnly onFocus={e => e.target.select()} value={shortLinkText} />
</div>
<div className={styles.buttons}>
<WithHoverSound>
<button className={styles.linkButton} onClick={this.copyClicked.bind(this, shortLink)}>
<span>{this.state.copyButtonActive ? "copied!" : "copy"}</span>
</button>
</WithHoverSound>
{this.props.allowShare &&
navigator.share && (
<WithHoverSound>
<button className={styles.linkButton} onClick={this.shareClicked.bind(this, shortLink)}>
<span>{this.state.shareButtonActive ? "sharing..." : "share"}</span>
</button>
</WithHoverSound>
)}
<WithHoverSound>
johnshaughnessy
committed
<button className={styles.linkButton} onClick={this.shareClicked.bind(this, shortLink)}>
<FormattedMessage id="invite.tweet" />
johnshaughnessy
committed
</button>
</WithHoverSound>
</div>
</div>