UNPKG

thank-you-tweet-button-004

Version:

Easy-to-use tweet button for saying thank you to @oluwatobiss.

23 lines (22 loc) 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tweetButton = tweetButton; const generateStarIcons_ts_1 = require("./generateStarIcons.js"); const showError_ts_1 = require("./showError.js"); function tweetButton(rating, bestNPMPackage, quantity) { const tweetButtonContainer = document.createElement("section"); const anchorElement = document.createElement("a"); const anchorElementContent = document.createTextNode("Post a thank you message"); const tweetUrl = `https://twitter.com/intent/tweet?text=Thank+you,+ %40oluwatobiss.+Your+book+helped+me+create,+test,+and+publish+${quantity && quantity > 1 ? quantity : "an"}+NPM+${quantity && quantity > 1 ? "packages" : "package"}.%0A%0AMy+Favorite:+${bestNPMPackage}%0A%0ABook's+Rating:+${rating}- star+rating!+${(0, generateStarIcons_ts_1.generateStarIcons)(rating)}%0A%0Ahttps%3A%2F%2Famzn.to/4lifL3n`; tweetButtonContainer.setAttribute("id", "tweet-btn-container"); anchorElement.setAttribute("class", "tweet-button"); anchorElement.setAttribute("target", "_blank"); anchorElement.setAttribute("href", tweetUrl); anchorElement.appendChild(anchorElementContent); tweetButtonContainer.appendChild(anchorElement); return typeof rating === "number" && bestNPMPackage ? tweetButtonContainer : (0, showError_ts_1.showError)(); }