UNPKG

@mornya/react-social-libs

Version:

The project of React.js Social Share and Widget modules.

44 lines (43 loc) 2.22 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import React from 'react'; import { BaseWidgetComponent } from '../utils/BaseWidgetComponent'; import { initTumblrSDK } from '../utils/Loader'; var TumblrPost = (function (_super) { __extends(TumblrPost, _super); function TumblrPost() { return _super !== null && _super.apply(this, arguments) || this; } TumblrPost.prototype.onInit = function () { this.initialize('Tumblr-Post', {}); }; TumblrPost.prototype.onRender = function (extra, OG) { var _a; var hashtags = ((_a = extra.hashtags) === null || _a === void 0 ? void 0 : _a.length) ? extra.hashtags.join(',') : ''; var locale = window.navigator.language.replace(/-/, '_'); return (React.createElement("a", { id: this.id, href: TumblrPost.LINK_URL, className: "tumblr-share-button", "data-color": "blue", "data-notes": "right", "data-posttype": "link", "data-title": OG.title, "data-content": OG.url, "data-caption": OG.description, "data-tags": hashtags, "data-locale": locale }, React.createElement("span", { style: { fontSize: 0, lineHeight: 0 } }, "Tumblr Post"))); }; TumblrPost.prototype.onMount = function (_extra) { var _this = this; initTumblrSDK() .then(function () { return _this.setApiStep(); }) .catch(console.error); }; TumblrPost.LINK_URL = 'https://embed.tumblr.com/share'; return TumblrPost; }(BaseWidgetComponent)); export default TumblrPost;