Merge branch 'master' into patch-5

This commit is contained in:
Rahul Jain
2020-10-04 10:15:35 +05:30
committed by GitHub
7 changed files with 243 additions and 25 deletions
+128 -12
View File
@@ -1,26 +1,110 @@
import React from "react"
import React, { useState, useEffect } from "react"
import { withPrefix } from "gatsby"
import { latestBlogs } from "../utils/workflows"
import links from "../constants/page-links"
import { isMediumUsernameValid } from "../utils/validation"
import { isMediumUsernameValid, isGitHubUsernameValid } from "../utils/validation"
import { ToolsIcon, XCircleIcon } from "@primer/octicons-react";
const AddonsItem = ({inputId, inputChecked, onInputChange, ...props}) => {
const AddonsItem = ({inputId, inputChecked, onInputChange, Icon, onIconClick, ...props}) => {
return (
<div className="py-2 flex justify-start items-center text-sm sm:text-lg">
<label htmlFor={inputId} className="cursor-pointer flex items-center">
<input
type="checkbox"
id={inputId}
checked={inputChecked}
onChange={onInputChange}
<div className="py-2 flex justify-start items-center text-sm sm:text-lg">
<label htmlFor={inputId} className="cursor-pointer flex items-center">
<input
type="checkbox"
id={inputId}
checked={inputChecked}
onChange={onInputChange}
/>
<span className="pl-4">{props.children}</span>
</label>
{
Icon?
<button onClick={onIconClick} className="flex ml-3 focus:bg-gray-400" style={{outline: "none"}}>
<Icon className="transform scale-100 md:scale-125" />
</button>
:''
}
</div>
)
}
const CustomizeBadge = ({githubName, badgeOptions, onBadgeUpdate}) => {
return (
<div className={`border-2 border-solid border-gray-900 bg-gray-100 p-2 ml-8`} style={{maxWidth: '21rem'}}>
<header className="text-base sm:text-lg">Customize Badge</header>
<hr className="border-gray-500"/>
<div className="text-sm sm:text-lg flex flex-col mt-2 ml-0 md:ml-4">
<label htmlFor="badge-style">Style:&nbsp;
<select
id="badge-style"
onChange={(e) => onBadgeUpdate('badgeStyle', e.target.value)}
value = {badgeOptions.badgeStyle}
>
<option value="flat">Flat</option>
<option value="flat-square">Flat Square</option>
<option value="plastic">Plastic</option>
</select>
</label>
<label htmlFor="badge-color">Color:&nbsp;
<input
type="color"
id="badge-color"
defaultValue={`#${badgeOptions.badgeColor}`}
className="w-6"
onChange={(e) => onBadgeUpdate('badgeColor', e.target.value.replace('#', ''))}
/>
</label>
<label htmlFor="badge-label-text">Label Text:&nbsp;
<input
type="text"
id="badge-label-text"
placeholder="Profile views"
className="w-2/4 bg-gray-300 pl-2"
onChange={(e) => onBadgeUpdate('badgeLabel', e.target.value.trim())}
defaultValue={badgeOptions.badgeLabel}
/>
</label>
<span className="mt-2 flex items-center">
Preview:&nbsp;
{
isGitHubUsernameValid(githubName)?
<img
src={`https://komarev.com/ghpvc/`
+ `?username=${githubName}`
+ `&label=${encodeURI(badgeOptions.badgeLabel)}`
+ `&color=${badgeOptions.badgeColor}`
+ `&style=${badgeOptions.badgeStyle}`
}
/>
<span className="pl-4">{props.children}</span>
</label>
: <span className="text-xxs md:text-sm text-red-600">Invalid GitHub username</span>
}
</span>
</div>
</div>
)
}
const Addons = props => {
const [customizeBadgeOpen, setCustomizeOpen] = useState(false);
const [debounce, setDebounce] = useState(undefined);
const [badgeOptions, setBadgeOptions] = useState({
badgeStyle: props.data.badgeStyle,
badgeColor: props.data.badgeColor,
badgeLabel: props.data.badgeLabel
});
useEffect(() => {
setBadgeOptions({
badgeStyle: props.data.badgeStyle,
badgeColor: props.data.badgeColor,
badgeLabel: props.data.badgeLabel
})
}, [props.data.badgeStyle, props.data.badgeColor, props.data.badgeLabel])
const blogPostPorkflow = () => {
let payload = {
dev: {
@@ -48,6 +132,20 @@ const Addons = props => {
tempElement.click()
document.body.removeChild(tempElement)
}
const onCustomizeClick = () => {
setCustomizeOpen(!customizeBadgeOpen);
}
const onBadgeUpdate = (option, value) => {
const callback = () => {
let newVal = (option==='badgeLabel' && value==='')?'Profile views':value;
setBadgeOptions({...badgeOptions, [option]: newVal});
props.handleDataChange(option, {target: {value: newVal}})
}
clearTimeout(debounce);
setDebounce(setTimeout(callback, 300));
}
return (
<div className="flex justify-center items-start flex-col w-full px-2 sm:px-6 mb-10">
<div className="text-xl sm:text-2xl font-bold font-title mt-2 mb-2">
@@ -57,9 +155,27 @@ const Addons = props => {
inputId="visitors-count"
inputChecked={props.data.visitorsBadge}
onInputChange={() => props.handleCheckChange("visitorsBadge")}
Icon={ customizeBadgeOpen ? XCircleIcon : ToolsIcon }
onIconClick={onCustomizeClick}
>
display visitors count badge
</AddonsItem>
{
customizeBadgeOpen?
<CustomizeBadge
githubName={props.social.github}
badgeOptions={badgeOptions}
onBadgeUpdate={onBadgeUpdate}
/>
: ''
}
<AddonsItem
inputId="github-profile-trophy"
inputChecked={props.data.githubProfileTrophy}
onInputChange={() => props.handleCheckChange("githubProfileTrophy")}
>
display github trophy
</AddonsItem>
<AddonsItem
inputId="github-stats"
inputChecked={props.data.githubStats}
+40 -3
View File
@@ -80,7 +80,11 @@ const Markdown = props => {
return ""
}
const VisitorsBadge = props => {
let link = "https://komarev.com/ghpvc/?username=" + props.github
let link = "https://komarev.com/ghpvc/?username="
+ props.github
+ `&label=${props.badgeOptions.badgeLabel}`
+ `&color=${props.badgeOptions.badgeColor}`
+ `&style=${props.badgeOptions.badgeStyle}`
if (props.show) {
return (
<>
@@ -92,7 +96,7 @@ const Markdown = props => {
}
return ""
}
const TwitterBadge = props => {
const TwitterBadge = props => {
let link = "https://img.shields.io/twitter/follow/" + props.twitter + "?logo=twitter&style=for-the-badge"
if (props.show) {
return (
@@ -105,6 +109,20 @@ const Markdown = props => {
}
return ""
}
const GithubProfileTrophy = props => {
let link =
"https://github-profile-trophy.vercel.app/?username=" + props.github
if (props.show) {
return (
<>
{`<p align="left"> <a href="https://github.com/ryo-ma/github-profile-trophy"><img src="${link}" alt="${props.github}" /></a> </p>`}
<br />
<br />
</>
)
}
return ""
}
const GitHubStats = props => {
let link =
"https://github-readme-stats.vercel.app/api?username=" +
@@ -222,6 +240,17 @@ const Markdown = props => {
<VisitorsBadge
show={props.data.visitorsBadge}
github={props.social.github}
badgeOptions={{
badgeLabel: encodeURI(props.data.badgeLabel),
badgeColor: props.data.badgeColor,
badgeStyle: props.data.badgeStyle
}}
/>
</>
<>
<GithubProfileTrophy
show={props.data.githubProfileTrophy}
github={props.social.github}
/>
<TwitterBadge
show={props.data.twitterBadge}
@@ -441,7 +470,15 @@ const Markdown = props => {
username={props.social.rssurl}
/>
</>
{isSocial(props.social) ? <>{`</p>`}<br/><br/></> : ""}
{isSocial(props.social) ? (
<>
{`</p>`}
<br />
<br />
</>
) : (
""
)}
<>
<DisplaySkills skills={props.skills} />
</>
+30 -2
View File
@@ -222,7 +222,11 @@ const MarkdownPreview = props => {
)
}
const VisitorsBadgePreview = props => {
let link = "https://komarev.com/ghpvc/?username=" + props.github
let link = "https://komarev.com/ghpvc/?username="
+ props.github
+ `&label=${props.badgeOptions.badgeLabel}`
+ `&color=${props.badgeOptions.badgeColor}`
+ `&style=${props.badgeOptions.badgeStyle}`
if (props.show) {
return (
<div className="text-left my-2">
@@ -233,7 +237,7 @@ const MarkdownPreview = props => {
}
return null
}
const TwitterBadgePreview = props => {
const TwitterBadgePreview = props => {
let link = "https://img.shields.io/twitter/follow/" + props.twitter + "?logo=twitter&style=for-the-badge"
if (props.show) {
return (
@@ -245,6 +249,21 @@ const MarkdownPreview = props => {
}
return null
}
const GithubProfileTrophyPreview = props => {
let link =
"https://github-profile-trophy.vercel.app/?username=" + props.github
if (props.show) {
return (
<div className="text-left my-2">
{" "}
<a href="https://github.com/ryo-ma/github-profile-trophy">
<img src={link} alt={props.github} />
</a>{" "}
</div>
)
}
return null
}
const GitHubStatsPreview = props => {
let link =
"https://github-readme-stats.vercel.app/api?username=" +
@@ -305,6 +324,15 @@ const MarkdownPreview = props => {
<VisitorsBadgePreview
show={props.data.visitorsBadge}
github={props.social.github}
badgeOptions={{
badgeLabel: encodeURI(props.data.badgeLabel),
badgeColor: props.data.badgeColor,
badgeStyle: props.data.badgeStyle
}}
/>
<GithubProfileTrophyPreview
show={props.data.githubProfileTrophy}
github={props.social.github}
/>
<TwitterBadgePreview
show={props.data.twitterBadge}
+13 -2
View File
@@ -56,6 +56,7 @@ const categorizedSkills = {
"nodejs",
"spring",
"express",
"graphql",
"kafka",
"solr",
"rabbitMQ",
@@ -171,6 +172,11 @@ const categorizedSkills = {
skills: ["gatsby", "gridsome", "hugo", "jekyll", "nextjs", "nuxtjs"],
},
game_engines:{
title: "Game Engines",
skills: ["unity"],
},
other: {
title: "Other",
skills: ["linux", "git"],
@@ -217,6 +223,7 @@ const icons = {
express:
"https://devicons.github.io/devicon/devicon.git/icons/express/express-original-wordmark.svg",
go: "https://devicons.github.io/devicon/devicon.git/icons/go/go-original.svg",
graphql: "https://www.vectorlogo.zone/logos/graphql/graphql-icon.svg",
gulp:
"https://devicons.github.io/devicon/devicon.git/icons/gulp/gulp-plain.svg",
html5:
@@ -368,7 +375,9 @@ const icons = {
elasticsearch:
"https://www.vectorlogo.zone/logos/elastic/elastic-icon.svg",
circleci:
"https://www.vectorlogo.zone/logos/circleci/circleci-icon.svg"
"https://www.vectorlogo.zone/logos/circleci/circleci-icon.svg",
unity:
"https://www.vectorlogo.zone/logos/unity3d/unity3d-icon.svg"
}
const skillWebsites = {
@@ -393,6 +402,7 @@ const skillWebsites = {
electron: "https://www.electronjs.org",
express: "https://expressjs.com",
go: "https://golang.org",
graphql: "https://graphql.org",
gulp: "https://gulpjs.com",
html5: "https://www.w3.org/html/",
hugo: "https://gohugo.io/",
@@ -489,7 +499,8 @@ const skillWebsites = {
kibana: "https://www.elastic.co/kibana",
grafana: "https://grafana.com",
elasticsearch: "https://www.elastic.co",
circleci: "https://circleci.com"
circleci: "https://circleci.com",
unity: "https://unity.com/"
}
const initialSkillState = {}
Binary file not shown.

After

Width:  |  Height:  |  Size: 419 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" version="1"><rect width="28" height="28" x="-30" y="-30" fill="#26557c" rx="1.4" ry="1.4" transform="matrix(0,-1,-1,0,0,0)"/><path d="m8.0254 8.0001c-0.7825-0.0166-1.1494 0.5244-0.9883 1.457 0.052 0.3006 0.3152 0.7299 0.8828 1.4419 0.63122 0.7909 0.88514 1.2227 1.1602 1.9707 0.4336 1.1793 0.63403 1.5748 0.98633 1.9434 0.27366 0.2863 0.27369 0.28712 0.08984 0.87109-0.28507 0.90556-0.34407 2.7207-0.11523 3.5742 0.34248 1.2774 0.76402 1.8574 1.3516 1.8574 0.41968 0 0.76364-0.35092 0.88672-0.9043 0.04268-0.19186 0.12249-0.46607 0.17773-0.60938 0.09535-0.24728 0.12093-0.22818 0.49414 0.38086 0.21628 0.35296 0.62866 0.87861 0.91602 1.168 0.6638 0.66845 1.5749 1.4217 1.6406 1.3574 0.02775-0.02713-0.238-0.42177-0.58984-0.87891s-1.0151-1.5189-1.4746-2.3594c-0.53593-0.98029-0.8997-1.5286-1.0137-1.5293-0.37045-0.0025-0.71588 0.58004-0.91602 1.5469-0.23056 1.1138-0.63675 0.92708-0.9668-0.44531-0.19019-0.79085-0.09106-1.856 0.26367-2.8535 0.16137-0.45376 0.29297-0.87373 0.29297-0.93164s-0.25731-0.54348-0.57227-1.0801c-0.315-0.537-0.6851-1.297-0.822-1.69-0.3326-0.954-0.4905-1.232-1.1582-2.043-0.6879-0.8346-0.753-1.2203-0.2051-1.2166 0.42554 0.00281 1.1123 0.28944 1.8027 0.75391 0.4371 0.29404 0.58523 0.33398 1.2871 0.33398 0.88142 0 1.0709 0.0722 2.293 0.87695 1.2445 0.81958 2.1722 1.5813 2.8145 2.3125 0.5704 0.64937 0.88201 1.2138 2.5605 4.6562 0.64433 1.3214 1.2158 1.9593 2.0039 2.2324 1.2173 0.42185 1.6317 0.61314 2.168 0.99805l0.56641 0.40625-0.38086 0.07422c-0.2103 0.04033-0.66847 0.10616-1.0176 0.14648-0.72741 0.084-1.2031 0.38573-1.2031 0.76367 0 0.42592 1.4513 1.6453 2.9062 2.4414 0.69903 0.38247 1.3716 0.75927 1.4941 0.83789 0.32598 0.20922 0.41424 0.18389 0.33008-0.0918-0.17624-0.57738-0.77279-1.1398-2.4297-2.2949-0.97197-0.6776-0.98199-0.65244 0.31641-0.78125 0.925-0.091 1.392-0.249 1.392-0.472 0-0.102-0.47-0.644-1.045-1.203-0.9-0.876-1.204-1.094-2.195-1.577-1.35-0.656-1.842-1.177-2.153-2.283-0.464-1.649-1.712-3.587-3.371-5.23-1.712-1.696-3.347-2.6344-4.845-2.7814-0.609-0.0598-0.924-0.1522-1.239-0.3653-0.5332-0.3611-1.7717-0.7684-2.3766-0.7812zm2.9629 3.002c-0.12266-0.0079-0.22945 0.0085-0.30273 0.05859-0.27341 0.18699-0.24099 0.41504 0.08008 0.55664 0.15092 0.06656 0.36501 0.30147 0.47656 0.52148 0.3751 0.73978 0.94985 0.2445 0.69336-0.59766-0.08085-0.26546-0.5793-0.51547-0.94727-0.53906z" opacity=".2"/><path fill="#fff" d="m8.0254 7c-0.7825-0.0166-1.1494 0.5244-0.9883 1.457 0.052 0.3006 0.3152 0.7302 0.8828 1.4414 0.6312 0.7906 0.8852 1.2226 1.1602 1.9706 0.4336 1.179 0.634 1.575 0.9859 1.943 0.274 0.287 0.274 0.288 0.09 0.872-0.2848 0.905-0.3438 2.72-0.115 3.574 0.342 1.277 0.764 1.857 1.352 1.857 0.419 0 0.763-0.351 0.886-0.904 0.043-0.192 0.123-0.466 0.178-0.609 0.095-0.248 0.121-0.229 0.494 0.38 0.216 0.353 0.629 0.879 0.916 1.168 0.664 0.669 1.575 1.422 1.641 1.358 0.028-0.027-0.238-0.422-0.59-0.879s-1.015-1.519-1.475-2.359c-0.536-0.981-0.899-1.529-1.013-1.53-0.371-0.002-0.716 0.58-0.916 1.547-0.231 1.114-0.637 0.927-0.967-0.445-0.19-0.791-0.091-1.856 0.264-2.854 0.161-0.453 0.293-0.873 0.293-0.931s-0.258-0.544-0.573-1.08c-0.315-0.537-0.6851-1.297-0.822-1.69-0.3326-0.954-0.4905-1.232-1.1582-2.0429-0.6879-0.8348-0.753-1.2204-0.2051-1.2168 0.4255 0.0029 1.1123 0.2895 1.8023 0.7539 0.438 0.2941 0.586 0.334 1.288 0.334 0.881 0 1.07 0.0722 2.293 0.877 1.244 0.8198 2.172 1.5818 2.814 2.3128 0.57 0.649 0.882 1.214 2.561 4.656 0.644 1.321 1.215 1.959 2.003 2.232 1.218 0.422 1.632 0.613 2.168 0.998l0.567 0.407-0.381 0.074c-0.21 0.04-0.669 0.106-1.018 0.146-0.727 0.084-1.203 0.386-1.203 0.764 0 0.426 1.451 1.645 2.906 2.441 0.7 0.383 1.372 0.76 1.495 0.838 0.326 0.21 0.414 0.184 0.33-0.091-0.177-0.578-0.773-1.14-2.43-2.295-0.972-0.678-0.982-0.653 0.316-0.782 0.926-0.092 1.393-0.25 1.393-0.472 0-0.102-0.47-0.644-1.045-1.203-0.9-0.877-1.204-1.094-2.195-1.577-1.35-0.656-1.842-1.177-2.153-2.283-0.464-1.65-1.712-3.587-3.371-5.23-1.712-1.6965-3.347-2.6345-4.845-2.7815-0.609-0.0598-0.924-0.1522-1.239-0.3653-0.5332-0.3611-1.7717-0.7684-2.3766-0.7812zm2.9626 3.002c-0.122-0.0079-0.229 0.008-0.302 0.059-0.274 0.187-0.241 0.415 0.08 0.556 0.151 0.067 0.365 0.302 0.476 0.522 0.375 0.739 0.95 0.244 0.694-0.598-0.081-0.265-0.58-0.515-0.948-0.539z"/><path fill="#fff" d="m3.4004 2c-0.7756 0-1.4004 0.6248-1.4004 1.4004v1c0-0.7756 0.6248-1.4004 1.4004-1.4004h25.2c0.775 0 1.4 0.6248 1.4 1.4004v-1c0-0.7756-0.625-1.4004-1.4-1.4004h-25.2z" opacity=".1"/><path d="m2 28.6v1c0 0.775 0.6248 1.4 1.4004 1.4h25.2c0.775 0 1.4-0.625 1.4-1.4v-1c0 0.775-0.625 1.4-1.4 1.4h-25.2c-0.7752 0-1.4-0.625-1.4-1.4z" opacity=".2"/></svg>

After

Width:  |  Height:  |  Size: 4.5 KiB

+31 -6
View File
@@ -53,7 +53,12 @@ const DEFAULT_DATA = {
ama: "",
contact: "",
funFact: "",
twitterBadge: false,
visitorsBadge: false,
badgeStyle: "flat",
badgeColor: "0e75b6",
badgeLabel: "Profile views",
githubProfileTrophy: false,
githubStats: false,
topLanguages: false,
devDynamicBlogs: false,
@@ -221,10 +226,19 @@ const IndexPage = () => {
trimDataValues(social, setSocial)
trimDataValues(link, setLink)
resetCopyMarkdownButton()
if (data.visitorsBadge || data.githubStats || data.topLanguages) {
if (
data.visitorsBadge ||
data.githubProfileTrophy ||
data.githubStats ||
data.topLanguages
) {
if (social.github && isGitHubUsernameValid(social.github)) {
generate()
}
} else if (data.twitterBadge) {
if (social.twitter)) {
generate()
}
} else if (social.github) {
if (isGitHubUsernameValid(social.github)) {
generate()
@@ -359,10 +373,10 @@ const IndexPage = () => {
return
}
setPrefix(cache.prefix || DEFAULT_PREFIX)
setData(cache.data || DEFAULT_DATA)
setLink(cache.link || DEFAULT_LINK)
setSocial(cache.social || DEFAULT_SOCIAL)
setPrefix(cache.prefix ? {...DEFAULT_PREFIX, ...cache.prefix} : DEFAULT_PREFIX)
setData(cache.data ? {...DEFAULT_DATA, ...cache.data} : DEFAULT_DATA)
setLink(cache.link ? {...DEFAULT_LINK, ...cache.link} : DEFAULT_LINK)
setSocial(cache.social ? {...DEFAULT_SOCIAL, ...cache.social} : DEFAULT_SOCIAL)
const cacheSkills = mergeDefaultWithNewDataSkills(
DEFAULT_SKILLS,
@@ -464,9 +478,13 @@ const IndexPage = () => {
data={data}
social={social}
handleCheckChange={handleCheckChange}
handleDataChange={handleDataChange}
/>
<div className="section">
{(data.visitorsBadge || data.githubStats || data.topLanguages) &&
{(data.visitorsBadge ||
data.githubProfileTrophy ||
data.githubStats ||
data.topLanguages) &&
!social.github ? (
<div className="warning">
* Please add github username to use these add-ons
@@ -511,6 +529,13 @@ const IndexPage = () => {
) : (
""
)}
{(data.twitterBadge && !social.twitter ? (
<div className="warning">
* Please add twitter username to use these add-ons
</div>
) : (
""
)}
</div>
<div className="flex items-center justify-center w-full">
<div