add top lang customize
This commit is contained in:
+54
-31
@@ -106,14 +106,13 @@ const CustomizeBadge = ({githubName, badgeOptions, onBadgeUpdate}) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const CustomizeGithubStats = ({ githubStatsOptions, onStatsUpdate }) => {
|
const CustomizeGithubStatsBase = ({ prefix, options, onUpdate }) =>
|
||||||
return (
|
|
||||||
<>
|
<>
|
||||||
<label htmlFor="github-stats-theme">Theme:
|
<label htmlFor={`${prefix}-theme`}>Theme:
|
||||||
<select
|
<select
|
||||||
id="github-stats-theme"
|
id={`${prefix}-theme`}
|
||||||
onChange={({target: { value }}) => onStatsUpdate("theme", value)}
|
onChange={({target: { value }}) => onUpdate("theme", value)}
|
||||||
value={githubStatsOptions.theme}
|
defaultValue={options.theme}
|
||||||
>
|
>
|
||||||
<option value="none">none</option>
|
<option value="none">none</option>
|
||||||
<option value="dark">Dark</option>
|
<option value="dark">Dark</option>
|
||||||
@@ -128,63 +127,63 @@ const CustomizeGithubStats = ({ githubStatsOptions, onStatsUpdate }) => {
|
|||||||
<option value="dracula">Dracula</option>
|
<option value="dracula">Dracula</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label htmlFor="github-stats-title-color">Title Color:
|
<label htmlFor={`${prefix}-title-color`}>Title Color:
|
||||||
<input
|
<input
|
||||||
type="color"
|
type="color"
|
||||||
id="github-stats-title-color"
|
id={`${prefix}-title-color`}
|
||||||
defaultValue={`#${githubStatsOptions.titleColor}`}
|
defaultValue={`#${options.titleColor}`}
|
||||||
className="w-6"
|
className="w-6"
|
||||||
onChange={(e) => onStatsUpdate('titleColor', e.target.value.replace('#', ''))}
|
onChange={(e) => onUpdate('titleColor', e.target.value.replace('#', ''))}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label htmlFor="github-stats-text-color">Text Color:
|
<label htmlFor={`${prefix}-text-color`}>Text Color:
|
||||||
<input
|
<input
|
||||||
type="color"
|
type="color"
|
||||||
id="github-stats-text-color"
|
id={`${prefix}-text-color`}
|
||||||
defaultValue={`#${githubStatsOptions.textColor}`}
|
defaultValue={`#${options.textColor}`}
|
||||||
className="w-6"
|
className="w-6"
|
||||||
onChange={(e) => onStatsUpdate('textColor', e.target.value.replace('#', ''))}
|
onChange={(e) => onUpdate('textColor', e.target.value.replace('#', ''))}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label htmlFor="github-stats-bg-color">Background Color:
|
<label htmlFor={`${prefix}-bg-color`}>Background Color:
|
||||||
<input
|
<input
|
||||||
type="color"
|
type="color"
|
||||||
id="github-stats-bg-color"
|
id={`${prefix}-bg-color`}
|
||||||
defaultValue={`#${githubStatsOptions.bgColor}`}
|
defaultValue={`#${options.bgColor}`}
|
||||||
className="w-6"
|
className="w-6"
|
||||||
onChange={(e) => onStatsUpdate('bgColor', e.target.value.replace('#', ''))}
|
onChange={(e) => onUpdate('bgColor', e.target.value.replace('#', ''))}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label htmlFor="github-stats-hide-border">Hide border:
|
<label htmlFor={`${prefix}-hide-border`}>Hide border:
|
||||||
<input
|
<input
|
||||||
id="github-stats-hide-border"
|
id={`${prefix}-hide-border`}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={githubStatsOptions.hideBorder}
|
checked={options.hideBorder}
|
||||||
onChange={(e) => onStatsUpdate('hideBorder', e.target.checked)}
|
onChange={(e) => onUpdate('hideBorder', e.target.checked)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label htmlFor="github-stats-cache-seconds">Cache Seconds:
|
<label htmlFor={`${prefix}-cache-seconds`}>Cache Seconds:
|
||||||
<input
|
<input
|
||||||
id="github-stats-cache-seconds"
|
id={`${prefix}-cache-seconds`}
|
||||||
type="number"
|
type="number"
|
||||||
min={1800}
|
min={1800}
|
||||||
max={86400}
|
max={86400}
|
||||||
placeholder={1800}
|
placeholder={1800}
|
||||||
onChange={(e) => onStatsUpdate('cacheSeconds', e.target.value)}
|
defaultValue={options.cacheSeconds}
|
||||||
|
onChange={(e) => onUpdate('cacheSeconds', e.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label htmlFor="github-stats-locale">Locale:
|
<label htmlFor={`${prefix}-locale`}>Locale:
|
||||||
<input
|
<input
|
||||||
id="github-stats-locale"
|
id={`${prefix}-locale`}
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="en"
|
placeholder="en"
|
||||||
onChange={(e) => onStatsUpdate('locale', e.target.value)}
|
defaultValue={options.locale}
|
||||||
|
onChange={(e) => onUpdate('locale', e.target.value)}
|
||||||
size="2"
|
size="2"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</>
|
</>
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const Addons = props => {
|
const Addons = props => {
|
||||||
const [debounce, setDebounce] = useState(undefined);
|
const [debounce, setDebounce] = useState(undefined);
|
||||||
@@ -212,6 +211,16 @@ const Addons = props => {
|
|||||||
})
|
})
|
||||||
}, [props.data.githubStatsOptions])
|
}, [props.data.githubStatsOptions])
|
||||||
|
|
||||||
|
const [topLanguagesOptions, setTopLanguagesOptions] = useState({
|
||||||
|
...props.data.topLanguagesOptions,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setTopLanguagesOptions({
|
||||||
|
...props.data.topLanguagesOptions
|
||||||
|
})
|
||||||
|
}, [props.data.topLanguagesOptions])
|
||||||
|
|
||||||
const blogPostPorkflow = () => {
|
const blogPostPorkflow = () => {
|
||||||
let payload = {
|
let payload = {
|
||||||
dev: {
|
dev: {
|
||||||
@@ -256,6 +265,12 @@ const Addons = props => {
|
|||||||
props.handleDataChange("githubStatsOptions", {target: {value: newStatsOptions}})
|
props.handleDataChange("githubStatsOptions", {target: {value: newStatsOptions}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onTopLangUpdate = (option, value) => {
|
||||||
|
const newLangOptions = {...topLanguagesOptions, [option]: value}
|
||||||
|
setTopLanguagesOptions(newLangOptions)
|
||||||
|
props.handleDataChange("topLanguagesOptions", {target: {value: newLangOptions}})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-start flex-col w-full px-2 sm:px-6 mb-10">
|
<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">
|
<div className="text-xl sm:text-2xl font-bold font-title mt-2 mb-2">
|
||||||
@@ -295,7 +310,7 @@ const Addons = props => {
|
|||||||
<CustomizeOptions
|
<CustomizeOptions
|
||||||
title="Customize Github Stats Card"
|
title="Customize Github Stats Card"
|
||||||
CustomizationOptions={
|
CustomizationOptions={
|
||||||
<CustomizeGithubStats githubStatsOptions={githubStatsOptions} onStatsUpdate={onStatsUpdate}/>
|
<CustomizeGithubStatsBase prefix="stats" options={githubStatsOptions} onUpdate={onStatsUpdate}/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@@ -306,6 +321,14 @@ const Addons = props => {
|
|||||||
inputId="top-languages"
|
inputId="top-languages"
|
||||||
inputChecked={props.data.topLanguages}
|
inputChecked={props.data.topLanguages}
|
||||||
onInputChange={() => props.handleCheckChange("topLanguages")}
|
onInputChange={() => props.handleCheckChange("topLanguages")}
|
||||||
|
Options={
|
||||||
|
<CustomizeOptions
|
||||||
|
title="Customize Top Skills Card"
|
||||||
|
CustomizationOptions={
|
||||||
|
<CustomizeGithubStatsBase prefix="top-lang" options={topLanguagesOptions} onUpdate={onTopLangUpdate}/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
>
|
>
|
||||||
display top skills
|
display top skills
|
||||||
</AddonsItem>
|
</AddonsItem>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { isMediumUsernameValid } from "../utils/validation"
|
import { isMediumUsernameValid } from "../utils/validation"
|
||||||
import { icons, skills, skillWebsites } from "../constants/skills"
|
import { icons, skills, skillWebsites } from "../constants/skills"
|
||||||
import { githubStatsLinkGenerator } from "../utils/link-generators"
|
import { githubStatsLinkGenerator, topLanguagesLinkGenerator } from "../utils/link-generators"
|
||||||
|
|
||||||
|
|
||||||
const Markdown = props => {
|
const Markdown = props => {
|
||||||
const Title = props => {
|
const Title = props => {
|
||||||
@@ -125,11 +124,11 @@ const Markdown = props => {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
const GitHubStats = props => {
|
const GitHubStats = ({ show, github, options }) => {
|
||||||
if (props.show) {
|
if (show) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{`<p> <img align="center" src="${githubStatsLinkGenerator(props)}" alt="${props.github}" /></p>`}
|
{`<p> <img align="center" src="${githubStatsLinkGenerator({github: github, options})}" alt="${github}" /></p>`}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
</>
|
</>
|
||||||
@@ -202,15 +201,11 @@ const Markdown = props => {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
const DisplayTopLanguages = props => {
|
const DisplayTopLanguages = props => {
|
||||||
let link =
|
|
||||||
"https://github-readme-stats.vercel.app/api/top-langs/?username=" +
|
|
||||||
props.github +
|
|
||||||
"&layout=compact"
|
|
||||||
if (props.show) {
|
if (props.show) {
|
||||||
if (!props.showStats) {
|
if (!props.showStats) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{`<p><img align="center" src="${link}" alt="${props.github}" /></p>`}
|
{`<p><img align="center" src="${topLanguagesLinkGenerator({github: props.github, options: props.options})}" alt="${props.github}" /></p>`}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
</>
|
</>
|
||||||
@@ -218,7 +213,7 @@ const Markdown = props => {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{`<p><img align="left" src="${link}" alt="${props.github}" /></p>`}
|
{`<p><img align="left" src="${topLanguagesLinkGenerator({github: props.github, options: props.options })}" alt="${props.github}" /></p>`}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
</>
|
</>
|
||||||
@@ -489,6 +484,7 @@ const Markdown = props => {
|
|||||||
show={props.data.topLanguages}
|
show={props.data.topLanguages}
|
||||||
showStats={props.data.githubStats}
|
showStats={props.data.githubStats}
|
||||||
github={props.social.github}
|
github={props.social.github}
|
||||||
|
options={props.data.topLanguagesOptions}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { icons, skills, skillWebsites } from "../constants/skills"
|
import { icons, skills, skillWebsites } from "../constants/skills"
|
||||||
import { githubStatsLinkGenerator } from "../utils/link-generators"
|
import { githubStatsLinkGenerator, topLanguagesLinkGenerator } from "../utils/link-generators"
|
||||||
|
|
||||||
const MarkdownPreview = props => {
|
const MarkdownPreview = props => {
|
||||||
const TitlePreview = props => {
|
const TitlePreview = props => {
|
||||||
@@ -273,21 +273,17 @@ const MarkdownPreview = props => {
|
|||||||
if (show) {
|
if (show) {
|
||||||
return (
|
return (
|
||||||
<div className="text-center mx-4 mb-4">
|
<div className="text-center mx-4 mb-4">
|
||||||
<img src={githubStatsLinkGenerator({github, options, show})} alt={github} />
|
<img src={githubStatsLinkGenerator({github, options})} alt={github} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const TopLanguagesPreview = props => {
|
const TopLanguagesPreview = ({github, options, show})=> {
|
||||||
let link =
|
if (show) {
|
||||||
"https://github-readme-stats.vercel.app/api/top-langs/?username=" +
|
|
||||||
props.github +
|
|
||||||
"&layout=compact"
|
|
||||||
if (props.show) {
|
|
||||||
return (
|
return (
|
||||||
<div className="text-center mx-4 mb-4">
|
<div className="text-center mx-4 mb-4">
|
||||||
<img src={link} alt={props.github} />
|
<img src={topLanguagesLinkGenerator({github, options})} alt={props.github} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -346,6 +342,7 @@ const MarkdownPreview = props => {
|
|||||||
<TopLanguagesPreview
|
<TopLanguagesPreview
|
||||||
show={props.data.topLanguages}
|
show={props.data.topLanguages}
|
||||||
github={props.social.github}
|
github={props.social.github}
|
||||||
|
options={props.data.topLanguagesOptions}
|
||||||
/>
|
/>
|
||||||
<GitHubStatsPreview
|
<GitHubStatsPreview
|
||||||
show={props.data.githubStats}
|
show={props.data.githubStats}
|
||||||
|
|||||||
+9
-2
@@ -73,6 +73,15 @@ const DEFAULT_DATA = {
|
|||||||
locale: "en",
|
locale: "en",
|
||||||
},
|
},
|
||||||
topLanguages: false,
|
topLanguages: false,
|
||||||
|
topLanguagesOptions: {
|
||||||
|
theme: "",
|
||||||
|
titleColor: "",
|
||||||
|
textColor: "",
|
||||||
|
bgColor: "",
|
||||||
|
hideBorder: false,
|
||||||
|
cacheSeconds: null,
|
||||||
|
locale: "en",
|
||||||
|
},
|
||||||
devDynamicBlogs: false,
|
devDynamicBlogs: false,
|
||||||
mediumDynamicBlogs: false,
|
mediumDynamicBlogs: false,
|
||||||
rssDynamicBlogs: false,
|
rssDynamicBlogs: false,
|
||||||
@@ -163,7 +172,6 @@ const IndexPage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleDataChange = (field, e) => {
|
const handleDataChange = (field, e) => {
|
||||||
debugger
|
|
||||||
let change = { ...data }
|
let change = { ...data }
|
||||||
change[field] = e.target.value
|
change[field] = e.target.value
|
||||||
setData(change)
|
setData(change)
|
||||||
@@ -465,7 +473,6 @@ const IndexPage = () => {
|
|||||||
setRestore("")
|
setRestore("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(data.githubStatsOptions)
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<div className="m-4 sm:p-4">
|
<div className="m-4 sm:p-4">
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
export const githubStatsLinkGenerator = ({github, options, show}) => {
|
const githubStatsStylingQueryString = options => {
|
||||||
const params = {
|
const params = {
|
||||||
username: github,
|
|
||||||
show_icons: true,
|
show_icons: true,
|
||||||
...(options.theme && options.theme !== "none") && { theme: options.theme },
|
...(options.theme && options.theme !== "none") && { theme: options.theme },
|
||||||
...options.titleColor && { "title_color": options.titleColor },
|
...options.titleColor && { "title_color": options.titleColor },
|
||||||
@@ -10,8 +9,12 @@ export const githubStatsLinkGenerator = ({github, options, show}) => {
|
|||||||
...options.cacheSeconds && { "cache_seconds": options.cacheSeconds},
|
...options.cacheSeconds && { "cache_seconds": options.cacheSeconds},
|
||||||
...options.locale && { "locale": options.locale},
|
...options.locale && { "locale": options.locale},
|
||||||
}
|
}
|
||||||
console.log(params);
|
|
||||||
const query_string = Object.entries(params).map(([key, value]) => `${key}=${value}`).join("&")
|
const query_string = Object.entries(params).map(([key, value]) => `${key}=${value}`).join("&")
|
||||||
const link = `https://github-readme-stats.vercel.app/api?${query_string}`
|
return query_string
|
||||||
return link
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const githubStatsLinkGenerator = ({github, options}) =>
|
||||||
|
`https://github-readme-stats.vercel.app/api?username=${github}&${githubStatsStylingQueryString(options)}`
|
||||||
|
|
||||||
|
export const topLanguagesLinkGenerator = ({github, options}) =>
|
||||||
|
`https://github-readme-stats.vercel.app/api/top-langs?username=${github}&${githubStatsStylingQueryString(options)}&layout=compact`
|
||||||
|
|||||||
Reference in New Issue
Block a user