Skip to content

Commit

Permalink
fix(FEC-9015): share to email subject and body (#380)
Browse files Browse the repository at this point in the history
The share to email subject and body were not implemented.
Also fixed invalid reference to share buttons aria-label.
  • Loading branch information
OrenMe committed Apr 4, 2019
1 parent 93743d3 commit d8b7912
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/components/share-overlay/share-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ShareButton = (props: Object): React$Element<any> => {
rel="noopener noreferrer"
title={props.config.title}
role="button"
aria-label={props.config.ariaLable}
aria-label={props.config.ariaLabel}
className={[style.btnRounded, style[props.config.iconType], props.config.iconType].join(' ')}
onClick={() => share()}>
<Icon style={props.config.iconType === 'svg' ? `background-image: url(${props.config.svg})` : ``} type={props.config.iconType} />
Expand Down Expand Up @@ -207,6 +207,22 @@ class ShareOverlay extends BaseComponent {
return `<iframe src="${url}" style="width: 560px;height: 395px" allowfullscreen webkitallowfullscreen mozAllowFullScreen frameborder="0" allow="accelerometer *; autoplay *; encrypted-media *; gyroscope *; picture-in-picture *"/>`;
}

/**
* Create the email mailto template string
* @returns {string} the mailto template
* @private
*/
_getEmailTemplate(): string {
let name = 'this video';
if (this.player.config.sources && this.player.config.sources.metadata && this.player.config.sources.metadata.name) {
name = this.player.config.sources.metadata.name;
}
const emailSubject = encodeURIComponent(`Check out ${name}`);
const emailBody = encodeURIComponent(`Check out ${name}: ${this.getShareUrl()}`);
const mailTo = `mailto:?subject=${emailSubject}&body=${emailBody}`;
return mailTo;
}

/**
* toggle start from option checkbox in the internal component state
*
Expand Down Expand Up @@ -265,10 +281,7 @@ class ShareOverlay extends BaseComponent {
<div className={style.shareIcons}>
{this._createSocialNetworks(this.props.socialNetworks)}
<Localizer>
<a
className={[style.btnRounded, style.emailShareBtn].join(' ')}
href={`mailto:?subject=${encodeURIComponent('email subject')}&body=${encodeURIComponent('email body')}`}
title={<Text id="share.email" />}>
<a className={[style.btnRounded, style.emailShareBtn].join(' ')} href={this._getEmailTemplate()} title={<Text id="share.email" />}>
<Icon type={IconType.Email} />
</a>
</Localizer>
Expand Down

0 comments on commit d8b7912

Please sign in to comment.