thank-you-tweet-button-001
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -5,4 +5,5 @@ import React from "react"; | ||
number?: number; | ||
rating: number; | ||
} | ||
export default function TweetButton(props: TweetButtonPropsType): React.JSX.Element; | ||
export {}; |
@@ -8,7 +8,26 @@ "use strict"; | ||
require("../index.css"); | ||
function generateStarIcons(rating) { | ||
var megaStars = "\u2B50\u2B50\u2B50\u2B50\u2B50 x ".concat(Math.round(rating / 5)); | ||
var stars = ""; | ||
for (var i = 0; i < rating; i++) { | ||
stars += "⭐"; | ||
} | ||
return rating > 10 ? megaStars : stars; | ||
} | ||
function TweetButton(props) { | ||
var tweetURL = "https://twitter.com/intent/tweet?text=Thank+you,+%40oluwatobiss.+Your+book+helped+me+create,+test,+and+publish+".concat(props.number && props.number > 1 ? props.number : "an", "+NPM+").concat(props.number && props.number > 1 ? "packages" : "package", ".%0A%0ACreating%20NPM%20Package:%20React%20TypeScript%20Guide%0A%0Ahttps%3A%2F%2Famzn.to/3qxnEdF"); | ||
return (react_1.default.createElement("section", { className: "tweet-btn-container" }, | ||
react_1.default.createElement("a", { className: "tweet-button", href: tweetURL, target: "_blank" }, "Send a thank you tweet"))); | ||
var tweetURL = "https://twitter.com/intent/tweet?text=Thank+you,+%40oluwatobiss.+Your+book+helped+me+create,+test,+and+publish+".concat(props.number && props.number > 1 ? props.number : "an", "+NPM+").concat(props.number && props.number > 1 ? "packages" : "package", ".%0A%0AI'm+giving+it+a+").concat(props.rating, "-star+rating!+").concat(generateStarIcons(props.rating), "+%0A%0ACreating%20NPM%20Package:%20React%20TypeScript%20Guide%0A%0Ahttps%3A%2F%2Famzn.to/3qxnEdF"); | ||
return props.rating ? (react_1.default.createElement("section", { className: "tweet-btn-container" }, | ||
react_1.default.createElement("a", { className: "tweet-button", href: tweetURL, target: "_blank" }, "Send a thank you tweet"))) : (react_1.default.createElement("div", { style: { | ||
display: "flex", | ||
justifyContent: "center", | ||
marginTop: "30px", | ||
} }, | ||
react_1.default.createElement("p", { style: { | ||
backgroundColor: "#DC3545", | ||
color: "#fff", | ||
width: "35%", | ||
borderRadius: "5px", | ||
padding: "15px 20px", | ||
} }, "\u24D8 Error: Props 'rating' is missing in 'TweetButtonPropsType'."))); | ||
} | ||
exports.default = TweetButton; |
@@ -5,4 +5,5 @@ import React from "react"; | ||
number?: number; | ||
rating: number; | ||
} | ||
export default function TweetButton(props: TweetButtonPropsType): React.JSX.Element; | ||
export {}; |
import React from "react"; | ||
import "../index.css"; | ||
function generateStarIcons(rating) { | ||
var megaStars = "\u2B50\u2B50\u2B50\u2B50\u2B50 x ".concat(Math.round(rating / 5)); | ||
var stars = ""; | ||
for (var i = 0; i < rating; i++) { | ||
stars += "⭐"; | ||
} | ||
return rating > 10 ? megaStars : stars; | ||
} | ||
export default function TweetButton(props) { | ||
var tweetURL = "https://twitter.com/intent/tweet?text=Thank+you,+%40oluwatobiss.+Your+book+helped+me+create,+test,+and+publish+".concat(props.number && props.number > 1 ? props.number : "an", "+NPM+").concat(props.number && props.number > 1 ? "packages" : "package", ".%0A%0ACreating%20NPM%20Package:%20React%20TypeScript%20Guide%0A%0Ahttps%3A%2F%2Famzn.to/3qxnEdF"); | ||
return (React.createElement("section", { className: "tweet-btn-container" }, | ||
React.createElement("a", { className: "tweet-button", href: tweetURL, target: "_blank" }, "Send a thank you tweet"))); | ||
var tweetURL = "https://twitter.com/intent/tweet?text=Thank+you,+%40oluwatobiss.+Your+book+helped+me+create,+test,+and+publish+".concat(props.number && props.number > 1 ? props.number : "an", "+NPM+").concat(props.number && props.number > 1 ? "packages" : "package", ".%0A%0AI'm+giving+it+a+").concat(props.rating, "-star+rating!+").concat(generateStarIcons(props.rating), "+%0A%0ACreating%20NPM%20Package:%20React%20TypeScript%20Guide%0A%0Ahttps%3A%2F%2Famzn.to/3qxnEdF"); | ||
return props.rating ? (React.createElement("section", { className: "tweet-btn-container" }, | ||
React.createElement("a", { className: "tweet-button", href: tweetURL, target: "_blank" }, "Send a thank you tweet"))) : (React.createElement("div", { style: { | ||
display: "flex", | ||
justifyContent: "center", | ||
marginTop: "30px", | ||
} }, | ||
React.createElement("p", { style: { | ||
backgroundColor: "#DC3545", | ||
color: "#fff", | ||
width: "35%", | ||
borderRadius: "5px", | ||
padding: "15px 20px", | ||
} }, "\u24D8 Error: Props 'rating' is missing in 'TweetButtonPropsType'."))); | ||
} |
{ | ||
"name": "thank-you-tweet-button-001", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "Easy-to-use tweet button for saying thank you to @oluwatobiss.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/TweetButton.js", |
@@ -14,2 +14,3 @@ > **Note** | ||
- A button that posts a thank you message | ||
- Display total published NPM packages | ||
@@ -16,0 +17,0 @@ ## Live Demo |
8020
97
62