import React from 'react';
import PropTypes from 'prop-types';
import { icons, skills as SKILLS, skillWebsites } from '../constants/skills';
import { githubStatsLinkGenerator, topLanguagesLinkGenerator, streakStatsLinkGenerator } from '../utils/link-generators';
import { DEFAULT_DATA, DEFAULT_PREFIX, DEFAULT_SOCIAL, DEFAULT_SUPPORT } from '../constants/defaults';
export const TitlePreview = (props) => {
const { prefix, title } = props;
if (prefix && title) {
return
{`${prefix} ${title}`}
;
}
return null;
};
TitlePreview.propTypes = {
prefix: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
};
export const SubTitlePreview = (props) => {
const { subtitle } = props;
if (subtitle) {
return {subtitle}
;
}
return null;
};
SubTitlePreview.propTypes = {
subtitle: PropTypes.string.isRequired,
};
export const SectionTitle = (props) => {
const { visible, label } = props;
if (!visible) return null;
if (label) {
return {label}
;
}
return null;
};
SectionTitle.defaultProps = {
visible: false,
};
SectionTitle.propTypes = {
visible: PropTypes.bool,
label: PropTypes.string.isRequired,
};
export const DisplayWork = (props) => {
const { prefix, project, link } = props;
if (prefix && project) {
if (link) {
return (
);
}
return (
{`${prefix} `}
{project}
);
}
if (prefix && link) {
return (
);
}
return null;
};
DisplayWork.defaultProps = {
prefix: '',
project: '',
link: '',
};
DisplayWork.propTypes = {
prefix: PropTypes.string,
project: PropTypes.string,
link: PropTypes.string,
};
export const WorkPreview = (props) => {
const { work } = props;
const { prefix, data, link } = work;
return (
<>
>
);
};
WorkPreview.propTypes = {
work: PropTypes.object.isRequired,
};
export const DisplaySocial = (props) => {
const { username, base, icon } = props;
if (username) {
return (
);
}
return null;
};
DisplaySocial.defaultProps = {
username: '',
base: '',
icon: '',
};
DisplaySocial.propTypes = {
username: PropTypes.string,
base: PropTypes.string,
icon: PropTypes.string,
};
export const SocialPreview = (props) => {
const { social } = props;
let viewSocial = false;
const iconBaseUrl = 'https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/';
Object.keys(social).forEach((key) => {
if (social[key] && key !== 'github') viewSocial = true;
});
return (
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
<>
>
);
};
SocialPreview.propTypes = {
social: PropTypes.object.isRequired,
};
export const VisitorsBadgePreview = (props) => {
const { github, show, badgeOptions } = props;
const link = `https://komarev.com/ghpvc/?username=${github}&label=${badgeOptions.badgeLabel}&color=${badgeOptions.badgeColor}&style=${badgeOptions.badgeStyle}`;
if (show) {
return (
{' '}

{' '}
);
}
return null;
};
VisitorsBadgePreview.defaultProps = {
github: '',
show: false,
badgeOptions: {},
};
VisitorsBadgePreview.propTypes = {
github: PropTypes.string,
show: PropTypes.bool,
badgeOptions: PropTypes.object,
};
export const TwitterBadgePreview = (props) => {
const { twitter, show } = props;
const link = `https://img.shields.io/twitter/follow/${twitter}?logo=twitter&style=for-the-badge`;
if (show) {
return (
{' '}
{' '}
);
}
return null;
};
TwitterBadgePreview.defaultProps = {
twitter: '',
show: false,
};
TwitterBadgePreview.propTypes = {
twitter: PropTypes.string,
show: PropTypes.bool,
};
export const GithubProfileTrophyPreview = (props) => {
const { github, show } = props;
const link = `https://github-profile-trophy.vercel.app/?username=${github}`;
if (show) {
return (
{' '}
{' '}
);
}
return null;
};
GithubProfileTrophyPreview.defaultProps = {
github: '',
show: false,
};
GithubProfileTrophyPreview.propTypes = {
github: PropTypes.string,
show: PropTypes.bool,
};
export const GitHubStatsPreview = ({ github, options, show }) => {
if (show) {
return (
);
}
return null;
};
GitHubStatsPreview.defaultProps = {
github: '',
options: {},
show: false,
};
GitHubStatsPreview.propTypes = {
github: PropTypes.string,
options: PropTypes.object,
show: PropTypes.bool,
};
export const TopLanguagesPreview = ({ github, options, show }) => {
if (show) {
return (
);
}
return
;
};
TopLanguagesPreview.defaultProps = {
github: '',
options: {},
show: false,
};
TopLanguagesPreview.propTypes = {
github: PropTypes.string,
options: PropTypes.object,
show: PropTypes.bool,
};
export const StreakStatsPreview = ({ github, options, show }) => {
if (show) {
return (
);
}
return null;
};
StreakStatsPreview.defaultProps = {
github: '',
options: {},
show: false,
};
StreakStatsPreview.propTypes = {
github: PropTypes.string,
options: PropTypes.object,
show: PropTypes.bool,
};
export const SkillsPreview = (props) => {
const { skills } = props;
const listSkills = [];
SKILLS.forEach((skill) => {
if (skills[skill]) {
listSkills.push(
,
);
}
});
return listSkills.length > 0 ? (
{listSkills}
) : (
''
);
};
SkillsPreview.propTypes = {
skills: PropTypes.array.isRequired,
};
export const SupportPreview = (props) => {
const { support } = props;
let viewSupport = false;
Object.keys(support).forEach((key) => {
if (support[key]) {
viewSupport = true;
}
});
return support.buyMeACoffee || support.buyMeAKofi ? (
{support.buyMeACoffee && (
)}
{support.buyMeAKofi && (
)}
) : (
''
);
};
SupportPreview.propTypes = {
support: PropTypes.object.isRequired,
};
const MarkdownPreview = (props) => {
const { prefix, data, social, skills, support } = props;
return (
);
};
export default MarkdownPreview;
MarkdownPreview.defaultProps = {
prefix: DEFAULT_PREFIX,
data: DEFAULT_DATA,
social: DEFAULT_SOCIAL,
support: DEFAULT_SUPPORT,
skills: [],
};
MarkdownPreview.propTypes = {
prefix: PropTypes.object,
data: PropTypes.object,
social: PropTypes.object,
skills: PropTypes.object,
support: PropTypes.object,
};