Rename themeConfig.default to themeConfig.defaultTheme

This commit is contained in:
Ariful Alam 2022-03-26 18:23:09 +06:00
parent 59a9a2fac4
commit 4cb107e168
5 changed files with 101 additions and 16 deletions

View File

@ -147,14 +147,14 @@ const config = {
snippetVersion: 6, snippetVersion: 6,
}, },
themeConfig: { themeConfig: {
default: 'light', defaultTheme: 'light',
// Hides the theme change switch // Hides the theme change switch
// Useful if you want to support a single color mode // Useful if you want to support a single color mode
disableSwitch: false, disableSwitch: false,
// Should we use the prefers-color-scheme media-query, // Should we use the prefers-color-scheme media-query,
// using user system preferences, instead of the hardcoded default // using user system preferences, instead of the hardcoded defaultTheme
respectPrefersColorScheme: true, respectPrefersColorScheme: true,
// Available themes. To remove any theme, exclude from here. // Available themes. To remove any theme, exclude from here.
@ -220,7 +220,7 @@ The default theme can be specified.
module.exports = { module.exports = {
// ... // ...
themeConfig: { themeConfig: {
default: 'light', defaultTheme: 'light',
// ... // ...
}, },
}; };

View File

@ -311,7 +311,7 @@ GitProfile.propTypes = {
snippetVersion: PropTypes.number, snippetVersion: PropTypes.number,
}), }),
themeConfig: PropTypes.shape({ themeConfig: PropTypes.shape({
default: PropTypes.string.isRequired, defaultTheme: PropTypes.string.isRequired,
disableSwitch: PropTypes.bool.isRequired, disableSwitch: PropTypes.bool.isRequired,
respectPrefersColorScheme: PropTypes.bool.isRequired, respectPrefersColorScheme: PropTypes.bool.isRequired,
themes: PropTypes.array.isRequired, themes: PropTypes.array.isRequired,

View File

@ -27,7 +27,7 @@ const ThemeChanger = ({ theme, setTheme, loading, themeConfig }) => {
<span className="text-base-content text-opacity-40 capitalize text-sm"> <span className="text-base-content text-opacity-40 capitalize text-sm">
{loading {loading
? skeleton({ width: 'w-16', height: 'h-5' }) ? skeleton({ width: 'w-16', height: 'h-5' })
: theme === themeConfig.default : theme === themeConfig.defaultTheme
? 'Default' ? 'Default'
: theme} : theme}
</span> </span>
@ -61,9 +61,9 @@ const ThemeChanger = ({ theme, setTheme, loading, themeConfig }) => {
> >
<ul className="p-4 menu compact"> <ul className="p-4 menu compact">
{[ {[
themeConfig.default, themeConfig.defaultTheme,
...themeConfig.themes.filter( ...themeConfig.themes.filter(
(item) => item !== themeConfig.default (item) => item !== themeConfig.defaultTheme
), ),
].map((item, index) => ( ].map((item, index) => (
<li key={index}> <li key={index}>
@ -73,7 +73,7 @@ const ThemeChanger = ({ theme, setTheme, loading, themeConfig }) => {
className={`${theme === item ? 'active' : ''}`} className={`${theme === item ? 'active' : ''}`}
> >
<span className="opacity-60 capitalize"> <span className="opacity-60 capitalize">
{item === themeConfig.default ? 'Default' : item} {item === themeConfig.defaultTheme ? 'Default' : item}
</span> </span>
</a> </a>
</li> </li>

View File

@ -3,7 +3,7 @@ import { hotjar } from 'react-hotjar';
export const getInitialTheme = (themeConfig) => { export const getInitialTheme = (themeConfig) => {
if (themeConfig.disableSwitch) { if (themeConfig.disableSwitch) {
return themeConfig.default; return themeConfig.defaultTheme;
} }
if ( if (
@ -19,10 +19,10 @@ export const getInitialTheme = (themeConfig) => {
if (themeConfig.respectPrefersColorScheme && !themeConfig.disableSwitch) { if (themeConfig.respectPrefersColorScheme && !themeConfig.disableSwitch) {
return window.matchMedia('(prefers-color-scheme: dark)').matches return window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark' ? 'dark'
: themeConfig.default; : themeConfig.defaultTheme;
} }
return themeConfig.default; return themeConfig.defaultTheme;
}; };
export const skeleton = ({ export const skeleton = ({
@ -113,7 +113,7 @@ export const constructConfigWithMissingValues = (config) => {
if (typeof config.themeConfig === 'undefined') { if (typeof config.themeConfig === 'undefined') {
const themeConfig = { const themeConfig = {
default: 'corporate', defaultTheme: 'corporate',
disableSwitch: false, disableSwitch: false,
respectPrefersColorScheme: false, respectPrefersColorScheme: false,
themes: [ themes: [

93
types/index.d.ts vendored
View File

@ -4,7 +4,7 @@
import { Component } from 'react'; import { Component } from 'react';
interface Github { export interface Github {
/** /**
* GitHub org/user name * GitHub org/user name
*/ */
@ -38,7 +38,7 @@ interface Github {
}; };
} }
interface Social { export interface Social {
/** /**
* LinkedIn * LinkedIn
*/ */
@ -90,7 +90,57 @@ interface Social {
email?: string; email?: string;
} }
interface Config { export interface Blog {
/**
* medium | dev.to
*/
source: string;
/**
* Username
*/
username: string;
/**
* How many posts to display
*
* Max is 10
*/
limit: number;
}
export interface GoogleAnalytics {
/**
* GA3 tracking id/GA4 tag id UA-XXXXXXXXX-X | G-XXXXXXXXXX
*/
id: string;
}
export interface Hotjar {
/**
* Hotjar id
*/
id: string;
/**
* Snippet Version
*/
snippetVersion: number;
}
export interface ThemeConfig {
/**
* Default theme
*/
defaultTheme: string;
/**
* Snippet Version
*/
snippetVersion: number;
}
export interface Config {
/** /**
* GitHub Config * GitHub Config
*/ */
@ -100,9 +150,44 @@ interface Config {
* Social links * Social links
*/ */
social?: Social; social?: Social;
/**
* Skill list
*/
skills?: Array<string>;
/**
* Experience list
*/
experiences?: Array<string>;
/**
* Education list
*/
education?: Array<string>;
/**
* Blog config
*/
blog?: Blog;
/**
* Google Analytics config
*/
googleAnalytics?: GoogleAnalytics;
/**
* Hotjar config
*/
hotjar?: Hotjar;
/**
* Theme config
*/
themeConfig?: ThemeConfig;
} }
interface GitProfileProps { export interface GitProfileProps {
/** /**
* Config values * Config values
*/ */