import colors from '../data/colors.json'; import { hotjar } from 'react-hotjar'; export const getInitialTheme = (themeConfig) => { if (themeConfig.disableSwitch) { return themeConfig.defaultTheme; } if ( typeof window !== 'undefined' && !(localStorage.getItem('gitprofile-theme') === null) && themeConfig.themes.includes(localStorage.getItem('gitprofile-theme')) ) { let theme = localStorage.getItem('gitprofile-theme'); return theme; } if (themeConfig.respectPrefersColorScheme && !themeConfig.disableSwitch) { return typeof window !== 'undefined' && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : themeConfig.defaultTheme; } return themeConfig.defaultTheme; }; export const skeleton = ({ width = null, height = null, style = {}, shape = 'rounded-full', className = null, }) => { return (
); }; export const languageColor = (language) => { if (typeof colors[language] !== 'undefined') { return colors[language].color; } else { return 'gray'; } }; export const fallbackImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdeg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oUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=='; export const ga = { // initialize google analytic initialize: (id) => { try { if (typeof window !== 'undefined') { window.gtag('js', new Date()); window.gtag('config', id); } } catch (error) { console.error(error); } }, // log specific events happening event: ({ action, params }) => { try { typeof window !== 'undefined' && window.gtag('event', action, params); } catch (error) { console.error(error); } }, }; export const isThemeDarkish = (theme) => { if ( theme === 'dark' || theme === 'halloween' || theme === 'forest' || theme === 'black' || theme === 'luxury' || theme === 'dracula' ) { return true; } else { return false; } }; export const setupHotjar = (hotjarConfig) => { if (hotjarConfig?.id) { let snippetVersion = hotjarConfig?.snippetVersion ? hotjarConfig?.snippetVersion : 6; hotjar.initialize(hotjarConfig.id, snippetVersion); } }; export const sanitizeConfig = (config) => { const customTheme = typeof config.themeConfig !== 'undefined' && typeof config.themeConfig.customTheme !== 'undefined' ? config.themeConfig.customTheme : { primary: '#fc055b', secondary: '#219aaf', accent: '#e8d03a', neutral: '#2A2730', 'base-100': '#E3E3ED', '--rounded-box': '3rem', '--rounded-btn': '3rem', }; const themes = typeof config.themeConfig !== 'undefined' && typeof config.themeConfig.themes !== 'undefined' ? config.themeConfig.themes : [ 'light', 'dark', 'cupcake', 'bumblebee', 'emerald', 'corporate', 'synthwave', 'retro', 'cyberpunk', 'valentine', 'halloween', 'garden', 'forest', 'aqua', 'lofi', 'pastel', 'fantasy', 'wireframe', 'black', 'luxury', 'dracula', 'cmyk', 'autumn', 'business', 'acid', 'lemonade', 'night', 'coffee', 'winter', 'procyon', ]; return { github: { username: config.github.username, sortBy: typeof config.github.sortBy !== 'undefined' ? config.github.sortBy : 'stars', limit: typeof config.github.limit !== 'undefined' ? config.github.limit : 8, exclude: { forks: typeof config.github.exclude !== 'undefined' && typeof config.github.exclude.forks !== 'undefined' ? config.github.exclude.forks : false, projects: typeof config.github.exclude !== 'undefined' && typeof config.github.exclude.projects !== 'undefined' ? config.github.exclude.projects : [], }, }, social: { linkedin: typeof config.social !== 'undefined' && typeof config.social.linkedin !== 'undefined' ? config.social.linkedin : '', twitter: typeof config.social !== 'undefined' && typeof config.social.twitter !== 'undefined' ? config.social.twitter : '', facebook: typeof config.social !== 'undefined' && typeof config.social.facebook !== 'undefined' ? config.social.facebook : '', instagram: typeof config.social !== 'undefined' && typeof config.social.instagram !== 'undefined' ? config.social.instagram : '', dribbble: typeof config.social !== 'undefined' && typeof config.social.dribbble !== 'undefined' ? config.social.dribbble : '', behance: typeof config.social !== 'undefined' && typeof config.social.behance !== 'undefined' ? config.social.behance : '', medium: typeof config.social !== 'undefined' && typeof config.social.medium !== 'undefined' ? config.social.medium : '', dev: typeof config.social !== 'undefined' && typeof config.social.dev !== 'undefined' ? config.social.dev : '', website: typeof config.social !== 'undefined' && typeof config.social.website !== 'undefined' ? config.social.website : '', phone: typeof config.social !== 'undefined' && typeof config.social.phone !== 'undefined' ? config.social.phone : '', email: typeof config.social !== 'undefined' && typeof config.social.email !== 'undefined' ? config.social.email : '', }, skills: typeof config.skills !== 'undefined' ? config.skills : [], experiences: typeof config.experiences !== 'undefined' ? config.experiences : [], education: typeof config.education !== 'undefined' ? config.education : [], blog: { source: typeof config.blog !== 'undefined' && typeof config.blog.source !== 'undefined' ? config.blog.source : '', username: typeof config.blog !== 'undefined' && typeof config.blog.username !== 'undefined' ? config.blog.username : '', limit: typeof config.blog !== 'undefined' && typeof config.blog.limit !== 'undefined' ? config.blog.limit : 5, }, googleAnalytics: { id: typeof config.googleAnalytics !== 'undefined' && typeof config.googleAnalytics.id !== 'undefined' ? config.googleAnalytics.id : '', }, hotjar: { id: typeof config.hotjar !== 'undefined' && typeof config.hotjar.id !== 'undefined' ? config.hotjar.id : '', snippetVersion: typeof config.hotjar !== 'undefined' && typeof config.hotjar.snippetVersion !== 'undefined' ? config.hotjar.snippetVersion : 6, }, themeConfig: { defaultTheme: typeof config.themeConfig !== 'undefined' && typeof config.themeConfig.defaultTheme !== 'undefined' ? config.themeConfig.defaultTheme : themes[0], disableSwitch: typeof config.themeConfig !== 'undefined' && typeof config.themeConfig.disableSwitch !== 'undefined' ? config.themeConfig.disableSwitch : false, respectPrefersColorScheme: typeof config.themeConfig !== 'undefined' && typeof config.themeConfig.respectPrefersColorScheme !== 'undefined' ? config.themeConfig.respectPrefersColorScheme : false, themes: themes, customTheme: customTheme, }, }; }; export const noConfigError = { status: 500, title: 'No Config is provided.', subTitle: 'Pass the required config as prop.', }; export const tooManyRequestError = (reset) => { return { status: 429, title: 'Too Many Requests.', subTitle: (

Oh no, you hit the{' '} rate limit. ! Try again later{` ${reset}`}.

), }; }; export const notFoundError = { status: 404, title: 'The Github Username is Incorrect.', subTitle: (

Please provide correct github username in config.

), }; export const genericError = { status: 500, title: 'Ops!!', subTitle: 'Something went wrong.', };